2014-02-16 110 views
1

我知道Google上有很多類似的問題,但我嘗試了很多,並且沒有任何幫助。我嘗試從Java EE 7教程運行this project,並在部署期間得到異常。然後,我用Stateful Bean做了一個簡單的小項目,並得到了同樣的一個。使用有狀態EJB部署項目期間的Glassfish異常

首先,它是戰爭項目。我的所有文件:

/pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<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>radzikowski</groupId> 
    <artifactId>ejb</artifactId> 
    <version>0.1</version> 
    <packaging>war</packaging> 

    <name>ejb</name> 

    <properties> 
     <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

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

/src/main/webapp/WEB-INF/web.xml(簡單,默認的web.xml)

<?xml version="1.0" encoding="UTF-8"?> 

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
    version="3.1"> 
    <session-config> 
     <session-timeout> 
      30 
     </session-timeout> 
    </session-config> 
</web-app> 

/src目錄/main/java/radzikowski/ejb/FulBean.java

package radzikowski.ejb; 

import javax.ejb.Stateful; 

@Stateful 
public class FulBean { 

} 

很簡單吧?我正在使用Glassfish 4.0(內部版本89)(從存儲庫 - Linux安裝)以及所有默認配置和一切。我檢查了由PKG和我已經安裝了GlassFish中的EJB封裝:

glassfish-ejb         4.0-89   installed ---- 
glassfish-ejb-l10n       4.0-89   known  ---- 
glassfish-ejb-lite       4.0-89   installed ---- 
glassfish-ejb-lite-l10n      4.0-89   known  ---- 

最後我在嘗試登錄部署:

SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer load method 
java.lang.RuntimeException: EJB Container initialization error 
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:234) 
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:291) 
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:99) 
    at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:206) 
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:313) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) 
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:356) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674) 
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534) 
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224) 
    at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544) 
    at java.lang.Thread.run(Thread.java:744) 
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4 
    at com.sun.enterprise.util.Utility.longToBytes(Utility.java:214) 
    at com.sun.ejb.containers.StatefulContainerFactory.createContainer(StatefulContainerFactory.java:479) 
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:221) 
    ... 38 more 

SEVERE: Exception during lifecycle processing 
java.lang.RuntimeException: EJB Container initialization error 
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:234) 
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:291) 
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:99) 
    at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:206) 
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:313) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) 
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:356) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674) 
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534) 
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224) 
    at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544) 
    at java.lang.Thread.run(Thread.java:744) 
Caused by: java.lang.ArrayIndexOutOfBoundsException: 4 
    at com.sun.enterprise.util.Utility.longToBytes(Utility.java:214) 
    at com.sun.ejb.containers.StatefulContainerFactory.createContainer(StatefulContainerFactory.java:479) 
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:221) 
    ... 38 more 

SEVERE: Exception while loading the app 
SEVERE: Exception while loading the app : EJB Container initialization error 
java.lang.ArrayIndexOutOfBoundsException: 4 
    at com.sun.enterprise.util.Utility.longToBytes(Utility.java:214) 
    at com.sun.ejb.containers.StatefulContainerFactory.createContainer(StatefulContainerFactory.java:479) 
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:221) 
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:291) 
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:99) 
    at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:206) 
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:313) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) 
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:356) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674) 
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534) 
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224) 
    at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544) 
    at java.lang.Thread.run(Thread.java:744) 

當使用無狀態或者單例bean一切正常良好。關於這個異常的很多問題都涉及舊的Glassfish版本(v2或v3),並且bug從很長一段時間都被修復了......我想我的配置有問題,但是我有一切默認設置,安裝後沒有改變。

+0

是您的有狀態EJB'Serializable'嗎? –

+0

添加'實現Serializable'後沒有任何改變。 – Radzikowski

回答

4

好吧,我幾個小時後就修好了。在我的服務器日誌有啓動域執行過程中引發的異常:

java.net.UnknownHostException: suse.site 

suse.site是我的電腦主機名和域名(我用的openSUSE 13.1)。我沒想到,它已經enythink與我的問題與狀態EJB(因爲服務器啓動,並工作良好)做的,但是當我添加的行

127.0.0.1 suse.site 

/etc/hosts文件並重新啓動服務器 - 魔法,也不例外在啓動域和成功的項目部署期間。棘手的問題。

+0

我也有同樣的問題。你節省了很多我的時間!感謝名單! – Mirko

0

我有複製粘貼你的代碼,至少是爲我工作,我的設置:Ubuntu 64位,openjdk V7和GF 4(build.89)。因此,仔細查看您的代碼,存在拼寫錯誤。你有沒有注意到這個包不符合@Stateful所在的位置(/src/main/java/radzikowski/ejb/FulBean.java vs package radzik.ejb;)?...你試圖解決這個問題,如果之後仍然不能正常工作,我已經打包my project,這個工作正常,試試吧。

提示:刪除GF上部署的任何以前的應用,重啓,清理& build &運行。

+0

這是一個錯字,但在我的文章,而不是應用程序(修復它)。下載你的項目,沒有任何改變。即使從官方網站下載的Glassfish,unziped它,啓動,仍然是例外。 我的設置:openSUSE 13.1 64bit,OpenJDK 7(軟件包:java-1_7_0-openjdk),GlassFish 4(build 89)。 – Radzikowski