Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Nullpointer Exception trying to execute eclipselink-2.0.0

> Hello,
> 
> This error is odd because it is complaining that it cannot load
> *javax/resource/ResourceException*, implying your classpath is
> incomplete.  This error occurs when trying to load the driver class to
> login, so chance are your driver jar is incomplete or has external
> dependencies that are not available causing this exception.  I am not
> familar with the org.firebirdsql.jdbc.FBDriver, so you might want to try
> a different driver/database combination and see if that works with the
> application.
> Best Regards,
> Chris
thanks for the help, the problem is the jar that I was using. Instead of 
jaybird-2.1.6jdk16.jar I need jaybird-full-2.1.6jdk16.jar.

Also I need to set the property 
<property name="eclipselink.target-database" 
value="org.eclipse.persistence.platform.database.FirebirdPlatform"/>

After that, my test run ok.
> 
> Arcangel wrote:
> > Hello.
> >
> > I'm having some troubles when I tried to use eclipselink-2.0.0 with
> > eclipse WTP.
> >
> > Eclipselink is sending to me this exception:
> >
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > javax/resource/ResourceException
> > 	at java.lang.Class.forName0(Native Method)
> > 	at java.lang.Class.forName(Class.java:247)
> > 	at
> > org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClass
> >ForName(PrivilegedAccessHelper.java:88) at
> > org.eclipse.persistence.sessions.DefaultConnector.loadDriverClass(Default
> >Connector.java:253) at
> > org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnecto
> >r.java:85) at
> > org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(Data
> >sourceLogin.java:162) at
> > org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDet
> >ectDatasource(DatabaseSessionImpl.java:584) at
> > org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(E
> >ntityManagerFactoryProvider.java:228) at
> > org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(Entity
> >ManagerSetupImpl.java:368) at
> > org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSe
> >ssion(EntityManagerFactoryImpl.java:151) at
> > org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntit
> >yManagerImpl(EntityManagerFactoryImpl.java:207) at
> > org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntit
> >yManager(EntityManagerFactoryImpl.java:195) at
> > Persona.guardar(Persona.java:63)
> > 	at Persona.main(Persona.java:89)
> > Caused by: java.lang.ClassNotFoundException:
> > javax.resource.ResourceException
> > 	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> > 	at java.security.AccessController.doPrivileged(Native Method)
> > 	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> > 	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> > 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> > 	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> > 	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> >
> > I create a simple JPA project and add these jars to the build path:
> > eclipselink-2.0.0.jar
> > javax.persistence-2.0.0.jar
> > jaybird-2.1.6jdk16.jar
> >
> > My persistence.xml is this:
> >
> > <?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="prueba_eclipselink"
> > transaction-type="RESOURCE_LOCAL">
> > 	<class>Persona</class>
> > 	<properties>
> > 			<property name="javax.persistence.jdbc.driver"
> > value="org.firebirdsql.jdbc.FBDriver" />
> > 			<property name="javax.persistence.jdbc.url"
> > 				value="jdbc:firebirdsql:localhost/3050:/var/dbs/prueba_firebird.fdb"
> > /> <property name="javax.persistence.jdbc.user" value="sysdba" />
> > <property name="javax.persistence.jdbc.password" value="masterkey" />
> > <property name="eclipselink.ddl-generation" value="create-tables" />
> > <property name="eclipselink.logging.level" value="ALL" />
> > 		</properties>
> > 	</persistence-unit>
> > </persistence>
> >
> > My test class is this:
> >
> > import java.io.Serializable;
> > import java.lang.String;
> > import javax.persistence.*;
> >
> > /**
> >  * Entity implementation class for Entity: Persona
> >  *
> >  */
> > @Entity
> > public class Persona implements Serializable {
> >
> > 	@Id
> > 	@GeneratedValue
> > 	private int id;
> > 	private String nombre;
> > 	private String direccion;
> > 	private static final long serialVersionUID = 1L;
> > 	@Transient
> > 	protected EntityManager em;
> > 	@Transient
> > 	protected static final String PERSISTENCE_UNIT_NAME =
> > "prueba_eclipselink"; @Transient
> > 	protected static EntityManagerFactory factory = Persistence
> > 	.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
> >
> >
> > 	public Persona() {
> > 		super();
> > 	}
> > 	public int getId() {
> > 		return this.id;
> > 	}
> >
> > 	public void setId(int id) {
> > 		this.id = id;
> > 	}
> > 	public String getNombre() {
> > 		return this.nombre;
> > 	}
> >
> > 	public void setNombre(String nombre) {
> > 		this.nombre = nombre;
> > 	}
> > 	public String getDireccion() {
> > 		return this.direccion;
> > 	}
> >
> > 	public void setDireccion(String direccion) {
> > 		this.direccion = direccion;
> > 	}
> >
> > 	public Persona(int id, String nombre, String direccion) {
> > 		super();
> > 		this.id = id;
> > 		this.nombre = nombre;
> > 		this.direccion = direccion;
> > 	}
> > 	public boolean guardar(){
> > 		boolean res = false;
> > 		try {
> > 			em = factory.createEntityManager();
> > 			em.getTransaction().begin();
> > 			if (id == 0) {
> > 				em.persist(this);
> > 			}
> > 			else {
> > 				em.merge(this);
> > 			}
> > 			em.getTransaction().commit();
> > 			res = true;
> > 		}
> > 		catch (Exception e) {
> > 			e.printStackTrace();
> > 			res = false;
> > 		}
> > 		finally{
> > 			if(em !=null){
> > 				em.close();
> > 			}
> > 		}
> > 		return res;
> > 	}
> >         public static void main(String[] args) {
> > 		Persona persona = new Persona();
> > 		persona.setNombre("jose");
> > 		persona.setDireccion("rio gambia");
> > 		assertTrue(persona.guardar());
> > 	}
> > }
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 


Back to the top