WSO2 ESB: JAR file with callback handler not loading - wso2

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

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! :)

Related

Bulk user import failing on wso2 identity server 5.11.0 with java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap

WSO2 Identity Server : 5.11.0
I am facing below error in logs while importing users using bulk import.
{org.apache.axis2.rpc.receivers.RPCMessageReceiver} - org/apache/commons/collections4/ListValuedMap java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
at org.wso2.carbon.user.mgt.bulkimport.ExcelUserBulkImport.createWorkbook(ExcelUserBulkImport.java:135)
at org.wso2.carbon.user.mgt.bulkimport.ExcelUserBulkImport.addUserList(ExcelUserBulkImport.java:59)
at org.wso2.carbon.user.mgt.UserRealmProxy.bulkImportUsers(UserRealmProxy.java:2208)
at org.wso2.carbon.user.mgt.UserAdmin.bulkImportUsers(UserAdmin.java:563)
... 80 more
**Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections4.ListValuedMap cannot be found by poi_3.17.0.wso2v1**
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:512)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:423)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:415)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:155)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 84 more
I tried out user bulk import with WSO2 - Identity Server version 5.11.0 with H2 and I could not reproduce any errors as such. But according to what I see there could be a missing dependency refer stackoverflow comment. You can download that missing jar file, add it to <IS_HOME>/repository/components/lib folder and try the scenario again after server restart. Furthermore you can validate any other issues regarding this scenario through the docs.

Problems running wso2ei sample 904 - kafka inbound endpoint

I trying out sample 904 for WSO2 EI and following the sample guidelines.
Still I'm getting the following error when starting up the runtime:
[2018-05-12 19:54:45,960] [] INFO - KAFKAMessageListener Creating Kafka Consumer Connector...
[2018-05-12 19:54:45,977] [] INFO - MediationStatisticsComponent Global Message-Flow Statistic Reporting is Disabled
Exception in thread "Thread-18" java.lang.NoClassDefFoundError: com/typesafe/scalalogging/Logger$
at kafka.utils.Log4jControllerRegistration$.<init>(Logging.scala:25)
at kafka.utils.Log4jControllerRegistration$.<clinit>(Logging.scala)
at kafka.utils.Logging.$init$(Logging.scala:47)
at kafka.utils.VerifiableProperties.<init>(VerifiableProperties.scala:27)
at kafka.consumer.ConsumerConfig.<init>(ConsumerConfig.scala:110)
at org.wso2.carbon.inbound.endpoint.protocol.kafka.KAFKAMessageListener.createKafkaConsumerConnector(KAFKAMessageListener.java:56)
at org.wso2.carbon.inbound.endpoint.protocol.kafka.KAFKAPollingConsumer.poll(KAFKAPollingConsumer.java:145)
at org.wso2.carbon.inbound.endpoint.protocol.kafka.KAFKAPollingConsumer.execute(KAFKAPollingConsumer.java:116)
at org.wso2.carbon.inbound.endpoint.protocol.kafka.KAFKATask.taskExecute(KAFKATask.java:48)
at org.wso2.carbon.inbound.endpoint.common.InboundRunner.run(InboundRunner.java:108)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.typesafe.scalalogging.Logger$ cannot be found by kafka_2.12_1.1.0_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(Unknown Source)
... 11 more
Don't know my options and I ran out of ideas. Any help would be appreciated.
Versions:
jre 1.8.0_161
wso2ei 6.2.0
kafka 2.12-1.1.0
zookeeper 3.4.12
Looks like it cannot find the "Logger" class. Are you sure you copied all of the required libs to /lib (also the one mentioned in the notes section of wso2 documentation if needed)?
What you could try is to start EI with osgi console enabled and check if the class is there. The following link might help.
OSGI
What you could also do is to open/extract the imported jar's and see if there's the class inside.

Startup Errors for Version 5.2 of WSO2 Identity Server

I have downloaded the latest version of wso2 identity server (5.2). However during the startup process I am getting the following errors.
[2016-10-26 09:50:27,563] INFO {org.wso2.carbon.webapp.mgt.TomcatGenericWebappsDeployer} - Deployed webapp: StandardEngine[Catalina].StandardHost[localhost].StandardContext[/wso2].File[D:\wso2is-5.2.0\bin\..\repository\deployment\server\webapps\wso2.war]
java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.
java.security.KeyStoreException: failed to extract any certificates or private keys - maybe bad password?
[2016-10-26 09:50:29,074] ERROR {org.jaggeryjs.scriptengine.engine.RhinoEngine} -
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Caused by: java.lang.ExceptionInInitializerError
at org.apache.commons.ssl.SSL.<init>(SSL.java:154)
at org.apache.commons.ssl.SSLClient.<init>(SSLClient.java:60)
at org.apache.commons.ssl.HttpSecureProtocol.<init>(HttpSecureProtocol.java:55)
at org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory.<init>(EasySSLProtocolSocketFactory.java:94)
at org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject.<init>(XMLHttpRequestHostObject.java:84)
... 113 more
Caused by: java.lang.NullPointerException
at org.apache.commons.ssl.TrustMaterial.<init>(TrustMaterial.java:127)
at org.apache.commons.ssl.TrustMaterial.<init>(TrustMaterial.java:118)
at org.apache.commons.ssl.TrustMaterial.<clinit>(TrustMaterial.java:108)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.ssl.KeyMaterial
at org.apache.commons.ssl.SSL.<init>(SSL.java:154)
at org.apache.commons.ssl.SSLClient.<init>(SSLClient.java:60)
It is a vanilla version of the server and I haven't made any kind of configuration changes. I am running on JDK 1.8. Can someone tell me what the resolution will be. I tried including "not-yet-commons-ssl-0.3.10.jar" and that didnt help.
Regards
Ranjith Madhavan
I recently got this exception, it was due to the fact that i donot have /lib/security/cacerts and /lib/security/jssecacerts in my jre.

Jetty deployment: Unable to compile class for JSP

I tried to deploy to and run Jetty from an Ant-script, but get the following error:
[jetty.run] 2016-06-25 09:16:54.333: Starting web application null
[jetty.run] [main] WARN org.eclipse.jetty.annotations.ServletContainerInitializersStarter -
[jetty.run] javax.servlet.ServletException: Not running on Jetty, WebSocket+CDI support unavailable
[jetty.run] at org.eclipse.jetty.cdi.websocket.WebSocketCdiInitializer.onStartup(WebSocketCdiInitializer.java:49)
[jetty.run] at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
[jetty.run] at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
[jetty.run] at
...
It work without deployment, but with the war-file this happens. What is corrupt?
UPDATE:
Added
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
to web.xml andweld jars to lib. Now I get this:
java.lang.reflect.InvocationTargetException
[jetty.run] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[jetty.run] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[jetty.run] at ...
[jetty.run] Caused by: java.lang.IllegalStateException: Nothing to bind for name BeanManager
UPDATE 2:
Ok, I didn't need the extra things in my web.xml. Instead I had forgot to add
<typedef name="webApp" classname="org.eclipse.jetty.ant.AntWebAppContext" classpathref="classpath" loaderref="jetty.loader"/>
to build.xml. I can now deploy and run jetty, but can't process JSP files:
[jetty.run] [qtp1387380406-14] WARN org.eclipse.jetty.servlet.ServletHandler -
[jetty.run] org.apache.jasper.JasperException: Unable to compile class for JSP
[jetty.run] at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600) ...
Why is this so?
Remove the various jetty cdi jar files from your project.
Those are designed specifically for jetty-distribution use, and are inappropriate for embedded-jetty.
Use the weld jars directly in your war file, along with the various recommended configurations that the weld project documentation tell you about.

WSO2-CEP KafkaReceiver deployment

I have defined a KafkaReceiver usind WSO2-CEP in management console.
It doesn't work and I can read this error on server-console log
[2016-02-26 10:17:25,412] INFO {org.wso2.carbon.event.input.adapter.core.internal.InputAdapterRuntime} - Connecting receiver kafkaReceiver
[2016-02-26 10:17:25,415] ERROR {org.wso2.carbon.event.input.adapter.core.internal.InputAdapterRuntime} - Error initializing Input Adapter 'kafkaReceiver, hence this will be suspended indefinitely, Cannot access kafka context due to missing jars
org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterRuntimeException: Cannot access kafka context due to missing jars
at org.wso2.carbon.event.input.adapter.kafka.KafkaEventAdapter.createConsumerConfig(KafkaEventAdapter.java:114)
at org.wso2.carbon.event.input.adapter.kafka.KafkaEventAdapter.createKafkaAdaptorListener(KafkaEventAdapter.java:132)
at org.wso2.carbon.event.input.adapter.kafka.KafkaEventAdapter.connect(KafkaEventAdapter.java:66)
at org.wso2.carbon.event.input.adapter.core.internal.InputAdapterRuntime.start(InputAdapterRuntime.java:72)
at org.wso2.carbon.event.input.adapter.core.internal.InputAdapterRuntime.startPolling(InputAdapterRuntime.java:62)
at org.wso2.carbon.event.input.adapter.core.internal.CarbonInputEventAdapterService.startPolling(CarbonInputEventAdapterService.java:187)
at org.wso2.carbon.event.receiver.core.internal.CarbonEventReceiverService.startPolling(CarbonEventReceiverService.java:620)
at org.wso2.carbon.event.receiver.core.internal.CarbonEventReceiverManagementService.startPolling(CarbonEventReceiverManagementService.java:99)
at org.wso2.carbon.event.processor.manager.core.internal.CarbonEventManagementService$2.run(CarbonEventManagementService.java:184)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: kafka/consumer/ConsumerConfig
at org.wso2.carbon.event.input.adapter.kafka.KafkaEventAdapter.createConsumerConfig(KafkaEventAdapter.java:112)
... 15 more
Caused by: java.lang.ClassNotFoundException: kafka.consumer.ConsumerConfig cannot be found by org.wso2.carbon.event.input.adapter.kafka_5.0.3
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)
... 16 more
If we read the class source at this link https://github.com/wso2/carbon-analytics-common/blob/master/components/event-receiver/event-input-adapters/org.wso2.carbon.event.input.adapter.kafka/src/main/java/org/wso2/carbon/event/input/adapter/kafka/KafkaEventAdapter.java
I read that the error is in ConsumerConfig creation
In order to use kafka you need to add kafka download and copy following client JAR files to /repository/components/lib/ directory
kafka_2.10-0.8.2.1.jar
zkclient-0.3.jar
scala-library-2.10.4.jar
zookeeper-3.4.6.jar
metrics-core-2.2.0.jar
kafka-clients-0.8.2.1.jar
[1]. https://docs.wso2.com/display/CEP400/Supporting+Different+Transports#SupportingDifferentTransports-KafkaTransport