-
1. Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
jaysensharma Dec 16, 2014 8:33 AM (in response to mmichael.fiscal.treasury.gov)>> By default WARs outside an EAR can not reference the JARs present inside the EAR, Until you configure a dependency using "$WAR/META-INF/MANIFEST.MF" or "$WAR/WEB-INF/jboss-deployment-structure.xml" as described in [1]
Example: By placing similar "$WAR/WEB-INF/jboss-deployment-structure.xml" it can be achieved.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="deployment.YOUR_EAR.ear.YOUR_EJB_JAR.jar"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
By placing above kind of "jboss-deployment-structure.xml" isnide the WAR we are instructing wildfly to make the JAR "YOUR_EJB_JAR.jar" present inside the EAR "YOUR_EAR.ear" accessible to the WAR.
[1] https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly
-
2. Re: Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
jaysensharma Dec 16, 2014 8:40 AM (in response to jaysensharma)I re read your question....
You asked:
What is the trick to make all jars in EAR/Lib folder available to all Web projects in EAR?
By default all the JARs present inside the EAR/lib will be accessible from the WARs Present inside the same EAR as sub modules . Mean the classes present inside the "$EAR/$WAR_Module/WEB-INF/classes" or "$EAR/$WAR_Module/WEB-INF/lib" (jars) wil have access to the $EAR/lib jars. So if you noticing that the classes present inside your WAR are not able to access the classes from $EAR/lib jars then there is something wrong. Are you getting some ClassNotFoundException or NoClassDefFoundError?
-
3. Re: Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
jaysensharma Dec 16, 2014 8:45 AM (in response to mmichael.fiscal.treasury.gov)I also noticed that you mentioned "EAR/Lib" , We must remember that it is case sensitive (if it is not typo mistake). Ideally it should be lowercase "lib" ($EAR/lib)
-
4. Re: Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
mmichael.fiscal.treasury.gov Dec 16, 2014 10:23 AM (in response to jaysensharma)This was typo on my part. The libraries are in EAR/lib folder. The WAR project that is not see classes is in same ear and throws ClassNotFoundExceptions when starting. If we move the jars to WAR\WebContent\lib folder application runs as expected.
-
5. Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
ctomc Dec 16, 2014 10:43 AM (in response to mmichael.fiscal.treasury.gov)how does your application.xml look like?
-
6. Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
mmichael.fiscal.treasury.gov Dec 16, 2014 10:47 AM (in response to ctomc)<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<application-name>MyAPP</application-name>
<display-name>MyAPP</display-name>
<module id="Module_1404300065394">
<web>
<web-uri>APP_WEB.war</web-uri>
<context-root>APP</context-root>
</web>
</module>
</application>
-
7. Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
jaysensharma Dec 16, 2014 9:30 PM (in response to mmichael.fiscal.treasury.gov)Can you please paste the complete stackTrace of the ClassNotFoundException which you are getting. Because many times NoClassDefFlundError or ClassNotFoundException can be caused due to some other issues as well like LinkageError or class initialization failure ..etc.
-
8. Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
mmichael.fiscal.treasury.gov Dec 17, 2014 9:08 AM (in response to jaysensharma)09:03:31,142 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final-redhat-1
09:03:31,298 INFO [org.jboss.msc] (main) JBoss MSC version 1.1.5.Final-redhat-1
09:03:31,361 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015899: JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19) starting
09:03:32,626 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found RSTM_EAR.ear in deployment directory. To trigger deployment create a file called RSTM_EAR.ear.dodeploy
09:03:32,627 INFO [org.xnio] (MSC service thread 1-2) XNIO Version 3.0.10.GA-redhat-1
09:03:32,627 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
09:03:32,658 INFO [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.0.10.GA-redhat-1
09:03:32,705 INFO [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version (unknown)
09:03:32,705 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 44) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
09:03:32,705 INFO [org.jboss.as.security] (ServerService Thread Pool -- 42) JBAS013171: Activating Security Subsystem
09:03:32,720 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 46) JBAS015537: Activating WebServices Extension
09:03:32,720 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 37) JBAS011800: Activating Naming Subsystem
09:03:32,720 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 29) JBAS010280: Activating Infinispan subsystem.
09:03:32,783 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 35) JBAS012605: Activated the following JSF Implementations: [main, 1.2]
09:03:32,798 INFO [org.jboss.as.connector.logging] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (IronJacamar 1.0.26.Final-redhat-1)
09:03:32,798 INFO [org.jboss.as.security] (MSC service thread 1-4) JBAS013170: Current PicketBox version=4.0.19.SP8-redhat-1
09:03:32,954 INFO [org.jboss.as.naming] (MSC service thread 1-6) JBAS011802: Starting Naming Service
09:03:32,954 INFO [org.jboss.as.mail.extension] (MSC service thread 1-3) JBAS015400: Bound mail session [java:jboss/mail/Default]
09:03:33,032 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
09:03:33,079 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010403: Deploying JDBC-compliant driver class com.ibm.db2.jcc.DB2Driver (version 4.13)
09:03:33,469 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-8) JBWEB003001: Coyote HTTP/1.1 initializing on : http-/127.0.0.1:8080
09:03:33,516 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-8) JBWEB003000: Coyote HTTP/1.1 starting on: http-/127.0.0.1:8080
09:03:33,516 INFO [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.0.Final-redhat-3
09:03:33,578 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
09:03:33,594 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/rstm]
09:03:33,610 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory C:\Users\mmichael\EAP-6.3.0\jboss-eap-6.3\standalone\deployments
09:03:33,610 INFO [org.jboss.as.remoting] (MSC service thread 1-8) JBAS017100: Listening on 127.0.0.1:4447
09:03:33,610 INFO [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on 127.0.0.1:9999
09:03:33,610 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "RSTM_EAR.ear" (runtime-name: "RSTM_EAR.ear")
09:03:34,061 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "null" (runtime-name: "RSTM_WEB.war")
09:03:34,134 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-5) JBWEB003001: Coyote HTTP/1.1 initializing on : http-/127.0.0.1:8443
09:03:34,134 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-5) JBWEB003000: Coyote HTTP/1.1 starting on: http-/127.0.0.1:8443
09:03:41,398 WARN [org.jboss.as.ee] (MSC service thread 1-3) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
09:03:41,398 WARN [org.jboss.as.ee] (MSC service thread 1-3) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
09:03:41,539 INFO [org.jboss.web] (ServerService Thread Pool -- 61) JBAS018210: Register web context: /RSTM
09:03:41,555 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/RSTM]] (ServerService Thread Pool -- 61) No Spring WebApplicationInitializer types detected on classpath
09:03:41,570 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/RSTM]] (ServerService Thread Pool -- 61) Initializing Spring root WebApplicationContext
09:03:43,271 WARN [org.jboss.modules] (ServerService Thread Pool -- 61) Failed to define class gov.treas.publicdebt.rs.tm.service.RSTMFactory in Module "deployment.RSTM_EAR.ear:main" from Service Module Loader: java.lang.LinkageError: Failed to link gov/treas/publicdebt/rs/tm/service/RSTMFactory (Module "deployment.RSTM_EAR.ear:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:277) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:92) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.Module.loadModuleClass(Module.java:568) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:236) [spring-core-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:392) [spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348) [spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319) [spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594) [spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396) [spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:382) [spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:353) [spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:82) [spring-context-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609) [spring-context-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) [spring-context-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) [spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.2.RELEASE.jar:4.0.2.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:161) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:59) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:94) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:482) [rt.jar:1.7.0]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:345) [rt.jar:1.7.0]
at java.util.concurrent.FutureTask.run(FutureTask.java:177) [rt.jar:1.7.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1121) [rt.jar:1.7.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614) [rt.jar:1.7.0]
at java.lang.Thread.run(Thread.java:777) [vm.jar:1.7.0]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.NoClassDefFoundError: org.springframework.beans.factory.FactoryBean
at java.lang.ClassLoader.defineClassImpl(Native Method) [vm.jar:1.7.0]
at java.lang.ClassLoader.defineClass(ClassLoader.java:284) [vm.jar:1.7.0]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.3.Final-redhat-1]
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.FactoryBean from [Module "deployment.RSTM_EAR.ear:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final-redhat-1]
-
9. Re: Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
jaysensharma Dec 17, 2014 9:30 AM (in response to mmichael.fiscal.treasury.gov)The Following error is basically a LinkageError, Looks like this linkage error is actually causing [NoClassDefFoundError: org.springframework.beans.factory.FactoryBean]
Failed to define class gov.treas.publicdebt.rs.tm.service.RSTMFactory in Module "deployment.RSTM_EAR.ear:main" from Service Module Loader: java.lang.LinkageError: Failed to link gov/treas/publicdebt/rs/tm/service/RSTMFactory (Module "deployment.RSTM_EAR.ear:main" from Service Module Loader)
So can you please let us know where exactly have you placed the "gov.treas.publicdebt.rs.tm.service.RSTMFactory" class inside your EAR "RSTM_EAR.ear"? Have you placed multiple copies of this class inside your Application / jboss module?
Where exactly have you placed the Spring related JARs? (inside RSTM_EAR.ear/lib or inside some Web Module of this EAR)
If you have defined some custom module then provide us the information about those custom modules (like the module.xml details so that we can see the list of jars which are present inside the module) , Also it will be best to list the JARs present inside the EAR/lib or EAR's sub-modules lib directory.
-
10. Re: Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
mmichael.fiscal.treasury.gov Dec 17, 2014 9:36 AM (in response to jaysensharma)There are three jars in RSTM_EAR.ear/lib folder one for gov.treas.publicdebt.rs.service.*, DAO.*, APP.*. All other dependencies are in Web Module of EAR.
-
11. Re: Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
jaysensharma Dec 17, 2014 9:42 AM (in response to mmichael.fiscal.treasury.gov)Can you tell us that whether the class "gov.treas.publicdebt.rs.tm.service.RSTMFactory" (which is present inside your EAR/lib jars) wants to use some spring related classes or not?
I am suspecting that your class "gov.treas.publicdebt.rs.tm.service.RSTMFactory" is dependent on some spring classes like [org.springframework.beans.factory.FactoryBean], But as per the specifications the classes (as a jar) present inside the "EAR/lib" will NOT have access to the Web Module resources like (WEB-INF/lib jars) of that EAR.
So can you please confirm and check if that is the case? if yes, then you should move the "gov.treas.publicdebt.rs.service.*" related classes/jars as well inside the WEB-INF/classes or WEB-INF/lib
-
12. Re: Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
mmichael.fiscal.treasury.gov Dec 17, 2014 10:59 AM (in response to jaysensharma)Yes, you are correct that it runs if we move the 3 jars into WAR\lib or to classes folder and that these three jars need classes from jars in WAR. We never had to build it like that way in Websphere. We are large organization with 100s of projects is there away to make this work in JBOSS and if so how?
-
13. Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
jaikiran Dec 31, 2014 11:50 PM (in response to mmichael.fiscal.treasury.gov)Matt, the Java EE spec states that the .war deployment (even nested within a .ear) will have an isolated classloader of its own. This means that other deployments (like the .ear or sibling .war) will not be able to see/access classes/resources in the .war deployment. If your application has classes that are needed across the sibling deployments then they are expected to be packaged in the .ear/lib folder (which is visible to all the deployments within that .ear).
In this specific case you seem to have certain shared jars/classes (three jars in RSTM_EAR.ear/lib folder one for gov.treas.publicdebt.rs.service.*, DAO.*, APP.*) in the .ear/lib folder but some (Spring?) jar that these classes depend on are within the .war/lib folder. The right way to fix this would be to move those other (Spring?) jars to .ear/lib folder too.
-
14. Re: EAP 6.3 - How to get jars in EAR\Lib folder accessible to WAR Project
mmichael.fiscal.treasury.gov Jan 5, 2015 8:23 AM (in response to jaikiran)I would like to thank everyone for their help. We were able to correct the issue by including the three jars in MANIFEST.MF file with. Class-Path: DAO.jar APP.jar Service.jar .
Thanks again, Matt