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

No Persistence provider for EntityManager named cassandra-pu #639

Closed
sunrain99 opened this issue Sep 3, 2014 · 9 comments
Closed

No Persistence provider for EntityManager named cassandra-pu #639

sunrain99 opened this issue Sep 3, 2014 · 9 comments
Assignees
Milestone

Comments

@sunrain99
Copy link

Hello!
I am using Kundera 2.13 on an dynamic web application to access cassandra database and everything works fine. I created EntityManagerFactory and EntityManager to handle entity bean CRUD.

this.emf = Persistence.createEntityManagerFactory("cassandra-pu");
EntityManager cem=emf.createEntityManager();

However, after I combine separate web components into EAR package, EntityManagerFactory and EntityManager do not work. Each war package inside EAR has its own persistence.xml and EntityManagerFactory, EntityManager Injection. The error message is:

ERROR [com.impetus.kundera.configure.PersistenceUnitConfiguration](default task-5) Unconfigured persistence unit: cassandra-pu please validate with persistence.xml
ERROR [com.impetus.kundera.KunderaPersistence](default task-5) EntityManagerFactory not created, returning null.
ERROR [org.jboss.as.ejb3.invocation](default task-5) JBAS014134: EJB Invocation failed on component TagManagementBean for method public abstract java.util.List com.sial.enotebook.ejb.TagManagementBeanLocal.viewAll(): javax.ejb.EJBException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named cassandra-pu
.....

Please help and any ideas?

Thanks and best regards,

@chhavigangwal
Copy link
Collaborator

@sunrain99

Can you share a sample app to help me debug the issue and resolve the same ?

Chhavi

@sunrain99
Copy link
Author

@chhavigangwal
Thanks for the taking a look. How can I share with you my app?

@sunrain99
Copy link
Author

@chhavigangwal
I create a war project test_1, its persistence.xml is like this. I can deploy test_1.war to jboss server and run the app successfully.
<persistence-unit name="cassandra-pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>entity.Vendor</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- <property name="jboss.as.jpa.managed" value="false" />-->
<property name="kundera.name" value="cassandra" />
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9160" />
<property name="kundera.keyspace" value="project" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.client" value="thrift" />
<property name="kundera.client.lookup.class"
value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
</properties>
</persistence-unit>

I created another war project test_2, its persistence.xml is like this. I can deploy test_2.war to jboss server and run successfully.
<persistence-unit name="cassandra-pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>entity.Employee</class>
<class>entity.Project</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!--property name="jboss.as.jpa.managed" value="false" / -->
<property name="kundera.name" value="cassandra" />
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9160" />
<property name="kundera.keyspace" value="project" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.client" value="thrift" />
<property name="kundera.client.lookup.class"
value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
</properties>
</persistence-unit>

entitymanager is initialized through @CassandraDatabase
@Inject
@CassandraDatabase
EntityManager entityManager;

public KunderaEntityManagerCDI(){
System.out.println("will create the entitymanager factory");
this.emf = Persistence.createEntityManagerFactory("cassandra-pu");
}
@produces @RequestScoped @CassandraDatabase EntityManager getKunderaEntityManager(){

    System.out.println("emf is: " + emf);       
    EntityManager cem=emf.createEntityManager();
    cem.setProperty(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
    return cem;

}

Then I created EAR project test and include project test_1 and test_2. test.ear can be deployed to jboss server ok but when I open pages, it got the above errors.

@chhavigangwal
Copy link
Collaborator

@sunrain99

I am trying to replicate the same scenario at my end, if possible please share your app by creating a repo over github or email it on [email protected]

Chhavi

@sunrain99
Copy link
Author

@chhavigangwal
I have send you zipped package to [email protected]. Please check it.
Thanks!

@chhavigangwal
Copy link
Collaborator

@sunrain99

Your issue seems to be related to setting classpath in Maifest. Take a look at the relevant thread.

https://groups.google.com/forum/#!msg/kundera-discuss/3-iUJQOShvE/kJihv32IbjYJ

I will have a look into your project and update you on same.

Chhavi

@sunrain99
Copy link
Author

@chhavigangwal
Thanks for your suggestion. I tried but still does not work. Can you please advise again? Thank you and appreciate!
What I did is:

  1. in pom.xml, add
    <configuration>
    <archive>
    <manifest>
    <addClasspath>true</addClasspath>
    </manifest>
    </archive>
    </configuration>
    so in project1 and project2 war file, manifest list all class path jar files
  2. add kundera-core-2.13-SNAPSHOT.jar,kundera-cassandra-2.13-SNAPSHOT.jar,kundera-cassandra-ds-driver-2.13-SNAPSHOT.jar,kundera-cassandra-pelops-2.13-SNAPSHOT.jar,fallback-impl-2.13-SNAPSHOT.jar into project\EarContent\lib folder.

@chhavigangwal
Copy link
Collaborator

Mailed you the working version of ear deployment. Please verify and let me know.

Chhavi

@chhavigangwal chhavigangwal added this to the 2.14 milestone Oct 10, 2014
@chhavigangwal chhavigangwal self-assigned this Oct 10, 2014
@chhavigangwal
Copy link
Collaborator

The same deployment works with wildfly 8.1. Closing this one as the same will be resolved with #534 .

Chhavi

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

No branches or pull requests

2 participants