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

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.

Related

Trying to deploy EAR in JBOSS 7.3. EJB.jar is not being looked up by the application in classpath

The structure of EAR is like this
EAR - Contains lmsweb.war and lmsEJB.jar
After deploying , when the application is trying to lookup at the bean, getting error as below
Unable to Get NamingException :javax.naming.CommunicationException: EJBCLIENT000062: Failed to look up "lms/lmsEJB/ejb/TestHome!com.lms.ejb.test.TestHome" [Root exception is java.lang.ClassNotFoundException: com.lms.ejb.test.TestHome from [Module "deployment.lms.ear.lmsWeb.war" from Service Module Loader]]
This class is inside the ejb module i.e., "deployment.lms.ear.lmsEJB.jar"
Can someone throw light on how to make the application look into the ejb module to get the class.

War deployment failing on Jboss 7.4

I am migrating from Jboss 6.4 to Jboss 7.4, First I have not made any changes in war file and tried to deploy it on Jboss 7.4, but I was getting below error. This error is coming for all filter and servlet classes which are configured in web.xml file.
Caused by: java.lang.IllegalArgumentException: UT010011: Filter log4jServletFilter of type class org.apache.logging.log4j.web.Log4jServletFilter does not implement javax.servlet.Filter
at io.undertow.servlet.api.FilterInfo.<init>(FilterInfo.java:74)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.createServletConfig(UndertowDeploymentInfoService.java:801)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.start(UndertowDeploymentInfoService.java:276)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
... 6 more
Then I tried with excluding undertow subsystem in jboss-deployment-structure.xml file as below. This time I was able to deploy war file without error, but application is not accessible with root context or any different way. On jboss admin console War is showing in active state but still accessible.
<exclude-subsystems>
<subsystem name="undertow" />
</exclude-subsystems>
Could anyone advise me to resolve filter or servlet class error?

Ojdbc8 jars upgrade to 21.1.0.0 throws Nosuchmethod exception UCPservletContextListener init

Ojdbc8, ons, ucp jars are upgraded to 21.1.0.0 version. When trying to start the app on tomcat server, it's throwing Nosuchmethod exception. Logged in the Tomcat's localhost.log file. Application tries to establish DB connection during startup itself.
01-Jun-2021 15:59:56.641 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 3 Spring WebApplication Initializers detected on classpath
01-Jun-2021 16:00:05.365 INFO localhost-startStop-1 org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
01-Jun-2021 16:00:19.397 SEVERE localhost-startStop-1 org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [oracle.ucp.jdbc.UCPServletContextListener]
java.lang.NoSuchMethodException: oracle.ucp.jdbc.UCPServletContextListener.init
at java.lang.class.getConstructor(Unknown Source)
This is a known issue with ucp.jar in 21.1. It will be fixed in 21.3 when it's released. In the meantime, you can remove this class from the ucp.jar:
oracle/ucp/jdbc/UCPServletContextListener.class
From my experience, if you put jdbc/ucp jars to Tomcat's lib (which is recommended for productive system) and set provided scope for them in Maven, the problem will disappear.
Another option could be setting metadata-complete="true" in web.xml (read more here and here)
if you are using spring boot then you can use
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
this dependency or update your maven project.

Unable to call JAX-WS client deployed on JBoss 7.1.1

I have a generated jax-ws web service client that runs fine when I run it as a java standalone project. However if I add it to a web application (war) deployed on JBoss 7.1.1 and call the web service it throws the following exception:
Caused by: java.lang.NoClassDefFoundError: com/ctc/wstx/io/DefaultInputResolver
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:628)
at com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.java:324)
at __redirected.__XMLInputFactory.createXMLStreamReader(__XMLInputFactory.java:139) [jboss-modules.jar:1.1.1.GA]
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1176)
at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:104)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:795)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1493)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1401)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:648)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:461)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:364)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:317)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at $Proxy189.getcodelists(Unknown Source)
Idea what I may be missing?
As the error says, the App server is unable to find the said class file. Is it possible in your standalone app your classpath has the library but JBoss AS 7 is unable to find it.
If you can isolate where this library is, you can either bundle it with your WAR file or create a jboss_module to satisfy the dependency.
Good luck!

Can I make a WAR depend on a JNDI entry in JBoss 5.1?

As part of an upgrade from JBoss 4.0.4 to 5.1, I am trying to get a WAR to deploy after an EAR is successfully deployed. JBoss 5.x does not support PrefixDeploymentSorter like 4.x did, which means that I have to use <depends> in the WAR's jboss-web.xml.
It seems I cannot depend on the EAR itself, so I pick the last deployed EJB instead. This EJB provides a JNDI entry that the WAR needs.
Here's the EJB as it deploys when the WAR is absent from the deploy directory:
2010-03-25 10:47:30,348 INFO [org.jboss.ejb3.session.SessionSpecContainer] (main) Starting jboss.j2ee:ear=my-ear.ear,jar=mypackage-ejb.jar,name=MyFacadeBean,service=EJB3
2010-03-25 10:47:30,350 INFO [org.jboss.ejb3.EJBContainer] (main) STARTED EJB: my.package.MyFacadeBean ejbName: MyFacadeBean
2010-03-25 10:47:30,371 INFO [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] (main) Binding the following Entries in Global JNDI:
my/MyFacade/local - EJB3.x Default Local Business Interface
my-ear/MyFacadeBean/local-my.package.MyFacade - EJB3.x Local Business Interface
And here's the depends snippet from jboss-web.xml:
<depends>jboss.j2ee:ear=my-ear.ear,jar=mypackage-ejb.jar,name=MyFacadeBean,service=EJB3</depends>
My problem is: The WAR starts to deploy immediately after "STARTED EJB:", i.e. before MyFacadeBean is bound to JNDI, which causes bean deployments to fail:
2010-03-25 10:47:39,068 ERROR [my.facade.FacadeFactory] (main) MyFacade not bound
2010-03-25 10:47:39,069 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[my.host.no].[/]] (main) StandardWrapper.Throwable
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at my.freemarker.servlet.FreemarkerController.setupPojoServiceFactory(FreemarkerController.java:621)
[...]
Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: MyFacade not bound
at my.facade.FacadeFactory.getFacade(FacadeFactory.java:61)
After the WAR has finished its deployment, MyFacade happily (mockingly?) continues its deployment and binds the JNDI entries.
If I hot-deploy the WAR after the EAR has deployed, everything works as intended.
I even thought of depending on a dummy EJB in the EAR, and using <module-order>strict</module-order> in jboss-app.xml to force it to load as the last module. But alas, JBoss 5.x does not support that either. Doh!
Is there a way to depend on the JNDI entry itself? Are there other ways of solving this?
Here's how you can achieve this on JBoss 5.1.x.
First, add a file called aliases.txt into the META-INF directory of your EAR. This file should just contain a single line with an arbitrary name / identifier for your EAR. For example, if you have my-ear.ear, your META-INF/aliases.txt file could contain 'my-ear'. It just needs to be something that won't clash with any other aliases declared by other apps deployed on the same server.
Next, add a jboss-dependency.xml file to the META-INF directory of your WAR, containing the following (subsituting 'my-ear' for the alias you created above):
<dependency xmlns="urn:jboss:dependency:1.0">
<item whenRequired="Real" dependentState="Create">my-ear</item>
</dependency>
This will ensure the EAR is deployed before the WAR.
Also, if you try to deploy the WAR without the EAR being present, JBoss will log a clear deployment error message telling you about the missing dependency.