【问题标题】:EntityManager null when trying to migrate to JBoss 7.1.1尝试迁移到 JBoss 7.1.1 时 EntityManager null
【发布时间】:2012-07-31 10:35:53
【问题描述】:

我目前正在尝试将我的 Web 应用程序从 JBoss 5.1 迁移到 JBoss 7.1.1。我将实体管理器注入到我的 jsp 文件中,但实体管理器始终为空。

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <!-- SSIS2 Productive Database --> 
    <persistence-unit name="SSIS2" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:/SSIS2DSprod</jta-data-source>
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="false"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/> 
        </properties>
    </persistence-unit>
</persistence> 

JSP 文件中的实体管理器注入示例:

<%! @PersistenceContext(unitName = "SSIS2")
    public EntityManager em;

    @Resource
    UserTransaction utx;
%>

部署本身没有错误,那么这里的实体管理器有什么问题?它在 JBoss 5.1 上运行没有问题。

编辑: Standalone.xml 中的数据源:(已删除 IP 地址和 SSID)

<datasource jta="true" jndi-name="java:/SSIS2DSprod" pool-name="SSIS2DSprod" enabled="true" use-java-context="true" use-ccm="true">
                    <connection-url>jdbc:oracle:thin:@ip-address:1531:SSID</connection-url>
                    <driver>oracle</driver>
                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                    <pool>
                        <prefill>true</prefill>
                        <use-strict-min>false</use-strict-min>
                        <flush-strategy>FailingConnectionOnly</flush-strategy>
                    </pool>
                    <security>
                        <user-name>ssis2</user-name>
                        <password>ssis2</password>
                    </security>
                </datasource>

【问题讨论】:

  • 也许你没有在 JBoss 中设置数据源?
  • 设置好了。还设置了安全域。请查看我更新的问题。
  • 嗯...我不知道在 JBoss 5 或 7 中如何,但在 JBoss 6 中定义文件名的数据源必须以“-ds.xml”结尾。尝试更改文件名。
  • 不,它在 JBoss 7 中完全改变了,现在位于standalone.xml 或 domain.xml 中

标签: java migration jboss7.x entitymanager


【解决方案1】:

确保您的 persistence.xml 位于 META-INF 文件夹下。

【讨论】:

    【解决方案2】:

    我发现不再允许向 JSP 注入资源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      • 2015-10-17
      • 1970-01-01
      相关资源
      最近更新 更多