无法启动jboss.deployment.unit。“war”.POST_MODULE

问题描述 投票:0回答:1

我按照本教程,使用 NetBeans 中数据库的 RESTful Web 服务创建了一个 Maven 项目:

http://jaxenter.com/from-database-to-restful-web-service-to-html5-in-10-minutes-105524.htmlhttp://jaxenter.com/from-database- to-restful-web-service-to-html5-in-五分钟-107078.html

当我尝试在 Glassfish 4.1 中将其作为打包的 war 文件运行时,我的 RESTful Web 服务工作正常。

但是,我想使用 JBoss EAP 6.1 而不是 Glassfish,但它遇到了很多问题。这是我运行时 JBoss 发出的消息

standalone.sh
:

18:16:33,320 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC0000
01: Failed to start service jboss.deployment.unit."mhc-maven-jboss-1.0-SNAPSHOT.
war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployme
nt.unit."mhc-maven-jboss-1.0-SNAPSHOT.war".POST_MODULE: JBAS018733: Failed to pr
ocess phase POST_MODULE of deployment "mhc-maven-jboss-1.0-SNAPSHOT.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(Deplo
ymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.
Final-redhat-8]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(Se
rviceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-
1]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceCont
rollerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145) [rt.jar:1.7.0_51]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615) [rt.jar:1.7.0_51]
        at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.lang.NullPointerException
        at org.jboss.as.jpa.processor.PersistenceRefProcessor.getPersistenceUnit
BindingSource(PersistenceRefProcessor.java:203)
        at org.jboss.as.jpa.processor.PersistenceRefProcessor.getPersistenceUnit
Refs(PersistenceRefProcessor.java:124)
        at org.jboss.as.jpa.processor.PersistenceRefProcessor.processDescriptorE
ntries(PersistenceRefProcessor.java:75)
        at org.jboss.as.ee.component.deployers.AbstractDeploymentDescriptorBindi
ngsProcessor.deploy(AbstractDeploymentDescriptorBindingsProcessor.java:95)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(Deplo
ymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.
Final-redhat-8]
        ... 5 more

18:16:33,370 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS0
18559: Deployed "mhc-maven-jboss-1.0-SNAPSHOT.war" (runtime-name : "mhc-maven-jb
oss-1.0-SNAPSHOT.war")
18:16:33,372 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774
: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit
."mhc-maven-jboss-1.0-SNAPSHOT.war".POST_MODULE: org.jboss.msc.service.StartExce
ption in service jboss.deployment.unit."mhc-maven-jboss-1.0-SNAPSHOT.war".POST_M
ODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "mhc-maven-
jboss-1.0-SNAPSHOT.war"

我的 pom.xml(其中某些部分由 NetBeans 自动生成)是:

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.mhc</groupId>
  <artifactId>mhc-maven-jboss</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>mhc-maven-jboss</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
  </dependencies> 

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>  
          <groupId>org.jboss.as.plugins</groupId>  
              <artifactId>jboss-as-maven-plugin</artifactId>  
              <version>7.5.Final</version>  
        </plugin>  
    </plugins>
  </build>
    <repositories>
        <repository>
            <id>unknown-jars-temp-repo</id>
            <name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
            <url>file:${project.basedir}/lib</url>
        </repository>
    </repositories>
</project>

我的 persistence.xml 是(与我使用 Glassfish 服务器创建的几乎相同):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" 
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
                                 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="mhcDS" transaction-type="JTA">
        <jta-data-source>java:jboss/datasources/mhcDS</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties/>
    </persistence-unit>
</persistence>
maven-3 netbeans-8 jboss-eap-6
1个回答
0
投票

确保检查以下几点:

  • 在 JBOSS_HOME/standalone/configuration/standalone.xml 中或通过管理页面创建 JNDI 数据源条目(示例已在其中给出)
  • 观察启动时的服务器日志 (/standalone/logs/server.log)。您应该看到以下行:
    [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/mhcDS]
  • 即使 JPA 规范没有要求,也要在 persistence.xml 中添加所需的 Provider(JBoss EAP 6 的默认设置是 Hibernate,因此请添加以下行作为 persistence-unit 元素下的第一个子元素:
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    (更多信息可以在这里找到:https://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/ch01s02s01.html)
© www.soinside.com 2019 - 2024. All rights reserved.