1

有没有人能够让 EJBContainer.createEJBContainer() 与 JBoss 7.1.1.Final 一起工作?

将以下代码作为 JUnit 测试运行会导致 NullPointerException!

public class EJBContainerTest {

private static EJBContainer ejbContainer;
private static Context context;

@BeforeClass
public static void beforeClass() {
    System.setProperty("jboss.home", "/home/usr1/jboss-as-7.1.1.Final");
    ejbContainer = EJBContainer.createEJBContainer();
    context = ejbContainer.getContext();
}

@Test
public void test() {
    Assert.assertNotNull(context);
}

}

堆栈跟踪:

java.lang.NullPointerException
    at org.jboss.modules.Module.forClassLoader(Module.java:365)
    at org.jboss.modules.Module.forClassLoader(Module.java:365)
    at org.jboss.modules.Module.forClassLoader(Module.java:365)
    at org.jboss.modules.Module.getContextModuleLoader(Module.java:421)
    at org.jboss.as.embedded.ejb3.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:86)
    at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:93)
    at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:75)
    at org.arquillian.example.EJBContainerTest.beforeClass(EJBContainerTest.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
4

3 回答 3

0

你必须设置这些文件:default.persistence.properties、ejb3-interceptors-aop.xml、embedded-jboss-beans.xml、jboss-jms-beans.xml、jndi.properties、login-config.xml、security-beans .xml 如果您使用 testNG,您还可以在 src/test/resources 目录中添加 testng.xml

在您的班级中,您必须添加:

System.setProperty("org.jboss.as.embedded.ejb3.BARREN", "true");  
System.setProperty("jboss.home", "/home/usr1/jboss-as-7.1.1.Final");  
System.setProperty("jboss.home.dir", "/home/usr1/jboss-as-7.1.1.Final");
于 2015-01-23T10:34:52.777 回答
0

在上面的代码中添加 System.setProperty("org.jboss.as.embedded.ejb3.BARREN", "true") 修复了 NPE 问题,嵌入式容器成功启动但无法部署类,并出现以下错误:

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit.classes.STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit.classes.STRUCTURE: Failed to process phase STRUCTURE of deployment "classes"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_26]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_26]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Failed to mount deployment content
    at org.jboss.as.server.deployment.module.DeploymentRootMountProcessor.deploy(DeploymentRootMountProcessor.java:91)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113)
    ... 5 more
Caused by: java.util.zip.ZipException: invalid CEN header (bad signature)
    at java.util.zip.ZipFile.open(Native Method) [rt.jar:1.6.0_26]
    at java.util.zip.ZipFile.<init>(ZipFile.java:127) [rt.jar:1.6.0_26]
    at java.util.jar.JarFile.<init>(JarFile.java:135) [rt.jar:1.6.0_26]
    at java.util.jar.JarFile.<init>(JarFile.java:99) [rt.jar:1.6.0_26]
    at org.jboss.vfs.spi.JavaZipFileSystem.<init>(JavaZipFileSystem.java:97)
    at org.jboss.vfs.spi.JavaZipFileSystem.<init>(JavaZipFileSystem.java:83)
    at org.jboss.vfs.VFS.mountZip(VFS.java:408)
    at org.jboss.vfs.VFS.mountZip(VFS.java:434)
    at org.jboss.as.server.deployment.DeploymentMountProvider$Factory$ServerDeploymentRepositoryImpl.mountDeploymentContent(DeploymentMountProvider.java:95)
    at org.jboss.as.server.deployment.module.DeploymentRootMountProcessor.deploy(DeploymentRootMountProcessor.java:87)
    ... 6 more

16:49:12,128 INFO  [org.jboss.as.server] (pool-9-thread-1) JBAS015870: Deploy of deployment "classes" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.classes.STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.classes.STRUCTURE: Failed to process phase STRUCTURE of deployment \"classes\""}}
16:49:12,129 INFO  [org.jboss.as.controller] (pool-9-thread-1) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit.classes.STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit.classes.STRUCTURE: Failed to process phase STRUCTURE of deployment "classes"
于 2012-04-25T00:07:26.077 回答
0

JBoss 类 org.jboss.vfs.VirtualJarFileInputStream 中有一个老错误。它不能写入 Zip 文件的有效本地文件头。因此,创建临时 zip 文件的类的部署无法在 JBoss 中工作。

于 2015-11-09T10:31:25.043 回答