首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > 其他服务器 >

JBoss,有关问题急需解决

2012-12-15 
JBoss高手进,问题急需解决我写了很简单的SessionBean,部署的时候都是报错不知道为为什么,各位求解释,初学E

JBoss高手进,问题急需解决
我写了很简单的SessionBean,部署的时候都是报错不知道为为什么,各位求解释,初学EJB,什么都不懂,贴下代码:


@Stateless
@Remote
public class UserManagerBean implements UserManager {

    private EntityManager entityManager;
    
    @PersistenceContext
    public EntityManager getEntityManager() {
        return entityManager;
    }

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    public void add(Teacher tea) {
        entityManager.persist(tea);
    }

}

persistence.xml文件中配置:
<persistence-unit name="test" transaction-type="JTA">
  <jta-data-source>MySqlDS</jta-data-source>
  <properties>
  <property name="hibernate.hbm2ddl.auto" value="update" />
  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
  </properties>
</persistence-unit>
JDBC的驱动包也已经复制到JBoss安装目\server\lib下,MySqlDS的命名空间也没问题,配置文件中加了<use-java-context>false</use-java-context>
我试了下,如果把Bean的生成类型@Stateless去掉,则是可以部署的,一加上就报错,不知道为什么,下面贴下错误信息:
org.jboss.deployers.spi.DeploymentException: Error deploying EJB_01.jar: Exception while processing container metadata for EJB: UserManagerBean in unit: EJB_01.jar
at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)
at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:99)
at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)


at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.Exception: Exception while processing container metadata for EJB: UserManagerBean in unit: EJB_01.jar
at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:549)
at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189)
... 28 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.jboss.injection.InjectionUtil.injectionTarget(InjectionUtil.java:314)
at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:64)
at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:588)
at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:418)
at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:527)
... 29 more
01:48:04,661 WARN [HDScanner] Failed to process changes
[解决办法]
persistence.xml文件中:
<persistence-unit name="test" transaction-type="JTA">
  <jta-data-source>MySqlDS</jta-data-source>
......
改为:
persistence.xml文件中配置:
<persistence-unit name="test" transaction-type="JTA">
  <jta-data-source>java:MySqlDS</jta-data-source>


然后把会话bean中的@Remote去掉或者加上@Remote(xxx.class)
xxx.class为远程接口名称

[解决办法]

引用:
persistence.xml文件中:
<persistence-unit name="test" transaction-type="JTA">
  <jta-data-source>MySqlDS</jta-data-source>
......
改为:
persistence.xml文件中配置:
<persistence-unit name="test" transaction……

为什么要配置成java:MySqlDS,我已经在配置文件里加上了<use-java-context>false</use-java-context>,java:/应该是可以省略的吧?
还有为什么@Remote为什么要加上xxx.class,UserManagerBean已经实现了UserManager接口了啊?
[解决办法]
java:MySqlDS是JBoss给出的数据源的JNDI名称,这个名字在控制台可以查到。

@Remote(xxx.class)中的小括号及其内容可以不加,但接口定义时,一定要加,不然如果一个类实现多个接口,JBOSS怎么知道谁是远程接口,可以提供给外界使用?
[解决办法]
兄弟,问题解决了吗?我和你一样的问题
是不是JBoss5要改什么配置呀

[解决办法]
没有,我还没搞懂呢
我现在也纳闷JBoss5是不是有问题

热点排行