Tomcat unable to access JARs in Spring3 WAR file - spring

I am developing a SOAP web service using Spring 3.0, Spring-WS, SpringSource toolsuite running tc server v6. When I run the application on the server, I get the following exception in SpringSource toolsuite.
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException:
Wrapper cannot find servlet class org.springframework.ws.transport.http.MessageDispatcherServlet or a class it depends on
at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:60)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:379)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)"
The org.springframework.ws.transport.http.MessageDispatcherServlet class is contained within the spring-ws-core-2.0.0.RELEASE.jar which is on my classpath. I have verified that the .JAR is contained within the WAR file but still getting the above exception.
This error occurs in both a stand-alone installation of Tomcat, and the embedded TC Lite server distributed with the STS.

You are probably missing some other dependent jar.
Wrapper cannot find servlet class org.springframework.ws.transport.http.MessageDispatcherServlet or a "class it depends on"
The depends on, check the pom dependencies for the ws-core. Try modifying the pom scope for the ws-core to compile (from provided if it is so)

Related

Upgraded my webapplication to use OJDBC8.jar. but Websphere8.5 refers to old version ojdbc6 and returns nosuchmethoderror

Error 500: java.lang.NoSuchMethodError: oracle/jdbc/OracleConnection.createOracleArray(Ljava/lang/String;Ljava/lang/Object;)Ljava/sql/Array; (loaded from file:/sysap/oracle/instantclient_11_2/ojdbc6.jar by com.ibm.ws.bootstrap.ExtClassLoader#96620801) called from class com.model.dao.TypeKeysDAO (loaded from file:/opt/WebSphere/8_5/AppServerBase1/profiles/AppServerBase1/installedApps/System_Cell/MyEnterprise.ear/MyEnterpriseWeb.war/WEB-INF/classes/ by com.ibm.ws.classloader.CompoundClassLoader#3edbaa21
The old copy of the JDBC jar appears to be associated with a JDBC provider defined in your configuration. The error message indicates that the class was loaded by WebSphere's ExtClassLoader, which is the loader that contains JDBC driver class paths. You'll need to remove the old JDBC provider, update its class path, or make it an "isolated" resource provider (which gives it a separate class loader that must be explicitly associated with an application) in order to get it out of the view of your application.
If there's some technical reason that you need ojdbc6.jar in the resource provider class path but need to reference ojdbc8.jar just within your application (not through a server-configured datasource), then you'll need to do some class loader configuration wizardry to make it work. The most reliable solution would be to create a shared library containing the new jar, set it to use an isolated class loader, and associate it with your EAR or WAR.
ojdbc6.jar is definitely there in the class path of the application. To locate from where it's loaded, you can login to the WebSphere Application server console (https://localhost:<admin-port>/ibm/console) and check the class loading details of your application.
This will show the list of classes/jars that are loaded for your application. Locate ojdbc6.jar from the list and see it's path.
You either would have added the ojdbc6.jar as a shared library or bundled in along with your Application (WEB-INF/lib directory) OR mentioned it in the class loader of the server itself.
file:/sysap/oracle/instantclient_11_2/ojdbc6.jar this is the sharedlibrary referenced by the EAR. I have added the ojdbc8.jar in this location and now the issue is fixed.

Log4j2 JSP Taglib not working in Spring-boot Embedded Servlet Containers

I have a Spring boot web application which I created using the spring-boot-starter-web artifact. I am using Spring Boot Embedded Servlet Containers features to use the Tomcat embedded server. I am able to run my app in Tomcat embedded mode. I can also create a WAR file of my app and deploy it to a normal installation of Tomcat.
I have one JSP page in which I am using log4j2's JSP taglib tags. On a normal installation of Tomcat the logging from that JSP page works as expected. But when bootRun on the Tomcat embedded server I get the following error
SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception [The absolute uri: [http://logging.apache.org/log4j/tld/log] cannot be resolved in either web.xml or the jar files deployed with this application] with root cause
org.apache.jasper.JasperException: The absolute uri: [http://logging.apache.org/log4j/tld/log] cannot be resolved in either web.xml or the jar files deployed with this application
Can this issue be solved?
The problem is occurring because Spring Boot skips log4j-*.jar by default. I've opened an issue to address this.
You can work around the problem by explicitly enabling scanning of the log4j-taglib jar. To do so, you need to add a TomcatContextCustomizer that changes the configuration of the jar scanner:
#Bean
TomcatContextCustomizer log4jTldScanningCustomizer() {
return (context) ->
((StandardJarScanFilter)context.getJarScanner().getJarScanFilter()).setTldScan("log4j-taglib*.jar");
}

How to use Jersey in Sling?

I've got Sling 8. I then include Jersey and this Jersey connector in my build: https://github.com/hstaudacher/osgi-jax-rs-connector
My next step should be simply write a Jersey Service and test it, but I'm getting this Exception immediately:
27.01.2017 10:54:16.696 *ERROR* [FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null.)org.osgi.framework.ServiceException: Service factory returned null.
and
[FelixDispatchQueue] com.eclipsesource.jaxrs.publisher FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command)
org.osgi.framework.ServiceException: Service factory exception: org/apache/felix/shell/Command
and
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/shell/Command
So I look at my bundles list in Felix, and I don't see any bundle that appears to provide this... So I find it online and install it myself. Now I get this exception:
Service factory exception: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
and
Caused by: java.lang.NoClassDefFoundError: org/apache/sling/extensions/threaddump/internal/ThreadDumpCommand
and
Caused by: java.lang.NoClassDefFoundError: org/apache/felix/webconsole/plugins/memoryusage/internal/MemoryUsageCommand
Now, I DO have a bundle installed with this class (it's "Apache Felix Web Console Memory Usage Plugin"). So now I really don't understand what the heck is going on.
I have a feeling that I'm not supposed to be providing my own "felix shell" bundle and that the OSGI in Sling is failing to provide it...
Is anybody successfully using Sling 8 and Jersey?
Maybe you should try with just a vanilla OSGi environment for starters. Once you have Jersey working then you can try integrating with Sling.
I have had success with jaxrs in OSGi, specifically using the Amdatu REST bundles.
https://amdatu.org/application/tutorial/step1/
With this I was able to use JAX-RS annotations to serve HTTP services:
https://github.com/figurate/figurate-core/blob/master/modules/figurate-osgi/src/main/groovy/org/figurate/osgi/http/ServiceInfo.groovy
You can see the bundles I used here:
https://github.com/figurate/figurate-core/blob/master/modules/figurate-osgi/src/test/resources/config/HttpVersionSpec.config

Websphere, Spring WS A resource reference binding could not be found

I am trying to deploy Spring web application using Spring Web Services on Websphere 8. Deploy to Tomcat works without any problem but with Websphere I needed to add jaxws-rt (this wasn't needed for Tomcat, but also with it is working) and after that I am still getting on WAS:
CWNEN0044E: A resource reference binding could not be found for the following resource
references [com.sun.xml.ws.transport.tcp.servicechannel.ServiceChannelWSImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.RegistrationRequesterPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.RegistrationPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.ActivationRequesterPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.RegistrationCoordinatorPortTypeImpl/wsContext,
com.sun.xml.ws.mex.server.MEXEndpoint/wsContext,
com.sun.xml.ws.tx.webservice.member.at.CoordinatorPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.coord.ActivationCoordinatorPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.at.CompletionInitiatorPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.at.ParticipantPortTypeImpl/wsContext,
com.sun.xml.ws.tx.webservice.member.at.CompletionCoordinatorPortTypeImpl/wsContext]
How to specify reference bindings?
I also see another error during deployin SystemErr:
Caused by: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load
webapp: Failed to load webapp: javax.servlet.ServletContainerInitializer: Provider
com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer not a subtype
But I am not sure if this is somehow connected with reference binding problem.

Class Loading Issue with HornetMQ and JBoss 7.0.2

I am working on a JBoss 7.0.2 instance. Our app is a war and messages are dropped into the queue. This works fine. But when we read it via a listener, the system throws an exception. It is looking for a class which is present in the WEB-INF/classes.
I understand that the module classloader (if I am right it is HornetMQ) is not able to see this application class and throwing up. I dont want my application class to be part of the server lib. That class living within the war is the best place.
The exception is :
javax.jms.JMSException: com.yyy.TransportMessage from [Module "org.hornetq:main" from local module loader #238b8914
(roots: /Users/xxx/jboss/multi/jboss-as-7.0.2.Final/modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:71)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)
at com.xxx.MessageReceiver.handleObjectMessage(NSMessageReceiver.java:72)
at com.xxx.jms.JMSListener.onMessage(JMSListener.java:1540)
at org.hornetq.jms.client.JMSMessageListenerWrapper.onMessage(JMSMessageListenerWrapper.java:91)
What should I do to make this work?
Regards.
ashok

Resources