0
votes

I am trying to setup a proxy service that hides the security of a back end service, following the tutorial found here. For the password callback handler I follow the instructions found here. All pretty basic and straightforward.

I compiled the PWCBHandler class into a JAR file and put it in the esbhome\repository\components\lib folder together with all the JAR files from wss4j-1.6.15\lib.

I see no warnings or errors during startup of the ESB. However when I test the proxy service, I get the following error in the log:

org.apache.axis2.AxisFault: Error in obtaining a token
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:76)
    at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
...
Caused by: org.apache.rampart.RampartException: Error in obtaining a token
    at org.apache.rampart.util.RampartUtil.getToken(RampartUtil.java:779)
    at org.apache.rampart.util.RampartUtil.getIssuedToken(RampartUtil.java:675)
...
Caused by: org.apache.rampart.RampartException: Cannot load password callback class: PWCBHandler
    at org.apache.rampart.util.RampartUtil.getPasswordCB(RampartUtil.java:144)
    at org.apache.rampart.util.RampartUtil.getPasswordCB(RampartUtil.java:118)
    at org.apache.rampart.util.RampartUtil.getToken(RampartUtil.java:723)
...
    ... 26 more
Caused by: java.lang.ClassNotFoundException: PWCBHandler
    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)
    ... 26 more
Caused by: java.lang.ClassNotFoundException: PWCBHandler
    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:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:190)
    at org.apache.ws.security.util.Loader.loadClass(Loader.java:200)
    at org.apache.ws.security.util.Loader.loadClass(Loader.java:163)
    at org.apache.rampart.util.RampartUtil.getPasswordCB(RampartUtil.java:142)
    ... 28 more
[2014-06-16 15:56:23,103]  WARN - FaultHandler ERROR_CODE : 0
[2014-06-16 15:56:23,103]  WARN - FaultHandler ERROR_MESSAGE : Unexpected error during sending message out
[2014-06-16 15:56:23,103]  WARN - FaultHandler ERROR_DETAIL : org.apache.synapse.SynapseException: Unexpected error during sending message out
    at org.apache.synapse.core.axis2.Axis2Sender.handleException(Axis2Sender.java:170)
    at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:69)
...

In other words, the ESB and Rampart know about the PWCBHandler class but it cannot load / access it.

At this point I have no ideas where to look further. Is there a way where I can check which JAR files were loaded during startup? What might prohibit the loading of the PWCBHandler JAR?

Thanks for your feedback,

Olivier

1
to check whether the jar file is loaded, you can start the server with osgi console (command: ./wso2server.sh -DosgiConsole). Once server completes loading, hit enter and you'll get the equinox osgi console. you can check the bundles with 'ss | grep <bundle_name>'. All equinox commands are valid here.Rajeev Sampath
The ss command showed the JAR file was indeed not loading. No indication why. The output did gave me an idea, don't know why. I noticed all the org.x.y package entries and that was something I did not do. So added the callback class to 'my' package, recompiled and re-jarred the thing and now the bundle is listed at id 3. Put on my todo list: dig into equinox... Thanks for the hint!Olivier

1 Answers

0
votes

Thanks to the answer from Rajeev I got confirmation the class was not loading.

I recreated the JAR file with the class added to a package and after restarting the server a bundle for the JAR was created. It looks like custom classes need to be added to a package for Carbon to create a bundle from it.

I know, I know, classes should always be added to a package, but I am not a Java hero and did not want to bother with the dirs and such.

Lessons learned! :)