meant to send it to the DEV list too.

---------- Forwarded message ---------
From: Todd Hill <[email protected]>
Date: Mon, Sep 4, 2017 at 11:38 AM
Subject: Re: [Dev] Custom API handler gets ClassNotFoundException
To: Harsha Kumara <[email protected]>


The profile I'm using is 'apim' (as opposed to the 'esb' profile). The
<packaging>bundle</packing> is comment out because I wasn't able to get
that working either.


On Mon, Sep 4, 2017 at 11:35 AM Harsha Kumara <[email protected]> wrote:

> Hi Todd,
>
> Can you attach the pom.xml of your custom handler?
>
> Thanks,
> Harsha
>
> On Mon, Sep 4, 2017 at 9:58 PM, Todd Hill <[email protected]> wrote:
>
>> Sorry if this is not the right place to send questions about writing a
>> custom Handler for WSO2 API Manager 2.1.0, but I don't see any other places
>> listed.
>>
>> I have written a custom handler that worked well with WSO2 ESB 4.8.0. We
>> are migrating to using the API Manager v2.1.0, so I updated the maven
>> dependencies, but now after I put the jar into
>> <APIM_HOME>/repository/components/lib and restart the API Manager, I get
>> this when my Handler class is invoked:
>>
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.synapse.core.axis2.Axis2MessageContext cannot be found by
>> esb.poc_1.0_SNAPSHOT_1.0.0
>> at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
>> at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
>> at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
>> at
>> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>>
>>
>> Here is the method in the handler:
>>
>> private void processPayload(CaosDecisionMakingData decisionMakingData,
>> MessageContext mc){
>> try {
>> RelayUtils.buildMessage(((Axis2MessageContext)
>> mc).getAxis2MessageContext());
>> } catch (IOException e) {
>> throw new RuntimeException(e);
>> } catch (XMLStreamException e) {
>> throw new RuntimeException(e);
>> }
>> OMElement restPayload = mc.getEnvelope().getBody().getFirstElement();
>> if (restPayload != null) {
>> decisionMakingData.setPostBodyElement(restPayload);
>> }
>> }
>>
>> The line with RelayUtils containing the cast is where the problem is.
>>
>>
>> Thanks for any help or direction you can give.
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Harsha Kumara
> Software Engineer, WSO2 Inc.
> Mobile: +94775505618 <+94%2077%20550%205618>
> Blog:harshcreationz.blogspot.com
>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

<!--
    <parent>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>carbon-parent</artifactId>
        <version>4.4.9</version>
    </parent>
-->

    <groupId>edu.wisc.services</groupId>
    <artifactId>esb.poc</artifactId>
    <version>1.0.0-SNAPSHOT</version>
<!--
    <packaging>bundle</packaging>
-->
    <repositories>
        <repository>
            <id>wso2-nexus</id>
            <name>WSO2 internal Repository</name>
            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
        </repository>
    </repositories>

    <profiles>
        <profile>
            <id>esb</id>
                <properties>
                    <esb.lib.dir>${user.home}/wso2esb-4.8.0/repository/components/lib</esb.lib.dir>
                </properties>
            <dependencies>
                <dependency>
                    <groupId>org.apache.synapse</groupId>
                    <artifactId>synapse-core</artifactId>
                    <version>2.1.7-wso2v10</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.synapse</groupId>
                    <artifactId>synapse-nhttp-transport</artifactId>
                    <version>2.1.7-wso2v10</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.synapse</groupId>
                    <artifactId>synapse-commons</artifactId>
                    <version>2.1.7-wso2v10</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.axis2.wso2</groupId>
                    <artifactId>axis2</artifactId>
                    <version>1.6.1.wso2v10</version>
                </dependency>
                <dependency>
                    <groupId>org.wso2.carbon</groupId>
                    <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
                    <version>4.2.2</version>
                </dependency>
                <dependency>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                    <version>12.0</version>
                </dependency>
                <dependency>
                    <groupId>net.sf.saxon</groupId>
                    <artifactId>Saxon-HE</artifactId>
                    <version>9.6.0-1</version>
                </dependency>

            </dependencies>
        </profile>
        <profile>
            <id>apim</id>
            <properties>
                <esb.lib.dir>${user.home}/wso2am-2.1.0/repository/components/lib</esb.lib.dir>
                <apim.velocity.tmplt.dir>${user.home}/wso2am-2.1.0/repository/resources/api_templates</apim.velocity.tmplt.dir>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.apache.synapse</groupId>
                    <artifactId>synapse-core</artifactId>
                    <version>2.1.7-wso2v10</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.synapse</groupId>
                    <artifactId>synapse-nhttp-transport</artifactId>
                    <version>2.1.2-wso2v2</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.synapse</groupId>
                    <artifactId>synapse-commons</artifactId>
                    <version>2.1.2-wso2v2</version>
                </dependency>
                <dependency>
                    <groupId>net.sf.saxon</groupId>
                    <artifactId>Saxon-HE</artifactId>
                    <version>9.6.0-1</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.osgi.core</artifactId>
                    <version>1.0.0</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <version>3.3.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <instructions>
                                <Bundle-SybolicName>esb.poc_1.0.0_SNAPSHOT</Bundle-SybolicName>
                                <Bundle-Name>esb.poc_1.0.0_SNAPSHOT</Bundle-Name>
                            </instructions>
                        </configuration>
                     </plugin>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.0.2</version>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <!-- here the phase you need -->
                                <phase>verify</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${apim.velocity.tmplt.dir}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/resources</directory>
                                            <includes>velocity_template.vm</includes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>

            </build>
        </profile>
    </profiles>

     <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                            <type>jar</type>
                            <overWrite>true</overWrite>
                            <outputDirectory>${esb.lib.dir}</outputDirectory>
                        </artifactItem>
                    </artifactItems>
                    <overWriteReleases>false</overWriteReleases>
                    <overWriteSnapshots>true</overWriteSnapshots>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to