|
|
|
|
|
|
|
|
|
|
Re: Persistence and Java SE - Example [message #434572 is a reply to message #434570] |
Thu, 30 August 2007 10:12 |
Mark Hoffmann Messages: 113 Registered: July 2009 Location: Jena |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------050901090004000001080402
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
I've succesfully created an SE Project:
1. create JPA project:
- Target runtime: none Configurations: Default Configurations -> NEXT
- NEXT
- Select you Connection
- I neither used Implementation from server-runtime nor an
implementation library (I added the jar later to the build-path)
- check "Annotated classes must be listed in persistence.xml"
- uncheck "Create orm.xml" -> FINISH
2. Now go to the project properties - Java Build Path - Libraries - add
external jars. Add toplink-essentials.jar and the
mysql-connector-java-5.x.x-bin.jar. Now press ok.
3. I attached you my persistence.xml. For SE project a took another provider
4. now i created the entities, a main class, db-structure
5. creating entites from a existing schema works also well for me.
I hope this will help you
Mark
--------------050901090004000001080402
Content-Type: text/xml;
name="persistence.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="persistence.xml"
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="JPA2" transaction-type="RESOURCE_LOCAL">
<provider>
oracle.toplink.essentials.PersistenceProvider
</provider>
<class>
test.entities.Contact</class>
<class>
test.entities.Meeting</class>
<properties>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://myserver:3306/test"/>
<property name="toplink.jdbc.user" value="myuser"/>
<property name="toplink.jdbc.password" value="mypassword"/>
<property name="toplink.logging.level" value="INFO"/>
<property name="toplink.target-database" value="MySQL4"/>
<!-- <property name="toplink.ddl-generation" value="create-tables"/>-->
</properties>
</persistence-unit>
</persistence>
--------------050901090004000001080402
Content-Type: text/plain;
name="Contact.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Contact.java"
package test.entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.ManyToMany;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
@Entity
@Table(schema="test", name = "contact")
public class Contact implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
private int id = 0;
private String name = new String();
@ManyToMany
@JoinTable(name="contact_meeting", joinColumns = @JoinColumn(name="contact_id"), inverseJoinColumns = @JoinColumn(name="meeting_id"))
private Collection<Meeting> meetings = new ArrayList<Meeting>(1);
/**
* @return Liefert das Attribut id
*/
public int getId() {
return id;
}
/**
* @return Liefert das Attribut name
*/
public String getName() {
return name;
}
/**
* @return Liefert das Attribut meetings
*/
public Collection<Meeting> getMeetings() {
return meetings;
}
}
--------------050901090004000001080402
Content-Type: text/plain;
name="Main.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Main.java"
package test.main;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import test.entities.Contact;
import test.entities.Meeting;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPA2");
/*
* EntityManager holen
*/
EntityManager em = emf.createEntityManager();
Contact c = em.find(Contact.class, 1);
System.out.println("Name: " + c.getName());
for (Meeting m : c.getMeetings()) {
System.out.println("Meeting: " + m.getDescription());
}
}
}
--------------050901090004000001080402
Content-Type: text/plain;
name="Meeting.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Meeting.java"
package test.entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.ManyToMany;
@Entity
@Table(schema="test", name = "meeting")
public class Meeting implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@Column(table="meeting", name = "id")
private int id = 0;
private String description = new String();
@ManyToMany(targetEntity=test.entities.Contact.class, mappedBy = "meetings")
private Collection<Contact> attendees = new ArrayList<Contact>(1);
/**
* @return Liefert das Attribut id
*/
public int getId() {
return id;
}
/**
* @return Liefert das Attribut description
*/
public String getDescription() {
return description;
}
/**
* @return Liefert das Attribut attendees
*/
public Collection<Contact> getAttendees() {
return attendees;
}
}
--------------050901090004000001080402
Content-Type: text/plain;
name="script.sql.ddl"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="script.sql.ddl"
Q1JFQVRFIFRBQkxFIGNvbnRhY3QgKA0KCWlkIElOVCBERUZBVUxUICcnIE5P VCBOVUxMLA0K
CW5hbWUgVkFSQ0hBUigyNTUpIERFRkFVTFQgJycgTk9UIE5VTEwsDQoJUFJJ TUFSWSBLRVkg
KGlkKQ0KKSBFTkdJTkU9TXlJU0FNOw0KDQpDUkVBVEUgVEFCTEUgY29udGFj dF9tZWV0aW5n
ICgNCgljb250YWN0X2lkIElOVCBERUZBVUxUICcnIE5PVCBOVUxMLA0KCW1l ZXRpbmdfaWQg
SU5UIERFRkFVTFQgJycgTk9UIE5VTEwNCikgRU5HSU5FPU15SVNBTTsNCg0K Q1JFQVRFIFRB
QkxFIG1lZXRpbmcgKA0KCWlkIElOVCBERUZBVUxUICcnIE5PVCBOVUxMLA0K CWRlc2NyaXB0
aW9uIFZBUkNIQVIoMjU1KSBERUZBVUxUICcnIE5PVCBOVUxMLA0KCVBSSU1B UlkgS0VZIChp
ZCkNCikgRU5HSU5FPU15SVNBTTs=
--------------050901090004000001080402--
|
|
|
Re: Persistence and Java SE - Example [message #434573 is a reply to message #434571] |
Thu, 30 August 2007 13:25 |
Steve Ray Messages: 31 Registered: July 2009 |
Member |
|
|
OK, no longer seeing syntax error when I try and run, however, still
getting runtime errors. Looks like a problem with persistence XML. Since
persistence.xml has to be created manually, is there any documentation on
how to do so?
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Un known
Source)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(U nknown
Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izerAgent.initializeFromAgent(JavaSECMPInitializerAgent.java :69)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izerAgent.premain(JavaSECMPInitializerAgent.java:62)
... 6 more
Caused by: Exception [TOPLINK-30004] (Oracle TopLink Essentials - 2.0
(Build b48-beta3 (05/23/2007))):
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingE xception
Exception Description: An exception was thrown while processing
persistence.xml from URL:
file:/C:/Documents%20and%20Settings/rt954c/My%20Documents/wo rkspace/JPA_2/build/classes/
Internal Exception:
(1. cvc-complex-type.2.4.a: Invalid content was found starting with
element 'provider'. One of
'{"http://java.sun.com/xml/ns/persistence":mapping-file,
"http://java.sun.com/xml/ns/persistence":jar-file,
"http://java.sun.com/xml/ns/persistence":class,
"http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes,
"http://java.sun.com/xml/ns/persistence":properties}' is expected.)
at
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingE xception.exceptionProcessingPersistenceXML(PersistenceUnitLo adingException.java:134)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.processPersistenceXML(PersistenceUnitProcessor.j ava:161)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.processPersistenceArchive(PersistenceUnitProcess or.java:99)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.getPersistenceUnits(PersistenceUnitProcessor.jav a:89)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izer.initPersistenceUnits(JavaSECMPInitializer.java:248)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izer.initialize(JavaSECMPInitializer.java:267)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izer.initializeFromAgent(JavaSECMPInitializer.java:284)
... 12 more
Caused by:
(1. cvc-complex-type.2.4.a: Invalid content was found starting with
element 'provider'. One of
'{"http://java.sun.com/xml/ns/persistence":mapping-file,
"http://java.sun.com/xml/ns/persistence":jar-file,
"http://java.sun.com/xml/ns/persistence":class,
"http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes,
"http://java.sun.com/xml/ns/persistence":properties}' is expected.)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.parser.XMLEx ceptionHandler.error(XMLExceptionHandler.java:52)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper. error(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.rep ortError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.rep ortError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r$XSIErrorReporter.reportError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r.reportSchemaError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r.handleStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r.startElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner Impl.scanStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner Impl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
Source)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.processPersistenceXML(PersistenceUnitProcessor.j ava:151)
... 17 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"
Here's TInterests.java
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="t_Interests")
public class TInterests implements Serializable {
@Id
@Column(name="interest_id")
private int interestId;
@Column(name="active_sub_team")
private Object activeSubTeam;
private String name;
private String description;
private static final long serialVersionUID = 1L;
public TInterests() {
super();
}
public int getInterestId() {
return this.interestId;
}
public void setInterestId(int interestId) {
this.interestId = interestId;
}
public Object getActiveSubTeam() {
return this.activeSubTeam;
}
public void setActiveSubTeam(Object activeSubTeam) {
this.activeSubTeam = activeSubTeam;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
}
And persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
- <persistence version="1.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_1_0.xsd">
- <persistence-unit name="JPA_2">
<mapping-file>META-INF/orm.xml</mapping-file>
<provider> oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvi der </provider>
<class>TInterestLinks</class>
<class>TInterests</class>
<class>TMembers</class>
- <properties>
<property name="toplink.jdbc.url"
value="jdbc:mysql://saturna.ca.boeing.com/javashare" />
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="toplink.jdbc.user" value="JavaFriends" />
<property name="toplink.jdbc.password" value="ShareTheFun" />
</properties>
</persistence-unit>
</persistence>
And orm.xml:
<?xml version="1.0" encoding="UTF-8" ?>
- <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0">
- <persistence-unit-metadata>
- <persistence-unit-defaults>
<schema>javashare</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Persistence and Java SE - Example [message #605502 is a reply to message #434570] |
Thu, 30 August 2007 10:12 |
Mark Hoffmann Messages: 113 Registered: July 2009 Location: Jena |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------050901090004000001080402
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
I've succesfully created an SE Project:
1. create JPA project:
- Target runtime: none Configurations: Default Configurations -> NEXT
- NEXT
- Select you Connection
- I neither used Implementation from server-runtime nor an
implementation library (I added the jar later to the build-path)
- check "Annotated classes must be listed in persistence.xml"
- uncheck "Create orm.xml" -> FINISH
2. Now go to the project properties - Java Build Path - Libraries - add
external jars. Add toplink-essentials.jar and the
mysql-connector-java-5.x.x-bin.jar. Now press ok.
3. I attached you my persistence.xml. For SE project a took another provider
4. now i created the entities, a main class, db-structure
5. creating entites from a existing schema works also well for me.
I hope this will help you
Mark
--------------050901090004000001080402
Content-Type: text/xml;
name="persistence.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="persistence.xml"
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="JPA2" transaction-type="RESOURCE_LOCAL">
<provider>
oracle.toplink.essentials.PersistenceProvider
</provider>
<class>
test.entities.Contact</class>
<class>
test.entities.Meeting</class>
<properties>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://myserver:3306/test"/>
<property name="toplink.jdbc.user" value="myuser"/>
<property name="toplink.jdbc.password" value="mypassword"/>
<property name="toplink.logging.level" value="INFO"/>
<property name="toplink.target-database" value="MySQL4"/>
<!-- <property name="toplink.ddl-generation" value="create-tables"/>-->
</properties>
</persistence-unit>
</persistence>
--------------050901090004000001080402
Content-Type: text/plain;
name="Contact.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Contact.java"
package test.entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.ManyToMany;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
@Entity
@Table(schema="test", name = "contact")
public class Contact implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
private int id = 0;
private String name = new String();
@ManyToMany
@JoinTable(name="contact_meeting", joinColumns = @JoinColumn(name="contact_id"), inverseJoinColumns = @JoinColumn(name="meeting_id"))
private Collection<Meeting> meetings = new ArrayList<Meeting>(1);
/**
* @return Liefert das Attribut id
*/
public int getId() {
return id;
}
/**
* @return Liefert das Attribut name
*/
public String getName() {
return name;
}
/**
* @return Liefert das Attribut meetings
*/
public Collection<Meeting> getMeetings() {
return meetings;
}
}
--------------050901090004000001080402
Content-Type: text/plain;
name="Main.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Main.java"
package test.main;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import test.entities.Contact;
import test.entities.Meeting;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPA2");
/*
* EntityManager holen
*/
EntityManager em = emf.createEntityManager();
Contact c = em.find(Contact.class, 1);
System.out.println("Name: " + c.getName());
for (Meeting m : c.getMeetings()) {
System.out.println("Meeting: " + m.getDescription());
}
}
}
--------------050901090004000001080402
Content-Type: text/plain;
name="Meeting.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Meeting.java"
package test.entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.ManyToMany;
@Entity
@Table(schema="test", name = "meeting")
public class Meeting implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@Column(table="meeting", name = "id")
private int id = 0;
private String description = new String();
@ManyToMany(targetEntity=test.entities.Contact.class, mappedBy = "meetings")
private Collection<Contact> attendees = new ArrayList<Contact>(1);
/**
* @return Liefert das Attribut id
*/
public int getId() {
return id;
}
/**
* @return Liefert das Attribut description
*/
public String getDescription() {
return description;
}
/**
* @return Liefert das Attribut attendees
*/
public Collection<Contact> getAttendees() {
return attendees;
}
}
--------------050901090004000001080402
Content-Type: text/plain;
name="script.sql.ddl"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="script.sql.ddl"
Q1JFQVRFIFRBQkxFIGNvbnRhY3QgKA0KCWlkIElOVCBERUZBVUxUICcnIE5P VCBOVUxMLA0K
CW5hbWUgVkFSQ0hBUigyNTUpIERFRkFVTFQgJycgTk9UIE5VTEwsDQoJUFJJ TUFSWSBLRVkg
KGlkKQ0KKSBFTkdJTkU9TXlJU0FNOw0KDQpDUkVBVEUgVEFCTEUgY29udGFj dF9tZWV0aW5n
ICgNCgljb250YWN0X2lkIElOVCBERUZBVUxUICcnIE5PVCBOVUxMLA0KCW1l ZXRpbmdfaWQg
SU5UIERFRkFVTFQgJycgTk9UIE5VTEwNCikgRU5HSU5FPU15SVNBTTsNCg0K Q1JFQVRFIFRB
QkxFIG1lZXRpbmcgKA0KCWlkIElOVCBERUZBVUxUICcnIE5PVCBOVUxMLA0K CWRlc2NyaXB0
aW9uIFZBUkNIQVIoMjU1KSBERUZBVUxUICcnIE5PVCBOVUxMLA0KCVBSSU1B UlkgS0VZIChp
ZCkNCikgRU5HSU5FPU15SVNBTTs=
--------------050901090004000001080402--
|
|
|
Re: Persistence and Java SE - Example [message #605504 is a reply to message #434571] |
Thu, 30 August 2007 13:25 |
Steve Ray Messages: 31 Registered: July 2009 |
Member |
|
|
OK, no longer seeing syntax error when I try and run, however, still
getting runtime errors. Looks like a problem with persistence XML. Since
persistence.xml has to be created manually, is there any documentation on
how to do so?
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Un known
Source)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(U nknown
Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izerAgent.initializeFromAgent(JavaSECMPInitializerAgent.java :69)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izerAgent.premain(JavaSECMPInitializerAgent.java:62)
... 6 more
Caused by: Exception [TOPLINK-30004] (Oracle TopLink Essentials - 2.0
(Build b48-beta3 (05/23/2007))):
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingE xception
Exception Description: An exception was thrown while processing
persistence.xml from URL:
file:/C:/Documents%20and%20Settings/rt954c/My%20Documents/wo rkspace/JPA_2/build/classes/
Internal Exception:
(1. cvc-complex-type.2.4.a: Invalid content was found starting with
element 'provider'. One of
'{"http://java.sun.com/xml/ns/persistence":mapping-file,
"http://java.sun.com/xml/ns/persistence":jar-file,
"http://java.sun.com/xml/ns/persistence":class,
"http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes,
"http://java.sun.com/xml/ns/persistence":properties}' is expected.)
at
oracle.toplink.essentials.exceptions.PersistenceUnitLoadingE xception.exceptionProcessingPersistenceXML(PersistenceUnitLo adingException.java:134)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.processPersistenceXML(PersistenceUnitProcessor.j ava:161)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.processPersistenceArchive(PersistenceUnitProcess or.java:99)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.getPersistenceUnits(PersistenceUnitProcessor.jav a:89)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izer.initPersistenceUnits(JavaSECMPInitializer.java:248)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izer.initialize(JavaSECMPInitializer.java:267)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitial izer.initializeFromAgent(JavaSECMPInitializer.java:284)
... 12 more
Caused by:
(1. cvc-complex-type.2.4.a: Invalid content was found starting with
element 'provider'. One of
'{"http://java.sun.com/xml/ns/persistence":mapping-file,
"http://java.sun.com/xml/ns/persistence":jar-file,
"http://java.sun.com/xml/ns/persistence":class,
"http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes,
"http://java.sun.com/xml/ns/persistence":properties}' is expected.)
at
oracle.toplink.essentials.internal.ejb.cmp3.xml.parser.XMLEx ceptionHandler.error(XMLExceptionHandler.java:52)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper. error(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.rep ortError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.rep ortError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r$XSIErrorReporter.reportError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r.reportSchemaError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r.handleStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidato r.startElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner Impl.scanStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScanner Impl.next(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
Source)
at
oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUn itProcessor.processPersistenceXML(PersistenceUnitProcessor.j ava:151)
... 17 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"
Here's TInterests.java
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="t_Interests")
public class TInterests implements Serializable {
@Id
@Column(name="interest_id")
private int interestId;
@Column(name="active_sub_team")
private Object activeSubTeam;
private String name;
private String description;
private static final long serialVersionUID = 1L;
public TInterests() {
super();
}
public int getInterestId() {
return this.interestId;
}
public void setInterestId(int interestId) {
this.interestId = interestId;
}
public Object getActiveSubTeam() {
return this.activeSubTeam;
}
public void setActiveSubTeam(Object activeSubTeam) {
this.activeSubTeam = activeSubTeam;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
}
And persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
- <persistence version="1.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_1_0.xsd">
- <persistence-unit name="JPA_2">
<mapping-file>META-INF/orm.xml</mapping-file>
<provider> oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvi der </provider>
<class>TInterestLinks</class>
<class>TInterests</class>
<class>TMembers</class>
- <properties>
<property name="toplink.jdbc.url"
value="jdbc:mysql://saturna.ca.boeing.com/javashare" />
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="toplink.jdbc.user" value="JavaFriends" />
<property name="toplink.jdbc.password" value="ShareTheFun" />
</properties>
</persistence-unit>
</persistence>
And orm.xml:
<?xml version="1.0" encoding="UTF-8" ?>
- <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0">
- <persistence-unit-metadata>
- <persistence-unit-defaults>
<schema>javashare</schema>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
|
|
|
|
|
|