简体   繁体   English

尝试迁移到JBoss 7.1.1时EntityManager为null

[英]EntityManager null when trying to migrate to JBoss 7.1.1

I am currently trying to migrate my web application from JBoss 5.1 to JBoss 7.1.1. 我目前正在尝试将Web应用程序从JBoss 5.1迁移到JBoss 7.1.1。 I inject the entity manager into my jsp file but the entity manager is always null. 我将实体管理器注入到我的jsp文件中,但是实体管理器始终为null。

persistence.xml: 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> 

Example of Entity Manager injection in a JSP file: 在JSP文件中的Entity Manager注入示例:

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

    @Resource
    UserTransaction utx;
%>

The deployment itself contains no errors, so what is the problem with the Entity Manager here? 部署本身不包含任何错误,那么这里的实体管理器有什么问题? It works without problems on JBoss 5.1. 它在JBoss 5.1上可以正常工作。

Edit: datasource in standalone.xml: (ip-address and SSID removed) 编辑: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>

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM