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

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.

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.

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!

Deploying JPA 2 (OpenJPA) on Jboss 7.1.0-Final-Snapshot

I have deployed axis2 on Jboss 7.1.0 Final Snapshot. We have a service (.aar) which uses OPenJPA 2.1.
All the OpenJPA jars are packaged within the service archive.
When I start the server I see this error message
Constructor threw exception; nested exception is java.lang.RuntimeException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named example
I have defined the provider in the persistence.xml as org.apache.openjpa.persistence.PersistenceProviderImpl
Structure of my Service is as follows,
SampleOpenJPAService.aar
|-lib
|-myJPAClasses.jar
Can anyone help me in understanding What is going wrong here.
regards,
sathwik

Java advanced imaging not available to EJB modules in Glassfish on Mac, but show up in EARs

I'm developing an application that uses the Geotools, which in turn uses the Java Advanced imaging (JAI) API to run under Glassfish. When I run my application from Netbeans as an EJB jar file it fails to deploy because of a ClassNotFoundException during CDI scanning :
com.google.common.collect.ComputationException: org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class org.autogena.skyserver.data.filetypes.SwathFile
at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)
....
Caused by: org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class org.autogena.skyserver.data.filetypes.SwathFile
at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:189)
.....
Caused by: java.lang.NoClassDefFoundError: javax/media/jai/PropertySource
at java.lang.ClassLoader.defineClass1(Native Method)
....
Caused by: java.lang.ClassNotFoundException: javax.media.jai.PropertySource
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
However, if I package the EJB module into an EAR file then I don't get the exception above and it seems to load ok.
Since on the Mac the JAI core classes are in the system extension library I'm baffled how it's not showing up on the classpath.
Is there a difference between an EJB jar and and EAR file when it comes to class loading, or is this a big in Glassfish / Weld?
Come to think of it - how is glassfish finding the libraries my prject uses anyway - they don't seem to be packaged into the ejb jar file - is netbeans doing something clever under the hood here that's going somehow askew?
thanks,
Josh
Try to configure the CLASSPATH on Glassfish in order to use the JAI libraries.

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.