我按照本教程使用NetBeans中的数据库中的RESTful Web服务创建了一个Maven项目:
http://jaxenter.com/from-database-to-restful-web-service-to-html5-in-10-minutes-105524.html和http://jaxenter.com/from-database-to-restful-web-service-to-html5-in-five-minutes-107078.html
当我尝试在Glassfish 4.1中将其作为打包的war文件运行时,我的RESTful Web服务正常运行。
但是,我想使用JBoss EAP 6.1代替Glassfish,但它遇到了很多问题。以下是我运行standalone.sh
时来自JBoss的消息:
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>
答案 0 :(得分:0)
确保您已检查以下几点:
[org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/mhcDS]