Error listenerStart - JaxWS - JBoss as 7 - classpath

I'm trying to migrate a Jax-WS based web service to JBoss as 7 but the application (deployed as a war) failes to start the listener on start-up.
ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-14) Error listenerStart
ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-14) Context [/abc] startup failed due to previous errors
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-14) MSC000001: Failed to start service jboss.web.deployment.default-host (...)
The error message references to failed due to previous errors however no errors are printed in the log. The application in question bundles jax-ws-rt like this:
<dependency>
<groupId>sun-jaxws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.1.7</version>
</dependency>
If I change the scope of the jax-ws-rt to be provided this causes a nice ClassNotFound as expected.
WARN [org.jboss.as.ee] (MSC service thread 1-13) JBAS011006: Not installing optional component com.sun.xml.ws.transport.http.servlet.WSServletContextListener due to exception: java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener (…)
The servlet is defined like this in the web.xml.
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<description>JAX-WS endpoint for data service</description>
<display-name>abc</display-name>
<servlet-name>abc</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>/services/abc</url-pattern>
</servlet-mapping>
I cant understand whats wrong. How do I solve this and get the application deployed?
Thoughts:
Am I missing a dependency?
Can I reconfigure the war to use Jboss internal JaxWS without major refactoring?
If I cant use a jboss internal JaxWS version can I force Jboss to use a version of Jaxws that I bundle in the war? (If so, what dependencies do I need for JaxWs?)

with JBoss AS7 (Java EE6) you actually shouldn't need to put the WSServlet in the web.xml as the servlet-class. But instead you would have there the class name of the class annotated with #Webservice
All you want to do is make sure that in you JBoss configuration (e.g. standalone.xml) you have extension for webservices enabled:
<extensions>
[...]
<extension module="org.jboss.as.webservices"/>
</extensions>

Related

Need strategy for identifying root cause of "JBAS011232: Only one JAX-RS Application Class allowed"

I have a problem similar to my previous one. I have a webapp that runs fine in JBoss EAP 6.4. I want to add some functionality to my webapp so that it can manipulate a hive-metastore. I add a single dependency to my pom.xml:
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>3.1.2</version>
</dependency>
If I now try to start my webapp, it fails at start up:
15:07:37,718 ERROR [org.jboss.msc.service.fail] (MSC service thread
1-5) MSC000001: Failed to start service
jboss.deployment.unit."myapp-0.0.1-SNAPSHOT.war".POST_MODULE:
org.jboss.msc.service.StartException in service
jboss.deployment.unit."myapp-0.0.1-SNAPSHOT.war".POST_MODULE:
JBAS018733: Failed to process phase POST_MODULE of deployment
"myapp-0.0.1-SNAPSHOT.war"
... Caused by:
org.jboss.as.server.deployment.DeploymentUnitProcessingException:
JBAS011232: Only one JAX-RS Application Class allowed.
com.sun.jersey.api.core.servlet.WebAppResourceConfig
com.sun.jersey.api.core.DefaultResourceConfig
com.sun.jersey.server.impl.application.DeferredResourceConfig
com.sun.jersey.api.core.ClassNamesResourceConfig
org.glassfish.jersey.server.ResourceConfig$WrappingResourceConfig
org.glassfish.jersey.server.ResourceConfig
org.glassfish.jersey.server.ResourceConfig$RuntimeConfig
com.sun.jersey.api.core.ScanningResourceConfig
com.sun.jersey.api.core.ResourceConfig
com.sun.jersey.api.core.PackagesResourceConfig
com.mycompany.RestApplication
com.sun.jersey.api.core.ApplicationAdapter
com.sun.jersey.api.core.ClasspathResourceConfig
The message "JBAS011232: Only one JAX-RS Application Class allowed" seems to be caused by my webapp trying to use both RestEasy (v. 2.3.10.Final-redhat-1) and Jersey. JBoss uses RestEasy by default. Apparently, hive-jdbc must directly or indirectly have a Jersey application class.
I would like to eliminate this problem by indicating that I don't want to use a Jersey-based application class. What strategy can I employ to discover where that Jersey-based class exists? If I generate the dependency tree with mvn,
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
hive-jdbc has nearly 800 lines of dependencies. There must be a better strategy than looking through the source code of all of the dependencies. Or, is there somehow a way to tell JBoss to ignore Jersey application classes?
BTW, unlike my previous question, hadoop-common doesn't seem to be the culprit. When I look at the occurrences of "hadoop-common" in the dependency tree, I see the following:
My current strategy goes like this:
Repeat
add exclusion to likely looking package in pom file
start JBoss and examine console log
if console log has no JBAS01132 error then
if console log has no startup failure due to NoClassDefFound error then
Done!
else remove exclusion
until Done
I can't get to "done". At this point, I seem to be stuck on the jersey-server package. Without it being present, we get the NoClassDefFound error. With it, we get JBAS011232: Only one JAX-RS Application Class allowed.

Wildfly 8.2 fails to load jbossws-cxf-client module

I am working on a web application that contains a Soap client and that needs to have access to the cxf Client implmentation, because we have to use different certificates for different calls to the remote endpoint.
Wildfly comes with a module jbossws-cxf-client which has dependencies to all the different cxf modules required. There is a maven version of this module as well.
In the maven module pom file we have a dependency like so:
<dependency>
<groupId>org.jboss.ws.cxf</groupId>
<artifactId>jbossws-cxf-client</artifactId>
<version>4.3.2.Final</version>
<scope>provided</scope>
</dependency>
Note that the version has been matched with the version that is mentioned in the wildfly 8.2 release notes:http://wildfly.org/news/2014/11/20/WildFly82-Final-Released/
When deploying our application we get the following message from the log:
14:22:12,492 INFO [org.jboss.weld.Bootstrap] (weld-worker-1) WELD-000119: Not generating any bean definitions from nl.topicuszorg.lsp.service.MultipleCertificatePingStubServiceImpl because of underlying class loading error: Type org.apache.cxf.transport.Conduit from [Module "deployment.kdplus-lsphub-server-1.1-SNAPSHOT.war:main" from Service Module Loader] not found. If this is unexpected, enable DEBUG logging to see the full error.
14:22:12,689 INFO [org.apache.deltaspike.core.util.ProjectStageProducer] (MSC service thread 1-2) Computed the following DeltaSpike ProjectStage: Production
14:22:13,628 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."kdplus-lsphub-server-1.1-SNAPSHOT.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."kdplus-lsphub-server-1.1-SNAPSHOT.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type PingStubService with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject nl.topicuszorg.lsp.service.PingPongServiceImpl.pingStubService
at nl.topicuszorg.lsp.service.PingPongServiceImpl.pingStubService(PingPongServiceImpl.java:0)
The real problem is logged as INFO, strangely enough. org.apache.cxf.transport.Conduit can not be loaded. This is part of the org.apache.cxf module, and should be loaded transitively by loading the jbossws-cxf-client module.
It should not be necessary, but we also implicitely declare the module dependencies in the jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<excludes>
</excludes>
<dependencies>
<module name="org.slf4j"/>
<module name="org.apache.cxf"/>
<module name="jbossws-cxf-client"/>
<module name="org.apache.cxf.impl"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
It seems the module is not loaded, I don't know why. I can not find a way to check which modules have been loaded.
What is going wrong here?
As it turned out I had to move my jboss-deployment-structure.xml from the META-INF to the WEB-INF directory.
Bummer...

com.sun.jersey.spi.spring.container.servlet.SpringServlet cannot be cast to javax.servlet.Servlet

I am trying to deploy a RESTful web service in JBOSS7.1.1 and it is giving me the error below:
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/anthut]] (MSC service thread 1-1) Servlet /anthut threw load() exception: java.lang.ClassCastException: com.sun.jersey.spi.spring.container.servlet.SpringServlet cannot be cast to javax.servlet.Servlet.
The version of jersey that I am using in my project is 1.18.3.
A section of my web.xml is given below
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>abdfserve</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
please what could be responsible for this, I have being on this for some days now...I need help please..
This can happen when you have multiple versions of the servlet API in your classpath.
The servlet API is always provided by the web application server, you must not include it in your own web application bundles.
You need it as a compile-time dependency during development, but it should not be deployed. If you use Maven, make sure it has "provided" scope.

Errors when deploying Tomcat7 webapp

I'm trying to deploy a simple Resteasy application using Java7 to Tomcat7.
I get these errors on startup:
SEVERE: Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
java.lang.NoClassDefFoundError: org/scannotation/AnnotationDB$CrossReferenceException
SEVERE: Exception sending context destroyed event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
java.lang.NullPointerException
I'm using apache maven for the dependencies which is retrieving from
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
The web.xml can be found at http://pastebin.com/Nsuh71ES.
Any help is appreciated.
After examining the maven cache, the jboss resteasy library hadn't been fully downloaded.
The problem was due to the fact that org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap could not be accessed

Facelets tab lib not recognised by Eclipse/Tomcat 6

I included this in my index.jsp JSF file:
<%# taglib prefix="ui" uri="http://java.sun.com/jsf/facelets"%>
and Eclipse underlines the URL, hovering gives this:
Cannot find the tag library descriptor for "http://java.sun.com/jsf/facelets"
Deploying and trying to start Tomcat 6 using the Tomcat plugin causes this:
|STDOUT| 2010-03-03 17:57:29,872 | INFO | [main]: Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
|STDOUT| 2010-03-03 17:57:29,904 | INFO | [main]: ServletContext 'C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myapp\' initialized.
|STDOUT| 2010-03-03 17:57:29,904 | INFO | [main]: Checking for plugins:org.apache.myfaces.FACES_INIT_PLUGINS
03-Mar-2010 17:57:29 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
03-Mar-2010 17:57:29 org.apache.catalina.core.StandardContext start
SEVERE: Context [/myapp] startup failed due to previous errors
...
03-Mar-2010 17:57:30 com.sun.faces.config.ConfigureListener contextDestroyed
SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:804)
My web.xml contains this
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
My face-config.xml contains this
<application>
<!-- tell JSF to use Facelets -->
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
And my application build has the latest JSF 2.0.2 jsf-api.jar and jsf-impl.jar. I've also got MyFaces 1.2.8 and all the latest commons jars. The app was building fine til I upgraded JSF. I would at least expect a run time error but here Eclipse cannot see the taglib. What else could I be missing?
EDIT
For full information - I took out Mojarra and left in Myfaces. This meant I needed to remove this from my web.xml:
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
and replace it with the equivalent for myfaces:
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
Thanks
Do not mix JSF 2.0 with JSF pre-2.0. It may lead to unexpected results (like the one above).
Choose a JSF 2.0 implementation (mojarra as it seems) and remove all myfaces and facelets libraries.
Well that's annoying. I read in a couple of places that the new Mojarra release embedded facelets. I added jsf-facelets-1.1.14.jar to my build and it deployed ok.