Hi Todd, This might cause due to version issues and class loading issues. You might check the exports of synapse core bundle in both of these versions. I didn't have a chance to look at this yet. If you stuck on this issue, better to go with the bundle approach which I provided in the reference resource.
Thanks, Harsha On Tue, Sep 5, 2017 at 9:21 PM, Todd Hill <[email protected]> wrote: > So, Harsha, the issue isn't resolved, but I have some additional > information comparing the OSGI output from the API Manager v2.1.0 to the > ESB v4.8.0. > > I ran each server with the system property -DosgiConsole, so I could > query the bundle information. In both cases I let the WSO2 framework do the > bundling by putting the raw jar into the <WSO2_HOME>repository/components/lib. > The generate MANIFEST.MF files by the framework were listed earlier in this > thread. > > Below are the results after executing the OSGI command b <bundle_id> both > before the handler is executed and after it has executed (albeit with an > error in the APIM version). What is most notable is that the missing > package org.apache.synapse.core.axis2 is clearly imported in the ESB > version, but not in the APIM version. > > I'm a newbie to WSO2/OSGI, so I could be missing something ... but I > wonder if this helps you diagnose what might be going on. > Thank you. > > > > For reference, here are the import statements in the Handler class: > import com.google.common.base.Joiner; > import org.apache.axiom.om.*; > import org.apache.axis2.databinding.types.URI; > import org.apache.commons.lang.StringUtils; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.apache.synapse.MessageContext; > import org.apache.synapse.core.axis2.Axis2MessageContext; > import org.apache.synapse.rest.AbstractHandler; > import org.apache.synapse.rest.RESTConstants; > import org.apache.synapse.transport.passthru.util.RelayUtils; > > import javax.xml.namespace.QName; > import javax.xml.stream.XMLStreamException; > import java.io.IOException; > import java.io.StringReader; > import java.util.*; > > > Results > *APIM 2.1.0* > > *Before executing Handler* > osgi> b 57 > esb.poc_1.0.0_SNAPSHOT_1.0.0 [57] > Id=57, Status=ACTIVE Data Root=/Users/tkhill/wso2am-2.1. > 0/repository/components/default/configuration/org. > eclipse.osgi/bundles/57/data > "No registered services." > No services in use. > Exported packages > edu.wisc.services.esbpoc; version="0.0.0"[exported] > Imported packages > org.apache.synapse.rest; version="0.0.0"<synapse-core_2.1.7.wso2v10 > [675]> > javax.xml.stream; version="1.0.1"<org.eclipse.osgi_3.9.1.v20130814-1242 > [0]> > org.apache.axiom.om; version="1.2.11.wso2v11"<axiom_1.2.11.wso2v11 > [13]> > org.apache.axis2.databinding.types; > version="1.6.1.wso2v20"<axis2_1.6.1.wso2v20 > [14]> > org.apache.commons.logging; version="1.2.0"<org.wso2.carbon.logging_4.4.11 > [454]> > No fragment bundles > Named class space > esb.poc_1.0.0_SNAPSHOT; bundle-version="1.0.0"[provided] > No required bundles > > *After executing Handler (but gets error - > org.apache.synapse.core.axis2.Axis2MessageContext cannot be found by > esb.poc_1.0.0_SNAPSHOT_1.0.0)* > osgi> b 57 > esb.poc_1.0.0_SNAPSHOT_1.0.0 [57] > Id=57, Status=ACTIVE Data Root=/Users/tkhill/wso2am-2.1. > 0/repository/components/default/configuration/org. > eclipse.osgi/bundles/57/data > "No registered services." > No services in use. > Exported packages > edu.wisc.services.esbpoc; version="0.0.0"[exported] > Imported packages > org.apache.synapse.rest; version="0.0.0"<synapse-core_2.1.7.wso2v10 > [675]> > javax.xml.stream; version="1.0.1"<org.eclipse.osgi_3.9.1.v20130814-1242 > [0]> > org.apache.axiom.om; version="1.2.11.wso2v11"<axiom_1.2.11.wso2v11 > [13]> > org.apache.axis2.databinding.types; > version="1.6.1.wso2v20"<axis2_1.6.1.wso2v20 > [14]> > org.apache.commons.logging; version="1.2.0"<org.wso2.carbon.logging_4.4.11 > [454]> > org.apache.synapse; version="0.0.0"<synapse-core_2.1.7.wso2v10 [675]> > org.jaxen; version="1.1.1"<axiom_1.2.11.wso2v11 [13]> > org.apache.axiom.om.xpath; version="1.2.11.wso2v11"<axiom_1.2.11.wso2v11 > [13]> > org.apache.commons.lang; version="2.6.0"<commons-lang_2.6.0.wso2v1 > [46]> > com.google.common.base; version="19.0.0"<com.google.guava_19.0.0 [32]> > No fragment bundles > Named class space > esb.poc_1.0.0_SNAPSHOT; bundle-version="1.0.0"[provided] > No required bundles > > > > ESB 4.8.0 > *Before executing Handler * > osgi> b 40 > esb.poc_1.0.0_SNAPSHOT_1.0.0 [40] > Id=40, Status=ACTIVE Data Root=/Users/tkhill/wso2esb-4. > 8.0/repository/components/default/configuration/org. > eclipse.osgi/bundles/40/data > "No registered services." > No services in use. > Exported packages > edu.wisc.services.esbpoc; version="0.0.0"[exported] > Imported packages > org.apache.synapse.rest; version="0.0.0"<synapse-core_2.1.2.wso2v2 > [526]> > org.apache.axis2.databinding.types; > version="1.6.1.wso2v10"<axis2_1.6.1.wso2v10 > [15]> > javax.xml.stream; > version="1.0.1"<org.eclipse.osgi_3.8.1.v20120830-144521 > [0]> > org.apache.axiom.om; version="1.2.11.wso2v4"<axiom_1.2.11.wso2v4 > [14]> > org.apache.commons.logging; > version="1.1.1"<org.wso2.carbon.logging_4.2.0 > [236]> > No fragment bundles > Named class space > esb.poc_1.0.0_SNAPSHOT; bundle-version="1.0.0"[provided] > No required bundles > > *After executing Handler* > osgi> b 40 > esb.poc_1.0.0_SNAPSHOT_1.0.0 [40] > Id=40, Status=ACTIVE Data Root=/Users/tkhill/wso2esb-4. > 8.0/repository/components/default/configuration/org. > eclipse.osgi/bundles/40/data > "No registered services." > No services in use. > Exported packages > edu.wisc.services.esbpoc; version="0.0.0"[exported] > Imported packages > org.apache.synapse.rest; version="0.0.0"<synapse-core_2.1.2.wso2v2 > [526]> > org.apache.axis2.databinding.types; > version="1.6.1.wso2v10"<axis2_1.6.1.wso2v10 > [15]> > javax.xml.stream; version="1.0.1"<org.eclipse.osgi_3.8.1.v20120830-144521 > [0]> > org.apache.axiom.om; version="1.2.11.wso2v4"<axiom_1.2.11.wso2v4 [14]> > org.apache.commons.logging; version="1.1.1"<org.wso2.carbon.logging_4.2.0 > [236]> > org.jaxen; version="1.1.1"<axiom_1.2.11.wso2v4 [14]> > org.apache.axiom.om.xpath; version="1.2.11.wso2v4"<axiom_1.2.11.wso2v4 > [14]> > org.apache.synapse.core.axis2; version="0.0.0"<synapse-core_2.1.2.wso2v2 > [526]> > org.apache.axis2.context; version="1.6.1.wso2v10"<axis2_1.6.1.wso2v10 > [15]> > org.apache.synapse.transport.passthru; > version="0.0.0"<synapse-nhttp-transport_2.1.2.wso2v2 > [529]> > org.apache.commons.lang; version="2.6.0"<commons-lang_2.6.0.wso2v1 > [31]> > com.google.common.base; version="12.0.0.wso2v1"<guava_12.0.0.wso2v1 > [43]> > org.apache.synapse; version="0.0.0"<synapse-core_2.1.2.wso2v2 [526]> > org.apache.axiom.soap; version="1.2.11.wso2v4"<axiom_1.2.11.wso2v4 > [14]> > org.apache.synapse.transport.passthru.util; > version="0.0.0"<synapse-nhttp-transport_2.1.2.wso2v2 [529]> > No fragment bundles > Named class space > esb.poc_1.0.0_SNAPSHOT; bundle-version="1.0.0"[provided] > No required bundles > > > On Tue, Sep 5, 2017 at 3:51 AM, Harsha Kumara <[email protected]> wrote: > >> Hi Todd, >> >> Yes your observation is correct, Jars placed in lib converts to OSGi >> bundles and copied to the dropins folder. We might need to debug this >> further with OSGi console as I don't see any issue with the both versions. >> However, you can follow the resources in provided link to get rid of this. >> Let us know if you couldn't able to sort out this issue. >> >> Thanks, >> Harsha >> >> On Mon, Sep 4, 2017 at 11:08 PM, Todd Hill <[email protected]> wrote: >> >>> Thanks, Harsha, that might prove useful, but the bigger question to me >>> is why even bother with the bundle part ... >>> >>> When I worked on the 4.8.0 ESB version, I just had to put the .jar file >>> into <ESB-HOME>/repository/components/lib and the wso2 framework took >>> care of bundling it and moving it to the dropins directory (along with >>> whatever bundling needs are required). >>> >>> The APIM also seems to do the same thing (i.e., put it in the >>> <APIM_HOME>/repository/components/lib directory and, again, the >>> framework does the bundling and putting it in the dropins directory). >>> >>> There isn't much difference in the wso2-framework generated MANIFEST.MF >>> file between the two. And yet I get ClassNotFoundExceptions in the APIM >>> version. >>> >>> TO COMPARE: >>> >>> generated MANIFEST.MF - 4.8.0 version of ESB: >>> Manifest-Version: 1.0 >>> Export-Package: edu.wisc.services.esbpoc >>> DynamicImport-Package: * >>> Bundle-ClassPath: .,esb.poc-1.0-SNAPSHOT.jar >>> Bundle-Version: 1.0.0 >>> Bundle-Name: esb.poc_1.0_SNAPSHOT >>> Bundle-ManifestVersion: 2 >>> Bundle-SymbolicName: esb.poc_1.0_SNAPSHOT >>> >>> generated MANIFEST.MF - 2.1.0 API Manager version: >>> Manifest-Version: 1.0 >>> Bundle-SymbolicName: esb.poc_1.0.0_SNAPSHOT >>> Export-Package: edu.wisc.services.esbpoc >>> Bundle-Name: esb.poc_1.0.0_SNAPSHOT >>> Bundle-Version: 1.0.0 >>> Bundle-ClassPath: .,esb.poc-1.0.0-SNAPSHOT.jar >>> Bundle-ManifestVersion: 2 >>> DynamicImport-Package: * >>> >>> On Mon, Sep 4, 2017 at 12:12 PM Harsha Kumara <[email protected]> wrote: >>> >>>> Hi Todd, >>>> >>>> Resource in [1] may be a good reference for you. >>>> >>>> [1] https://github.com/R-Rajkumar/samples/blob/master/messag >>>> e-builder-handler/pom.xml >>>> >>>> Thanks, >>>> Harsha >>>> >>>> On Mon, Sep 4, 2017 at 10:16 PM, Todd Hill <[email protected]> wrote: >>>> >>>>> 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.findClassInter >>>>>>> nal(BundleLoader.java:501) >>>>>>> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund >>>>>>> leLoader.java:421) >>>>>>> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund >>>>>>> leLoader.java:412) >>>>>>> at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa >>>>>>> dClass(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().get >>>>>>> FirstElement(); >>>>>>> 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 >>>>>> >>>>> >>>> >>>> >>>> -- >>>> Harsha Kumara >>>> Software Engineer, WSO2 Inc. >>>> Mobile: +94775505618 <+94%2077%20550%205618> >>>> Blog:harshcreationz.blogspot.com >>>> >>> >> >> >> -- >> Harsha Kumara >> Software Engineer, WSO2 Inc. >> Mobile: +94775505618 <+94%2077%20550%205618> >> Blog:harshcreationz.blogspot.com >> > > -- Harsha Kumara Software Engineer, WSO2 Inc. Mobile: +94775505618 Blog:harshcreationz.blogspot.com
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
