- loaded by WebappClassLoader
- package com.test.data;
- import java.util.Date;
- import javax.persistence.Entity;
- import javax.persistence.Id;
- import javax.persistence.IdClass;
- import javax.persistence.Table;
- @Entity
- @Table(name = "car")
- @IdClass(VoiturePK.class)
- public class Voiture {
- private int matriculeVoiture;
- private Date datecapture;
- private float positionx;
- private float positiony;
- private float vitesse;
- public Voiture(int matricule, Date datecapture, float positionx,
- float positiony, float vitesse) {
- this.matriculeVoiture = matricule;
- this.datecapture = datecapture;
- this.positionx = positionx;
- this.positiony = positiony;
- this.vitesse = vitesse;
- }
- public Voiture() {
- this.matriculeVoiture = 0;
- this.datecapture = null;
- this.positionx = 0;
- this.positiony = 0;
- this.vitesse = 0;
- }
- @Id
- public int getMatriculeVoiture() {
- return matriculeVoiture;
- }
- public void setMatriculeVoiture(int matriculeVoiture) {
- this.matriculeVoiture = matriculeVoiture;
- }
- @Id
- public Date getDatecapture() {
- return datecapture;
- }
- public void setDatecapture(Date datecapture) {
- this.datecapture = datecapture;
- }
- public float getPositionx() {
- return positionx;
- }
- public void setPositionx(float positionx) {
- this.positionx = positionx;
- }
- public float getPositiony() {
- return positiony;
- }
- public void setPositiony(float positiony) {
- this.positiony = positiony;
- }
- public float getVitesse() {
- return vitesse;
- }
- public void setVitesse(float vitesse) {
- this.vitesse = vitesse;
- }
- }
- package com.test.data;
- import java.util.Date;
- public class VoiturePK implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
- private int matriculeVoiture;
- private Date datecapture;
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((datecapture == null) ? 0 : datecapture.hashCode());
- result = prime * result + matriculeVoiture;
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- VoiturePK other = (VoiturePK) obj;
- if (datecapture == null) {
- if (other.datecapture != null)
- return false;
- } else if (!datecapture.equals(other.datecapture))
- return false;
- if (matriculeVoiture != other.matriculeVoiture)
- return false;
- return true;
- }
- public int getMatriculeVoiture() {
- return matriculeVoiture;
- }
- public void setMatriculeVoiture(int matriculeVoiture) {
- this.matriculeVoiture = matriculeVoiture;
- }
- public Date getDatecapture() {
- return datecapture;
- }
- public VoiturePK(int matriculeVoiture, Date datecapture) {
- super();
- this.matriculeVoiture = matriculeVoiture;
- this.datecapture = datecapture;
- }
- public void setDatecapture(Date datecapture) {
- this.datecapture = datecapture;
- }
- public VoiturePK() {
- super();
- }
- }
- <?xml version="1.0" encoding="UTF-8" ?>
- <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" xmlns="http://java.sun.com/xml/ns/persistence">
- <persistence-unit name="todo" transaction-type="RESOURCE_LOCAL">
- <class>com.test.data.Voiture</class>
- <class>com.test.data.VoiturePK</class>
- <properties>
- <!-- <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" /> -->
- <!-- <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:todos" /> -->
- <!-- <property name="javax.persistence.jdbc.user" value="sa" /> -->
- <!-- <property name="javax.persistence.jdbc.password" value="" /> -->
- <!-- <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" /> -->
- <!-- <property name="openjpa.RuntimeUnenhancedClasses" value="supported" /> -->
- <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"
- />
- <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/db1"
- />
- <property name="javax.persistence.jdbc.user" value="root" />
- <property name="javax.persistence.jdbc.password" value="" />
- <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"
- />
- <property name="openjpa.RuntimeUnenhancedClasses" value="supported"
- />
- </properties>
- </persistence-unit>
- </persistence>
- GRAVE: "Servlet.service()" pour la servlet ServletPrincipal a généré une exception
- <openjpa-2.0.1-r422266:989424 fatal user error> org.apache.openjpa.persistence.ArgumentException: Type "class com.test.data.VoiturePK" loaded by WebappClassLoader
- context: /sujet_stage_structure
- delegate: false
- repositories:
- /WEB-INF/classes/
- ----------> Parent Classloader:
- org.apache.catalina.loader.StandardClassLoader@122e7820
- does not have persistence metadata.
- at org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:685)
- at org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:751)
- at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:649)
- at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:149)
- at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
- at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:117)
- at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
- at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
- at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
- at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
- at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
- at com.test.servlets.ServletPrincipal.doGet(ServletPrincipal.java:44)
- at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
- at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
- at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
- at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
- at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
- at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
- at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
- at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
- at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
- at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
- at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
- at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
- at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
- at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
- at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
- at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
- at java.lang.Thread.run(Thread.java:662)