使用依赖项从 Eclipse 将 Web 应用程序部署到 JBoss
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15614333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Deploy web applications to JBoss from Eclipse, with dependencies
提问by lmsasu
I have a project developed under Eclipse with JBoss tools installed. When I deploy the application to the Jboss server, some helper jar files which are made available to the project through Maven are not copied inside the WEB-INF/lib folder. Hence, I get a ClassNotFound
exception at runtime.
我有一个在 Eclipse 下开发的项目,并安装了 JBoss 工具。当我将应用程序部署到 Jboss 服务器时,一些通过 Maven 提供给项目的帮助 jar 文件没有复制到 WEB-INF/lib 文件夹中。因此,我ClassNotFound
在运行时遇到异常。
Is there any approach to convince Eclipse (or Maven) to copy the jars into the lib folder at deployment?
有什么方法可以说服 Eclipse(或 Maven)在部署时将 jars 复制到 lib 文件夹中?
EDIT: the pom.xml looks like:
编辑: pom.xml 看起来像:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.whatever.simulators</groupId>
<artifactId>eebuildingsim</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>eebuildingsim Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- begin JBoss -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.2.FINAL</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<version>2.3.0.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
<!-- end JBoss -->
<dependency>
<groupId>ro.mysite</groupId>
<artifactId>petrinetexec</artifactId>
<version>0.1.3.81</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.whatever.myAuxiliaryStuff</groupId>
<artifactId>myAuxiliaryStuff </artifactId>
<version>0.1.0.1305</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.0-m09</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.0-m09</version>
</dependency>
</dependencies>
<build>
<finalName>eebuildingsim</finalName>
</build>
The artifact myAuxiliaryStuff
should be deployed under WEB-INF/lib
, under the jboss deployment server.
该工件myAuxiliaryStuff
应部署在WEB-INF/lib
jboss 部署服务器下。
Using:
使用:
- Eclipse: Juno Service Release 1
- Jboss: 7.1.1. final
- m2e 1.3.1.20130219-1424
- eclipse web tools platform 3.4.2.v2013
- Eclipse:Juno 服务第 1 版
- Jboss:7.1.1。最终的
- m2e 1.3.1.20130219-1424
- eclipse web 工具平台 3.4.2.v2013
Later edit: the error reported in jboss' log file looks like:
稍后编辑:jboss 的日志文件中报告的错误如下所示:
12:31:38,507 INFO [org.jboss.weld.deployer] (MSC service thread 1-5)
JBAS016002: Processing weld deployment mywar.war 12:31:38,522 ERROR
[org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed
to start service jboss.deployment.unit."mywar.war".POST_MODULE:
org.jboss.msc.service.StartException in service
jboss.deployment.unit."mywar.war".POST_MODULE: Failed to process phase
POST_MODULE of deployment "mywar.war" at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119)
[jboss-as-server-7.1.1.Final.jar:7.1.1.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.runWorker(ThreadPoolExecutor.java:1110)
[rt.jar:1.7.0_05] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
[rt.jar:1.7.0_05] at java.lang.Thread.run(Thread.java:722)
[rt.jar:1.7.0_05] Caused by: java.lang.NoSuchFieldError: FLOW at
com.sun.faces.flow.FlowDiscoveryCDIExtension.<clinit>(FlowDiscoveryCDIExtension.java:90)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) [rt.jar:1.7.0_05] at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[rt.jar:1.7.0_05] at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[rt.jar:1.7.0_05] at
java.lang.reflect.Constructor.newInstance(Constructor.java:525)
[rt.jar:1.7.0_05] at
org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadExtension(WeldPortableExtensionProcessor.java:117)
at
org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadAttachments(WeldPortableExtensionProcessor.java:100)
at
org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.deploy(WeldPortableExtensionProcessor.java:86)
at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113)
[jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 more
12:31:38,522 INFO [org.jboss.as.server] (DeploymentScanner-threads -
2) JBAS015870: Deploy of deployment "mywar.war" was rolled back with
failure message {"JBAS014671: Failed services" =>
{"jboss.deployment.unit.\"mywar.war\".POST_MODULE" =>
"org.jboss.msc.service.StartException in service
jboss.deployment.unit.\"mywar.war\".POST_MODULE: Failed to process
phase POST_MODULE of deployment \"mywar.war\""}} 12:31:38,647 INFO
[org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877:
Stopped deployment mywar.war in 115ms 12:31:38,647 INFO
[org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774:
Service status report JBAS014775: New missing/unsatisfied
dependencies:
service jboss.naming.context.java.module.mywar.mywar (missing) dependents: [service
jboss.naming.context.java.module.mywar.mywar.ValidatorFactory, service
jboss.naming.context.java.module.mywar.mywar.Validator] JBAS014777:
Services which failed to start: service
jboss.deployment.unit."mywar.war".POST_MODULE:
org.jboss.msc.service.StartException in service
jboss.deployment.unit."mywar.war".POST_MODULE: Failed to process phase
POST_MODULE of deployment "mywar.war"
12:31:38,647 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.unit.\"mywar.war\".POST_MODULE" =>
"org.jboss.msc.service.StartException in service
jboss.deployment.unit.\"mywar.war\".POST_MODULE: Failed to process
phase POST_MODULE of deployment \"mywar.war\""}}}}
回答by Old Pro
Eclipse and the plugins are a bit finicky. This is what I've done to get it to work.
Eclipse 和插件有点挑剔。这就是我为使其正常工作所做的工作。
Project -> Properties -> Deployment Assembly
Add...
Java Build Path Entries (Next >)
Maven Dependencies (Finish)
The Deploy Properties panel should now include an entry for Source: Maven Dependecies -> Deploy Path: WEB_INF/lib
Deploy Properties 面板现在应该包括 Source: Maven Dependecies -> Deploy Path: WEB_INF/lib 的条目
回答by Sam Rad
This is suspicious:
这很可疑:
java.lang.NoSuchFieldError: FLOW
Which is related to JSF, if I'm not mistaken. I've got a few suggestions but I'm not an expert in any aspect.
如果我没记错的话,这与 JSF 相关。我有一些建议,但我不是任何方面的专家。
First try to add provided
dependency scope for jsf-api
and jsf-impl
like this (since the JBoss has them):
首先尝试添加provided
依赖范围为jsf-api
和jsf-impl
这样的(因为JBoss已经它们):
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.0-m09</version>
<scope>provided</scope> // <----- do it for both
</dependency>
AFAIK, JBoss 7.1.1 already has the JSF 2.1.7. So, if you really need the JSF 2.2 you should update the JSF module in JBoss. Here is how to Migration to JSF 2.2
.
AFAIK,JBoss 7.1.1 已经有 JSF 2.1.7。因此,如果您真的需要 JSF 2.2,您应该更新 JBoss 中的 JSF 模块。这是如何Migration to JSF 2.2
。
Another option is to bundle the JSF in to your WAR and inform JBoss to exclude the container version(the one that is shipped with JBoss) of it:
另一种选择是将 JSF 捆绑到您的 WAR 中,并通知 JBoss 排除它的容器版本(JBoss 附带的版本):
in web.xmladd:
在web.xml添加:
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
and in jboss-deployment-structure.xmlexclude the JBoss's implementation:
并在jboss-deployment-structure.xml 中排除 JBoss 的实现:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="javax.faces.api" />
</exclusions>
.
.
.
回答by eis
Based on your description, you only have Eclipse and JBoss Tools in use and dependencies stored in Maven pom files. For Eclipse to become aware of those dependencies, you need to have eclipse-maven integration. M2e is the common choice for it.
根据您的描述,您只使用了 Eclipse 和 JBoss 工具,并且依赖项存储在 Maven pom 文件中。为了让 Eclipse 意识到这些依赖关系,您需要进行 eclipse-maven 集成。M2e是它的常见选择。
So you would need these installed:
所以你需要安装这些:
回答by Atilla Ozgur
Go to the directory where your pom.xml resides and execute following command.
转到您的 pom.xml 所在的目录并执行以下命令。
mvn package
This command should create a war file for you to deploy to your application server. This file is a zip file, look to its contents and see if your myAuxiliaryStuff.jar is in web-inf/lib. If it is, your problem lies with eclipse integration with maven.
此命令应为您创建一个用于部署到应用程序服务器的 war 文件。这个文件是一个 zip 文件,查看它的内容,看看你的 myAuxiliaryStuff.jar 是否在 web-inf/lib 中。如果是,您的问题在于 Eclipse 与 Maven 的集成。
回答by Stoffe
You seem to have everything installed. I had this problem too. Just needed to right click on the project and choose.
你似乎已经安装了所有东西。我也有这个问题。只需要右键单击项目并选择。
"Mark as Deployable"
“标记为可部署”