Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors Loading DSClientFactory in persistence.xml #723

Closed
pluttrell opened this issue Mar 15, 2015 · 8 comments
Closed

Errors Loading DSClientFactory in persistence.xml #723

pluttrell opened this issue Mar 15, 2015 · 8 comments

Comments

@pluttrell
Copy link

I'm trying to get Kundera deployed in Wildfly 8.2 and am receiving the following exception which are causing my deployment to fail and have me blocked:

2015-03-15 23:18:38,322 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 51) MSC000001: Failed to start service jboss.persistenceunit."MyTest.ear#MyTestPersistenceUnit": org.jboss.msc.service.StartException in service jboss.persistenceunit."MyTest.ear#MyTestPersistenceUnit": com.impetus.kundera.classreading.ResourceReadingException: java.io.FileNotFoundException: /content/MyTest.ear/lib/MyCore.jar (No such file or directory)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_25]
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: com.impetus.kundera.classreading.ResourceReadingException: java.io.FileNotFoundException: /content/MyTest.ear/lib/MyCore.jar (No such file or directory)
    at com.impetus.kundera.classreading.Reader.getResourceIterator(Reader.java:180) [kundera-core-2.15.1.jar:]
    at com.impetus.kundera.configure.MetamodelConfiguration.loadEntityMetadata(MetamodelConfiguration.java:226) [kundera-core-2.15.1.jar:]
    at com.impetus.kundera.configure.MetamodelConfiguration.configure(MetamodelConfiguration.java:112) [kundera-core-2.15.1.jar:]
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(EntityManagerFactoryImpl.java:158) [kundera-core-2.15.1.jar:]
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:116) [kundera-core-2.15.1.jar:]
    at com.impetus.kundera.KunderaPersistence.createContainerEntityManagerFactory(KunderaPersistence.java:63) [kundera-core-2.15.1.jar:]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
    ... 8 more
Caused by: java.io.FileNotFoundException: /content/MyTest.ear/lib/MyCore.jar (No such file or directory)
    at java.io.FileInputStream.open(Native Method) [rt.jar:1.8.0_25]
    at java.io.FileInputStream.<init>(FileInputStream.java:138) [rt.jar:1.8.0_25]
    at java.io.FileInputStream.<init>(FileInputStream.java:93) [rt.jar:1.8.0_25]
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90) [rt.jar:1.8.0_25]
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188) [rt.jar:1.8.0_25]
    at java.net.URL.openStream(URL.java:1038) [rt.jar:1.8.0_25]
    at com.impetus.kundera.classreading.Reader.getResourceIterator(Reader.java:154) [kundera-core-2.15.1.jar:]
    ... 16 more

I have searched my entire file system and I do not have a directory /content/MyTest.ear.

MyTest.ear was deploying fine prior to adding the persistence.xml.

How do I reslove this, or go about further troubleshooting it?

For reference here is my persistence.xml:

<persistence 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" version="2.0">

    <persistence-unit name="MyTestPersistenceUnit">
        <provider>com.impetus.kundera.KunderaPersistence</provider>
        <properties>
            <property name="kundera.nodes" value="[removed]"/>
            <property name="kundera.port" value="9042"/>
            <property name="kundera.keyspace" value="[removed]"/>
            <property name="kundera.dialect" value="cassandra"/>
            <property name="kundera.ddl.auto.prepare" value="validate" />
            <property name="kundera.client.lookup.class" value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />
        </properties>
    </persistence-unit>

</persistence>

And here's my wip test code:

@PersistenceUnit
private EntityManagerFactory entityManagerFactory;

private EntityManager entityManager;

@Resource
private UserTransaction utx;

@Override
public MyTestEntity retrieveByUid(String uid) {

    if (entityManager == null){
        entityManager = entityManagerFactory.createEntityManager();
    }

    return entityManager.find(MyTestEntity.class, uid);

}

@Override
public void store(MyTestEntity myTestEntity) {

    if (entityManager == null){
        entityManager = entityManagerFactory.createEntityManager();
    }

    try {

      utx.begin();
      entityManager.persist(myTestEntity);
      utx.commit();

    } catch (Exception e) {
      try {
        utx.rollback();
      } catch (SystemException e1) {
        e1.printStackTrace();
      }
    }

}
@pluttrell
Copy link
Author

Does anyone have any ideas on what might be causing this...or how to resolve it? At the moment it's blocking our PoC using Kundera.

@devender-yadav
Copy link
Contributor

@pluttrell
Sorry for late response. The team was busy with a release and hence could not respond.
Can you please make sure all dependent jars are added in your class-path.
content in  /content/MyTest.ear  refers to the directory where your EAR is deployed.
Also, can you please share a sample project with us to help us quickly look into the issue?

HTH,
Devender

@karthikprasad13
Copy link
Collaborator

@pluttrell
Please set the following property in your persistence.xml
<property name="jboss.as.jpa.managed" value="false" />

Karthik.

@pluttrell
Copy link
Author

@karthikprasad13

Adding <property name="jboss.as.jpa.managed" value="false" /> did work initially, however then I received NPE's because the @PersistenceUnit annotation wasn't populating the entityManagerFactory member... this was due to the fact that the class is actually created by our internal services framework which uses Google Guice for DI...and of course isn't going to properly process the @PersistenceUnit annotation. As such I removed this annotation and am instead trying to load the PersistenceUnit manually as you would outside of Wildfly, which causes the same FileNotFoundException as above.

My entity class remains the same. Here's my new wip test code:

private EntityManager entityManager;

public MyTestEntity retrieveByUid(String uid) {
    return getEntityManager().find(MyTestEntity.class, uid);
}

public void store(MyTestEntity myTestEntity) {
    getEntityManager().persist(myTestEntity);
}

private EntityManager getEntityManager(){

    if (entityManager == null){
        EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("MyTestPersistenceUnit");
        entityManager = entityManagerFactory.createEntityManager();
    }

   return entityManager;
}

Here's the error again (using Kundera v2.16):

java.io.FileNotFoundException: /content/MyTest.ear/lib/MyCore.jar (No such file or directory)
    at com.impetus.kundera.classreading.Reader.getResourceIterator(Reader.java:180)
    at com.impetus.kundera.configure.MetamodelConfiguration.loadEntityMetadata(MetamodelConfiguration.java:226)
    at com.impetus.kundera.configure.MetamodelConfiguration.configure(MetamodelConfiguration.java:112)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(EntityManagerFactoryImpl.java:158)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:135)
    at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(KunderaPersistence.java:85)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
        at ....

@devender-yadav

Wildfly 8.2 does not appear to be storing the EAR file in such a location as there is no directory on my test machine /content/MyTest.ear.

@chhavigangwal
Copy link
Collaborator

@pluttrell

Please mail a sample test project at kundera@impetus.co.in to help us look into the issue further.

Chhavi

@karthikprasad13
Copy link
Collaborator

@pluttrell

Please try including your entity classes within <class> tag and setting <exclude-unlisted-classes> to true in persistence.xml

Example:

<persistence-unit name="cassandra-test">
       <provider>com.impetus.kundera.KunderaPersistence</provider>
           <class>com.impetus.cassandra.entity.Book</class>
           <exclude-unlisted-classes>true</exclude-unlisted-classes>
           <properties> ....

Karthik.

@chhavigangwal
Copy link
Collaborator

@pluttrell

Is the issue resolved for you?

Chhavi

@pluttrell
Copy link
Author

That depends... The last suggestion is an effective work around, which is why I closed this ticket.

But it's only a work around... Without looking at the code, I was quite surprised to see that Kundera was trying to read the file system in a place that doesn't exist..and further failing when it couldn't find what it was looking for. And after briefly looking at the code it appears to me that the classloading and metadata code might not work in all deployment environments, such as the one that we're deploying too...

There's another ticket 547 with a very similar issue, but the fix as proposed there (and above) did not resolve the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants