1

My application is running perfectly fine in JBoss AS 5.1.0. My goal is to migrate it to Wildfly 10.

Below is my persistence.xml

<?xml version="1.0" encoding="UTF-8"?>    
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
        <persistence-unit name="ApplicationPersistenceUnit">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/MySQL_DS</jta-data-source>
            <jar-file>application_db_interface.jar</jar-file>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                <property name="jboss.entity.manager.jndi.name" value="java:/ApplicationPersistenceUnit"/>
                <property name="jboss.entity.manager.factory.jndi.name" value="java:/ApplicationPersistenceUnitFactory"/>
            </properties>
        </persistence-unit>
    </persistence>

Below is my transaction manager class;

public class TransactionManager implements TransactionManagerI {

    @PersistenceContext(unitName="ApplicationPersistenceUnit")
    private EntityManager em;
...
}

I also try to use lookup but it still returns null;

public Session getSession() throws DAOException {
        ..
            em = (EntityManager) new InitialContext().lookup("java:/ApplicationPersistenceUnit");
        ..
    }

Below is the project schema;

->application.ear
->application.ear/application.war
->application.ear/db.jar
->application.ear/db.jar/META-INF/persistence.xml

I looked into other solutions and try one by one but couldn't figure out mine yet. I can provide more info if you need.

UPDATE: I check JNDI view from wildfly admin console. I don't see ApplicationPersistenceUnit there. It looks like server doesn't bind my persistence.xml file. I am now trying to figure out this problem.

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
likeachamp
  • 765
  • 4
  • 11
  • 21
  • Maybe your JNDI name is not correct. Try to check it, open admin console in WF and see what is the actual JNDI name. – Mikhail Kuchma Aug 09 '16 at 09:01
  • @MikhailKuchma i don't see any jndi bindings with name 'ApplicationPersistenceUnit'. Looks like server doesn't see my persistence xml file. Do you have any idea? – likeachamp Aug 09 '16 at 15:53
  • Server will not see any persistence.xml, it belongs only to application. I think you need to create data source in WF with name `MySQL_DS`, maybe it'd necessary to correct name in persistence.xml after this. – Mikhail Kuchma Aug 10 '16 at 07:20
  • @MikhailKuchma MySQL_DS is already created on standalone.xml and i can see on server log / admin console that it is bound. – likeachamp Aug 10 '16 at 16:16
  • Check if [Windup](http://windup.jboss.org) can give some hints on that. – Ondra Žižka Aug 14 '16 at 16:21
  • @OndraŽižka thank you for suggestion! But it didn't help me to fix the problem. – likeachamp Aug 15 '16 at 19:32

0 Answers0