Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!

Richard Collins

Greenhorn
+ Follow
since Aug 15, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Collins

Hi,

I got the answer. I had to put the toplink-essentials-agent.jar in the class path.
Hi,

I am getting Persistence Exception while trying to run the JPA client.

The cleint is not able to recognize the persistence.xml which is present in the META-INF directory.

Following is the exception.

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named EmployeeService
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at client.EmployeeClient.main(EmployeeClient.java:16)


If any of you have a clue about the above exception please let me know.
Hi Dave,

Adam Gilchirst is my Favourite criketer, so I wanted to have his name. I am really sorry, to not to have abide by your rules.
Hi,

I am getting the following exception while trying to run the sample given in Chapter 2 of the Pro EJB3 book.

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named EmployeeService
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at client.EmployeeClient.main(EmployeeClient.java:16)


I have the persistence.xml file inside the META-INF directory which is inside the jar file. I am getting this exception while trying to run the client. I have the jar in the classpath, but somehow it is not able to recognize the persistence.xml.

Any advice on this exception please.
Congratulations to the winners.

Thanks for the authors.
There is a default server in SJAS 9.0 called JavaDB, i believe all the data that i create goes into that DB, I am not sure about this though. While creating the EntityManager I was creating it using the @PerssitenceContext annotation, is it because of that the value are getting written in JavaDB.

I changed the code to get the EntityManager from EntityManagerFactory. The code goes like this,

EntityManagerFactory emf = Persistence.createEntityManagerFactory("AccountService");
manager = emf.createEntityManager();

This code is in a Session bean.

Following is my persistence.xml.

<?xml version="1.0" encoding="UTF-8"?>
<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_1_0.xsd" version="1.0">
<persistence-unit name="AccountService" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<class>sample.entity.account.Account</class>
<properties>
<property name="toplink.target-database" value="Oracle"/>
<property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="toplink.jdbc.url" value="jdbc racle:thin:@zeus1dev:1521:zeusdev"/>
<property name="toplink.ddl-generation" value="drop-and-create-tables"/>
<property name="toplink.jdbc.user" value="olga_twe48_lease"/>
<property name="toplink.jdbc.password" value="olga_twe48_lease"/>
</properties>
</persistence-unit>
</persistence>


I have this persistence.xml file inside META-INF folder. When I do this i get the following error message.

Caused by: Exception [TOPLINK-7189] (Oracle TopLink Essentials - 2006.4 (Build 060412)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Cannot create temp classloader from current loader: [EJBClassLoader :
urlSet = [URLEntry : file:/C:/Sun/AppServer/domains/domain1/applications/j2ee-modules/entity/, URLEntry : file:/C:/Sun/AppServer/domains/domain1/generated/ejb/j2ee-modules/entity/]
doneCalled = false
Parent -> EJBClassLoader :
urlSet = []
doneCalled = false
Parent -> java.net.URLClassLoader@113beb5



Any of you guys know what this error message means.
I just looked into the samples of the book, so I changed my code to begin and commit transactions. Everything is working fine now, I have no exceptions, in the console I am able to see the correct outputs in my console, but the point is that I don't know where all these data are been written to. I did change my DB connection Info to wrong values in both persistence.xml and in the in the Application Server, but still everything is going fine I did not get any errors. I am using Sun Java Application Server is there anything like default DB connection available in this server.
I do have only one persistence.xml, and i dont have any properties file too. I am wondering if it is taking any info from the application server, i am not sure though.
When I changed the credentials to wrong values given in the persistence.xml, it still goes and creates the data. I really confused from where it is getting the DB information. Please help me out.
The project that I am currently working on is using EJB 2.0 to the maximum extent possible, we have about 120 entity beans. This project is about 2 years old now, our customer found it very difficult to port the application in various platforms, though we have the application running now in Weblogic, JBoss and Websphere, it took them a lot of money to do the porting. It is because of this they decided to remove EJB's from the application and move to Hibernate which does not depend any application server. With EJB3 now is it possible to have the application "App Server Independant" atleast from the Entity Beans point of view.
Hey Mike,

As you have said I included the <property> tag in the persistence.xml, I got rid of that exception but I was not able to find any data in the tables. In the client code I do a create and then try to find the data that I created, it throws an EJBException as it was not able to find the data.

Moreover when I remove the finder and have the create code alone, it says that the record was created, I confirm this as manager.contains() returned true. But when I queried in the DB directly I was not able to find the data. So, I believe that the record is created in some other instance. The credentials that I have given in the persistence.xml to connect to the DB are correct, I have verified them again and again. I have also created a Datasource in the Application Server which is the same as the one given in the persistence.xml. I am not sure what I am missing here, where else would the data be created, were else would it find the credentials to connect to DB.
Following is the exception that i got:

Internal Exception: org.apache.derby.client.am.SqlException: Table 'ACCOUNT' does not exist.Error Code: -1
Call:SELECT ID, OWNERNAME, BALANCE FROM ACCOUNT
Hi Mike,

I have configured the persistence.xml as you have said, i was able to deploy the application successfully, but when I am running my client the continer was not able to find the table in the Database, eventhough i have created the Table in the right schema and provided the right credentials to connect to that schema in the persistence.xml. Does the container look for the DB credentials anywhere else.
Hi Mark,

Following is the persistence.xml file given in chapter 2 of the book.

<persistence>
<persistence-unit name="EmployeeService" transaction- type="RESOURCE_LOCAL">
<class>examples.model.Employee</class>
<properties>
<property name="toplink.jdbc.driver"
value="org.apache.derby.jdbc.ClientDriver"/>
<property name="toplink.jdbc.url"
value="jdbc erby://localhost:1527/EmpServDB;create=true"/>
<property name="toplink.jdbc.user" value="APP"/>
<property name="toplink.jdbc.password" value="APP"/>
</properties>
</persistence-unit>
</persistence>

I am using a Oracle 9i Database. Is the following persistence.xml correct

<persistence>
<persistence-unit name="EmployeeService" transaction- type="RESOURCE_LOCAL">
<class>examples.model.Employee</class>
<properties>
<property name="toplink.jdbc.driver"
value="oracle.jdbc.driver.OracleDriver"/>
<property name="toplink.jdbc.url"
value="jdbc racle:thin:@162.44.9.87:1521:ZEUSI18N"/>
<property name="toplink.jdbc.user" value="swat4drs"/>
<property name="toplink.jdbc.password" value="swat4drs"/>
</properties>
</persistence-unit>
</persistence>

Are the values given for the name attribute correct. Do I need to specify the Persistence provider name in the <provider></provider>.
Hi,

Can anyone please tell me what are the things that need to specified in the persistence.xml, if i am using Oracle 9i as my Database.

Thanks
Adam