本文介绍了从Eclipse将Web应用程序部署到JBoss,并具有依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Eclipse下开发的项目,安装了JBoss工具。当我将应用程序部署到Jboss服务器时,通过Maven可以使用的一些助手jar文件不会被复制到WEB-INF / lib文件夹中。因此,在运行时我得到一个 ClassNotFound 异常。



有没有办法说服Eclipse(或Maven)将jars复制到lib文件夹中?



编辑: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>

<依赖关系>

<! - 开始JBoss - >

<依赖关系>
< groupId> org.jboss.resteasy< / groupId>
< artifactId> resteasy-jaxrs< / artifactId>
< version> 2.3.2.FINAL< / version>
< scope>已提供< / scope>
< / dependency>

<依赖关系>
< groupId> org.jboss.resteasy< / groupId>
< artifactId> jaxrs-api< / artifactId>
< version> 2.3.0.GA< / version>
< scope>已提供< / scope>
< / dependency>

<依赖关系>
< groupId> org.apache.httpcomponents< / groupId>
< artifactId> httpclient< / artifactId>
< version> 4.1.2< / version>
< scope>已提供< / scope>
< / dependency>

<! - 结束JBoss - >

< dependency>
< groupId> ro.mysite< / groupId>
< artifactId> petrinetexec< / artifactId>
< version> 0.1.3.81< / version>
< / dependency>

<依赖关系>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-resources-plugin< / artifactId>
< version> 2.4.3< / version>
< / dependency>

<依赖关系>
< groupId> javax< / groupId>
< artifactId> javaee-api< / artifactId>
< version> 6.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> log4j< / groupId>
< artifactId> log4j< / artifactId>
< version> 1.2.16< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-log4j12< / artifactId>
< version> 1.6.6< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 3.8.1< / version>
< scope> test< / scope>
< / dependency>
<依赖关系>
< groupId> com.whatever.myAuxiliaryStuff< / groupId>
< artifactId> myAuxiliaryStuff< / artifactId>
< version> 0.1.0.1305< / version>
< / dependency>
<依赖关系>
< groupId> com.sun.faces< / groupId>
< artifactId> jsf-api< / artifactId>
< version> 2.2.0-m09< / version>
< / dependency>
<依赖关系>
< groupId> com.sun.faces< / groupId>
< artifactId> jsf-impl< / artifactId>
< version> 2.2.0-m09< / version>
< / dependency>
< / dependencies>

< build>
< finalName> eebuildingsim< / finalName>
< / build>


工件 myAuxiliaryStuff 应该部署在jboss部署服务器下的 WEB-INF / lib 下。



使用:




  • Eclipse:Juno Service Release 1

  • Jboss:7.1.1 。最终

  • m2e 1.3.1.20130219-1424

  • eclipse网页工具平台3.4.2.v2013



稍后编辑:jboss日志文件中报告的错误如下所示:

  12 :31:38,507 INFO [org.jboss.weld.deployer](MSC服务线1-5)
JBAS016002:处理焊接部署mywar.war 12:31:38,522 ERROR
[org.jboss.msc .service.fail](MSC服务线程1-5)MSC00001:失败
启动服务jboss.deployment.unitmywar.war.POST_MODULE:
org.jboss.msc.service.StartException在服务
jboss.deployment.unit。mywar.war.POST_MODULE:无法处理阶段

org.jboss.as.server.deployment部署mywar.war的POST_MODULE .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] a t
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]在java.lang.Thread.run(Thread.java:722)
[rt.jar:1.7.0_05]导致:java .lang.NoSuchFieldError:FLOW at
com.sun.faces.flow.FlowDiscoveryCDIExtension。< clinit>(FlowDiscoveryCDIExtension.java:90)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
方法)[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.newInstanc e(Constructor.java:525)
[rt.jar:1.7.0_05] at
org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadExtension(WeldPortableExtensionProcessor.java:117)

org.jboss.as.weld.deployment.processors.WeldPortableExtensionProcessor.loadAttachments(WeldPortableExtensionProcessor.java:100)
at
org.jboss.as.weld.deployment.processors。 WeldPortableExtensionProcessor.deploy(WeldPortableExtensionProcessor.java:86)

org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113)
[jboss-as-server- 7.1.1.Final.jar:7.1.1.Final] ... 5更多

12:31:38,522 INFO [org.jboss.as.server](DeploymentScanner-threads -
2)JBAS015870:部署部署mywar.war已回滚
失败消息{JBAS014671:Failed services=>
{jboss.deployment.unit.\mywar.war\.POST_MODULE=>
org.jboss.msc.service.StartException in service
jboss.deployment.unit.\mywar.war\.POST_MODULE:无法处理
阶段POST_MODULE的部署\\ \\mywar.war\}} 12:31:38,647 INFO
[org.jboss.as.server.deployment](MSC服务线程1-1)JBAS015877:
停止部署mywar。战争在115ms 12:31:38,647 INFO
[org.jboss.as.controller](DeploymentScanner-threads - 2)JBAS014774:
服务状态报告JBAS014775:新的缺少/不满足
依赖关系:
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:
无法启动的服务:service
jboss.deployment.unitmywar.war.POST_MODULE:
org.jboss.msc.service.StartException in service
jboss.deployment.unit。mywar.war.POST_MODULE:无法执行ss阶段
部署的子程序$ my $ $ $

12:31:38,647 ERROR [org.jboss.as.server.deployment.scanner]
(DeploymentScanner-threads - 1){JBAS014653:复合操作
失败并被回滚。失败的步骤:=> {操作步骤2
=> {JBAS014671:失败的服务=> {jboss.deployment.unit.\mywar.war\。 POST_MODULE=>
org.jboss.msc.service.StartException in service
jboss.deployment.unit.\mywar.war\.POST_MODULE:无法处理
阶段POST_MODULE部署\mywar.war\}}}}


解决方案

Eclipse和插件有点奇怪,这是我做的,让它工作。

 项目 - >属性 - >部署程序集
添加...
Java构建路径条目(下一个>)
Maven依赖关系(完成)

部署属性面板现在应包含一个条目:源:Maven Dependecies - >部署路径:WEB_INF / lib


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.

Is there any approach to convince Eclipse (or Maven) to copy the jars into the lib folder at deployment?

EDIT: the pom.xml looks like:

<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.

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

Later edit: the error reported in jboss' log file looks like:

 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\""}}}}
解决方案

Eclipse and the plugins are a bit finicky. This is what I've done to get it to work.

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

这篇关于从Eclipse将Web应用程序部署到JBoss,并具有依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 16:57