Suppose I have a jar file called 'util.jar'. This jar file contains mostly JPA entities and some útil classes (no EJBs). How do I make this jar available to all wars deployed in Wildfly (without placing the jar inside the war's WEB-INF/lib)?
I thied to create a module in Wildfly:
<module xmlns="urn:jboss:module:1.3" name="br.edu.ufca">
<resources>
<resource-root path="ufca.jar"/>
</resources>
<dependencies>
</dependencies>
</module>
and in my war MANIFEST.MF file:
Dependencies: br.edu.ufca export
but I'm getting all sorts of erros, like these:
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.LinkageError: Failed to link br/edu/ufca/web/FalhaValidacaoParametroVisao (Module "br.edu.ufca:main" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\wildfly-8.1.0.Final\modules,C:\wildfly-8.1.0.Final\modules\system\layers\base)))
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:219)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 more
Caused by: java.lang.RuntimeException: java.lang.LinkageError: Failed to link br/edu/ufca/web/FalhaValidacaoParametroVisao (Module "br.edu.ufca:main" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\wildfly-8.1.0.Final\modules,C:\wildfly-8.1.0.Final\modules\system\layers\base)))
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:275)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:190)
... 7 more
Caused by: java.lang.LinkageError: Failed to link br/edu/ufca/web/FalhaValidacaoParametroVisao (Module "br.edu.ufca:main" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\wildfly-8.1.0.Final\modules,C:\wildfly-8.1.0.Final\modules\system\layers\base)))
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:277) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:92) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.Module.loadModuleClass(Module.java:568) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_20]
at java.lang.Class.forName(Class.java:340) [rt.jar:1.8.0_20]
at com.sun.faces.util.Util.loadClass(Util.java:325)
at com.sun.faces.config.processor.AbstractConfigProcessor.loadClass(AbstractConfigProcessor.java:376)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:427)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags(FaceletTaglibConfigProcessor.java:378)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:321)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:270)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:437)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:216)
... 9 more
Caused by: java.lang.NoClassDefFoundError: javax/faces/event/SystemEventListener
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_20]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) [rt.jar:1.8.0_20]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.3.Final]
... 27 more
Caused by: java.lang.ClassNotFoundException: javax.faces.event.SystemEventListener from [Module "br.edu.ufca:main" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\wildfly-8.1.0.Final\modules,C:\wildfly-8.1.0.Final\modules\system\layers\base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
... 31 more
15:12:16,710 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "email-servidores.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./email-servidores" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./email-servidores: Failed to start service
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.LinkageError: Failed to link br/edu/ufca/web/FalhaValidacaoParametroVisao (Module \"br.edu.ufca:main\" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\\wildfly-8.1.0.Final\\modules,C:\\wildfly-8.1.0.Final\\modules\\system\\layers\\base)))
Caused by: java.lang.RuntimeException: java.lang.LinkageError: Failed to link br/edu/ufca/web/FalhaValidacaoParametroVisao (Module \"br.edu.ufca:main\" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\\wildfly-8.1.0.Final\\modules,C:\\wildfly-8.1.0.Final\\modules\\system\\layers\\base)))
Caused by: java.lang.LinkageError: Failed to link br/edu/ufca/web/FalhaValidacaoParametroVisao (Module \"br.edu.ufca:main\" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\\wildfly-8.1.0.Final\\modules,C:\\wildfly-8.1.0.Final\\modules\\system\\layers\\base)))
Caused by: java.lang.NoClassDefFoundError: javax/faces/event/SystemEventListener
Caused by: java.lang.ClassNotFoundException: javax.faces.event.SystemEventListener from [Module \"br.edu.ufca:main\" from local module loader @16e9adb (finder: local module finder @121714c (roots: C:\\wildfly-8.1.0.Final\\modules,C:\\wildfly-8.1.0.Final\\modules\\system\\layers\\base))]"}}
15:12:16,745 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "email-servidores.war" (runtime-name : "email-servidores.war")
15:12:16,751 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./email-servidores: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./email-servidores: Failed to start service
15:12:16,859 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
15:12:16,859 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
15:12:16,860 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.1.0.Final "Kenny" started (with errors) in 6985ms - Started 275 of 331 services (2 services failed or missing dependencies, 91 services are lazy, passive or on-demand)
15:12:17,001 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016009: Stopping weld service for deployment email-servidores.war
15:12:17,241 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment email-servidores.war (runtime-name: email-servidores.war) in 252ms
15:12:17,354 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "email-servidores.war" (runtime-name: "email-servidores.war")
15:12:17,356 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.deployment.unit."email-servidores.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
service jboss.deployment.unit."email-servidores.war".component."javax.faces.webapp.FacesServlet".START (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
service jboss.deployment.unit."email-servidores.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
service jboss.deployment.unit."email-servidores.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
service jboss.deployment.unit."email-servidores.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
service jboss.deployment.unit."email-servidores.war".component."org.jboss.weld.servlet.WeldInitialListener".START (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
service jboss.deployment.unit."email-servidores.war".component."org.jboss.weld.servlet.WeldTerminalListener".START (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
service jboss.undertow.deployment.default-server.default-host./email-servidores (missing) dependents: [service jboss.deployment.unit."email-servidores.war".deploymentCompleteService]
JBAS014777: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./email-servidores
Thank you.
Marcos
UPDATE
It worked now. I added the following dependencies:
<dependencies>
<module name="javaee.api"/>
<module name="javax.faces.api"/>
</dependencies>
An alternative to creating a custom module and defining a dependency to that module is to just deploy the jar file to the application server (f.i. ufca.jar). Once the jar is deployed, you can simply declare a dependency to this deployment from your war-file using f.i. deployment.ufca.jar as the id.
In your war-file you can f.i. use the jboss-deployment-structure.xml to add the dependency, f.i. using
<dependencies>
<module name="deployment.ufca.jar" />
</dependencies>
See also: https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With