gpt4 book ai didi

java - 在 jBoss AS 中创建模块

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:04:41 26 4
gpt4 key购买 nike

我正在使用 jBoss AS 7 来发布我的各种项目,并且所有项目都使用 Jersey API,因此我不想在每个项目中都部署它,而是想为它创建一个模块。为此,我创建了文件夹 JBOSS_HOME\modules\com\sun\Jersey\main 并在该文件夹中放置了 Jersey jar 和文件 module.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.sun.jersey">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="jersey-bundle-1.12.jar"/>
<resource-root path="asm-3.1.jar"/>
<resource-root path="jackson-core-asl-1.9.2.jar"/>
<resource-root path="jackson-jaxrs-1.9.2.jar"/>
<resource-root path="jackson-mapper-asl-1.9.2.jar"/>
<resource-root path="jackson-xc-1.9.2.jar"/>
<resource-root path="jersey-client-1.12.jar"/>
<resource-root path="jersey-core-1.12.jar"/>
<resource-root path="jersey-json-1.12.jar"/>
<resource-root path="jersey-server-1.12.jar"/>
<resource-root path="jersey-servlet-1.12.jar"/>
<resource-root path="jettison-1.1.jar"/>
<resource-root path="jsr311-api-1.1.1.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.jboss.staxmapper"/>
<module name="org.jboss.as.controller"/>
<module name="org.jboss.as.server"/>
<module name="org.jboss.modules"/>
<module name="org.jboss.msc"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.vfs"/>
</dependencies>
</module>

为了防止使用 jBoss JAX-RS,我从文件 JBOSS_HOME\standalone\standalone.xml 中删除了以下行:

<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
<extension module="org.jboss.as.jaxrs"/>

在 MyProjectEAR\META-INF 文件夹中,我创建了具有以下结构的 jboss-deployment-structure.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="com.sun.jersey" slot="main" >
<imports>
<include path="META-INF/**"/>
<include path="**"/>
</imports>
</module>
</dependencies>
</deployment>
</jboss-deployment-structure>

我的 MyProject\webContent\web.xml 文件是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name> MyProject </display-name>

<servlet>
<description>
</description>
<servlet-name>Jersey Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<description></description>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.MyProject.service.REST_Application</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Jersey Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
</web-app>

MyProject\webContent\META-INF\MANIFEST.MF 中的 list 文件是这样的:

Manifest-Version: 1.0
Class-Path:

当我尝试部署项目时出现以下错误:

12:12:11,804 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "MyProjectEAR.ear"
12:12:11,852 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "MyProject.war"
12:12:12,052 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.jersey:main") which may be changed or removed in future versions without notice.
12:12:12,054 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.jersey:main") which may be changed or removed in future versions without notice.
12:12:12,055 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.misc:main") which may be changed or removed in future versions without notice.
12:12:12,057 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.misc:main") which may be changed or removed in future versions without notice.
12:12:12,117 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "MyProject.war" of deployment "MyProjectEAR.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_30]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_30]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_30]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011093: Could not load component class com.sun.jersey.spi.container.servlet.ServletContainer
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:113)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:54)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
... 5 more
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer from [Module "deployment.MyProjectEAR.ear.MyProject.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:111)
... 7 more
12:12:12,340 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "MyProjectEAR.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE: Failed to process phase POST_MODULE of subdeployment \"MyProject.war\" of deployment \"MyProjectEAR.ear\""}}
12:12:12,351 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment MyProject.war in 9ms
12:12:12,353 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment MyProjectEAR.ear in 12ms
12:12:12,355 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "MyProject.war" of deployment "MyProjectEAR.ear"
12:12:12,359 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE: Failed to process phase POST_MODULE of subdeployment \"MyProject.war\" of deployment \"MyProjectEAR.ear\""}}}}

* 编辑:* 如果我将 Jersey API 放在 JBOSS_HOME\modules\com\sun\jsf-impl\main 中并更改相应的 module.xml 一切正常。这个位置有什么不同?

最佳答案

您需要在部署中指定对您的模块的依赖。

元信息\ list .MF

Dependencies: com.sun.jersey

另见 https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

关于java - 在 jBoss AS 中创建模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9925266/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com