Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink + Spring can't find Postgres Driver
EclipseLink + Spring can't find Postgres Driver [message #654359] Tue, 15 February 2011 11:52 Go to next message
Luiz E. is currently offline Luiz E.
Messages: 97
Registered: September 2010
Member
hi all
i have a query like this:
public List<Pais> findAllPais(){
		return find("select p from Pais p");
	}

but when she's executed, it throws a error like this:
[EL Severe]: 2011-02-15 10:32:32.421--ServerSession(2572110)--Thread(Thread[main,6,main])--Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:postgresql://192.168.0.10:5432/ti_fiscal
Error Code: 0
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:309)
	at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:138)
	at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
	at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
	at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:327)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:291)
	at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:415)
	at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:155)
	at org.eclipse.persistence.sessions.server.ExternalConnectionPool.startUp(ExternalConnectionPool.java:118)
	at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:495)
	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:627)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:230)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:389)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:164)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:221)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:209)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:423)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:485)
	at $Proxy8.createEntityManager(Unknown Source)
	at org.springframework.orm.jpa.EntityManagerFactoryAccessor.createEntityManager(EntityManagerFactoryAccessor.java:116)
	at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:176)
	at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:146)
	at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:306)
	at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:302)
	at br.com.germantech.repo.JPADao.findAllPais(JPADao.java:16)
	at br.com.germantech.repo.JPADao$$FastClassByCGLIB$$dcf8016c.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:617)
	at br.com.germantech.repo.JPADao$$EnhancerByCGLIB$$9ccc57c9.findAllPais(<generated>)
	at br.com.germantech.commands.AbrirEditorTeste.execute(AbrirEditorTeste.java:21)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:820)
	at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:806)
	at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:796)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at br.com.germantech.application.Application.start(Application.java:20)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


and yes, i DO HAVE postgres driver added as a dependecie from my bundle

here's all the stack trace:
http://pastie.org/1566055
as you can see here:
[EL Config]: 2011-02-15 10:32:32.421--ServerSession(2572110)--Connection(1349553)--Thread(Thread[main,6,main])--connecting(DatabaseLogin(
  platform=>PostgreSQLPlatform
  user name=> "postgres"
  connector=>JNDIConnector datasource name=>null
))
[EL Severe]: 2011-02-15 10:32:32.421--ServerSession(2572110)--Thread(Thread[main,6,main])--Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:postgresql://192.168.0.10:5432/ti_fiscal

eclipselink tries to instantiate a datasource, which i don't use, i never used at all

my config files:
appContext.xml
http://pastie.org/1566048

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_2_0.xsd" version="2.0">
	<persistence-unit name="Fiscal" transaction-type="RESOURCE_LOCAL">
	
		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
		
		<class>br.com.germantech.modelos.GrupoAcesso</class>
		<class>br.com.germantech.modelos.GrupoUsuario</class>
		<class>br.com.germantech.modelos.Usuario</class>
		<class>br.com.germantech.modelos.Estado</class>
		<class>br.com.germantech.modelos.GrupoTelefone</class>
		<class>br.com.germantech.modelos.Municipio</class>
		<class>br.com.germantech.modelos.Pais</class>
		<class>br.com.germantech.modelos.Telefone</class>
		<class>br.com.germantech.modelos.TipoLogradouro</class>
		<class>br.com.germantech.modelos.ClienteFornecedor</class>
		<class>br.com.germantech.modelos.Contabilista</class>
		<class>br.com.germantech.modelos.Departamento</class>
		<class>br.com.germantech.modelos.Empresa</class>
		<class>br.com.germantech.modelos.EmpresasEndereco</class>
		<class>br.com.germantech.modelos.EmpresasResponsavel</class>
		<class>br.com.germantech.modelos.EmpresasSocio</class>
		<class>br.com.germantech.modelos.Escritorio</class>
		<class>br.com.germantech.modelos.GrupoResponsavel</class>
		<class>br.com.germantech.modelos.InscricaoSubstituicao</class>
		<class>br.com.germantech.modelos.Nacionalidade</class>
		<class>br.com.germantech.modelos.NaturezaJuridica</class>
		<class>br.com.germantech.modelos.Responsavel</class>
		<class>br.com.germantech.modelos.Sindicato</class>
		<class>br.com.germantech.modelos.SituacaoEspecial</class>
		<class>br.com.germantech.modelos.TipoSocio</class>
		
		<exclude-unlisted-classes>false</exclude-unlisted-classes>
		
		<properties>
			<property name="eclipselink.target-database" value="PostgreSQL" />
			<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
			<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://192.168.0.10:5432/ti_fiscal" />
			<property name="javax.persistence.jdbc.user" value="postgres" />
			<property name="javax.persistence.jdbc.password" value="admin" />
		</properties>
	</persistence-unit>
</persistence>


if i hardcode the entityManager, eclipselink doesn't use connector:
[EL Config]: 2011-02-15 10:50:49.656--Connection(20348456)--connecting(DatabaseLogin(
	platform=>PostgreSQLPlatform
	user name=> "postgres"
	datasource URL=> "jdbc:postgresql://192.168.0.10:5432/ti_fiscal"
))
[EL Config]: 2011-02-15 10:50:49.687--Connection(4167406)--Connected: jdbc:postgresql://192.168.0.10:5432/ti_fiscal
	User: postgres
	Database: PostgreSQL  Version: 8.4.3
	Driver: PostgreSQL Native Driver  Version: PostgreSQL 8.3 JDBC4 with SSL (build 604)
[EL Config]: 2011-02-15 10:50:49.687--Connection(13506221)--connecting(DatabaseLogin(
	platform=>PostgreSQLPlatform
	user name=> "postgres"
	datasource URL=> "jdbc:postgresql://192.168.0.10:5432/ti_fiscal"
))


what am i missing?
thanks
Re: EclipseLink + Spring can't find Postgres Driver [message #654390 is a reply to message #654359] Tue, 15 February 2011 14:36 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1023
Registered: July 2009
Senior Member
Hello,

By stating that hard coding the EntityManager do you mean that the problem only occurs when you use the container to inject the EntityManager? The error states that the container is throwing the exception when EclipseLink attempts to get a connection from the datasource - as this is injected, you may want to check on the Spring site for configuration tips.

EclipseLink is working fine when accessing the factory directly since the container is not injecting the datasource as well as the EntityManager.

Best Regards,
Chris
Previous Topic:JPA 2 : how can I do ReportQueryResult
Next Topic:Does deleting a relationsip remove the dependant object from the database?
Goto Forum:
  


Current Time: Sat Sep 20 12:06:17 GMT 2014

Powered by FUDForum. Page generated in 0.01852 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software