假设我有一个名为'util.jar'的jar文件。这个jar文件主要包含JPA实体和一些útil类(没有EJB)。如何让这个jar可用于Wildfly中部署的所有战争(不将jar放入战争的WEB-INF / lib中)?
我想在Wildfly中创建一个模块:
<module xmlns="urn:jboss:module:1.3" name="br.edu.ufca">
<resources>
<resource-root path="ufca.jar"/>
</resources>
<dependencies>
</dependencies>
</module>
在我的战争MANIFEST.MF文件中:
Dependencies: br.edu.ufca export
但是我得到了各种各样的错误,比如:
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
谢谢。
马科斯
更新
现在有用了。我添加了以下依赖项:
<dependencies>
<module name="javaee.api"/>
<module name="javax.faces.api"/>
</dependencies>
答案 0 :(得分:3)
创建自定义模块并定义对该模块的依赖关系的另一种方法是将jar文件部署到应用程序服务器(f.i. ufca.jar)。部署jar后,您只需使用f.i从war文件中声明对此部署的依赖关系。 deployment.ufca.jar作为id。
在你的战争文件中你可以f.i.使用jboss-deployment-structure.xml添加依赖项f.i.使用
<dependencies>
<module name="deployment.ufca.jar" />
</dependencies>
另请参阅:https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly
答案 1 :(得分:0)
如果出于技术原因真的需要,可以通过配置中的这一部分来允许部署访问您的模块类:
<subsystem xmlns="urn:jboss:domain:ee:1.0" >
<global-modules>
<module name="br.edu.ufca" slot="main" />
</global-modules>
</subsystem>
我通常在发布JDBC驱动程序时使用这种方式,当然首先是DataSource,但也因为当应用程序代码需要访问实现类时。
如果您想在多个独立部署之间共享大量依赖关系,那么这是一种节省内存的好方法。