خرید بک لینک

Vote count: 0

I'm trying to instantiate an EntityManager using a JTA Datasource, but I always get NullPointerException. Here's my environment: Server : JBossAS 7.0 JPA : 2.0 DB : MySQL

persistence.xml

    <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
    <persistence-unit name="WebStock" transaction-type="JTA">
        <provider>org.hibeate.ejb.HibeatePersistence</provider>
        <jta-data-source>stockmanagementDS</jta-data-source>
        <class>prv.stockmanagement.business.Product</class>
    </persistence-unit>
</persistence>

On a dao class I'm trying this :

@PersistenceContext(type=PersistenceContextType.EXTENDED, unitName="WebStock")
private EntityManager em;

but when I use its getter, I get NullPointerException here :

public EntityManager getEntityManager() {
        retu em;
    }

the debug shows it's null.

Here's the datasource definition in the standalone.xml :

<datasource jndi-name="stockmanagementDS" pool-name="stockmanagement" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                    <coection-url>
                        jdbc:mysql://localhost:3306/kitchen_stock
                    </coection-url>
                    <driver>
                        mysql
                    </driver>
                    <security>
                        <user-name>
                            root
                        </user-name>
                        <password>
                            rootroot
                        </password>
                    </security>
                    <statement>
                        <prepared-statement-cache-size>
                            100
                        </prepared-statement-cache-size>
                        <share-prepared-statements/>
                    </statement>
                </datasource>

Any hint?

asked 2 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 3 اسفند 1394 ساعت: 2:52

صفحه بندی