users@glassfish.java.net

Re: JPA: Translating Annotations to Metadata (orm.xml)

From: Mitesh Meswani <Mitesh.Meswani_at_Sun.COM>
Date: Wed, 09 Jul 2008 18:20:23 -0700

Can you post the nested exception
It it possible that you are running into
https://bugs.eclipse.org/bugs/show_bug.cgi?id=236726?

glassfish_at_javadesktop.org wrote:
> Hi everyone,
>
> I'm trying to translate the commented annotations in the next two classes to metadata:
>
> [code]
> package pfc.model;
> import java.io.Serializable;
> import java.util.Date;
> //import javax.persistence.*;
>
> //_at_Entity
> public class DadesComentari implements Serializable {
>
> //_at_Id
> //_at_Column(name = "id", nullable = false)
> private Integer id;
> //_at_Column(name = "accio")
> private Integer accio;
> //_at_Column(name = "idAutor", nullable = false)
> private String idAutor;
> //_at_Column(name = "perfilAutor", nullable = false)
> private Integer perfilAutor;
> //_at_Column(name = "dataCreacio", nullable = false)
> //_at_Temporal(TemporalType.TIMESTAMP)
> private Date dataCreacio;
> //_at_Column(name = "text", nullable = false)
> private String text;
> //_at_Column(name = "idIncidencia", nullable = false)
> private Integer idIncidencia;
>
> ...(Setters and getters)...
> }
>
>
> package pfc.model;
> import java.io.Serializable;
> import java.util.ArrayList;
> import java.util.Date;
> //import javax.persistence.*;
>
> //_at_Entity
> public class DadesIncidencia implements Serializable {
>
> //_at_Id
> //_at_Column(name = "id", nullable = false)
> private Integer id;
> //_at_Column(name = "servAfectats", nullable = false)
> private Integer servAfectats;
> //_at_Column(name = "idCreador", nullable = false)
> private String idCreador;
> //_at_Column(name = "idTecnic")
> private String idTecnic;
> //_at_Column(name = "idTD")
> private String idTD;
> //_at_Column(name = "visitaSolicitada", nullable = false)
> private Boolean visitaSolicitada;
> //_at_Column(name = "dataCreacio", nullable = false)
> //_at_Temporal(TemporalType.TIMESTAMP)
> private Date dataCreacio;
> //_at_Column(name = "dataTancament")
> //_at_Temporal(TemporalType.TIMESTAMP)
> private Date dataTancament;
> //_at_Column(name = "nomClient")
> private String nomClient;
> //_at_Column(name = "cognomsClient")
> private String cognomsClient;
> //_at_Transient
> private ArrayList comentaris;
>
> ...(Setters and getters)...
> }
> [/code]
>
> To do it I have created the next file orm.xml:
>
> [code]
> <?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">
> <package>pfc</package>
> <entity class="pfc.model.DadesIncidencia" name="incidencia">
> <attributes>
> <id name="id">
> <column name="id" nullable="false"/>
> </id>
> <basic name="servAfectats">
> <column name="servAfectats" nullable="false"/>
> </basic>
> <basic name="dataCreacio">
> <column name="dataCreacio" nullable="false"/>
> <temporal>TIMESTAMP</temporal>
> </basic>
> <basic name="dataTancament">
> <column name="dataTancament"/>
> <temporal>TIMESTAMP</temporal>
> </basic>
> <basic name="idCreador">
> <column name="idCreador" nullable="false"/>
> </basic>
> <basic name="idTecnic">
> <column name="idTecnic"/>
> </basic>
> <basic name="idTD">
> <column name="idTD"/>
> </basic>
> <basic name="visitaSolicitada">
> <column name="visitaSolicitada" nullable="false"/>
> </basic>
> <basic name="nomClient">
> <column name="nomClient"/>
> </basic>
> <basic name="cognomsClient">
> <column name="cognomsClient"/>
> </basic>
> <transient name="comentaris"/>
> </attributes>
> </entity>
> <entity class="pfc.model.DadesComentari" name="comentari">
> <attributes>
> <id name="id">
> <column name="id" nullable="false"/>
> </id>
> <basic name="idIncidencia">
> <column name="idIncidencia" nullable="false"/>
> </basic>
> <basic name="perfilAutor">
> <column name="perfilAutor" nullable="false"/>
> </basic>
> <basic name="idAutor">
> <column name="idAutor" nullable="false"/>
> </basic>
> <basic name="dataCreacio">
> <column name="dataCreacio" nullable="false"/>
> <temporal>TIMESTAMP</temporal>
> </basic>
> <basic name="accio">
> <column name="accio" />
> </basic>
> <basic name="text">
> <column name="text" nullable="false"/>
> </basic>
> </attributes>
> </entity>
> </entity-mappings>
> [/code]
>
> Which I reference from the persistence.xml:
>
> [code]
> <?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="pfc" transaction-type="RESOURCE_LOCAL">
> <provider>oracle.toplink.essentials.PersistenceProvider</provider>
> <mapping-file>pfc/model/orm.xml</mapping-file>
> <!--<class>pfc.model.DadesIncidencia</class>
> <class>pfc.model.DadesComentari</class> -->
> <properties>
> <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
> <property name="toplink.jdbc.url" value="jdbc:mysql://localhost/pfc"/>
> <property name="toplink.jdbc.password" value=""/>
> <property name="toplink.jdbc.user" value="root"/>
> </properties>
> </persistence-unit>
> </persistence>
> [/code]
>
> Having done only these modifications, the next exception appears when trying to execute the application:
>
> [code]
> Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
> Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: WebappClassLoader
> delegate: false
> repositories:
> /WEB-INF/classes/
> ----------> Parent Classloader:
> org.apache.catalina.loader.StandardClassLoader_at_f4f44a
>
> Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
> Exception Description: predeploy for PersistenceUnit [pfc] failed.
> Internal Exception: java.lang.NullPointerException
> at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143)
> at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)
> at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
> at pfc.model.DAOFactory.connectarBD(DAOFactory.java:15)
> at pfc.model.FaƧanaDelModel.obtenirDadesIncidencia(FaƧanaDelModel.java:33)
> at pfc.IncidenciaController.handleRequest(IncidenciaController.java:18)
> [/code]
>
> Anybody knows how I can solve it? Or where I can search?
>
> Thank you in advance
> [Message sent by forum member 'asdfawer' (asdfawer)]
>
> http://forums.java.net/jive/thread.jspa?messageID=285383
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>