Netbeans, postgresql, JPA and tutorial


I've started learning JSP, JSF and other stuff used to develop J2EE apps. Of course everything is standing on database, and with accessing to the postgresql database I had the biggest problem.



I start with tutorials founded on netbeans.com web site, 1st Using Java Persistence API Within a Visual Web Application, but unfortunately every time when I start application I got such error on glassfish console:


Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:postgresql://ldap.krajniak.test/lastvideo
Error Code: 0
(...)
com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:postgresql://ldap.krajniak.test/lastvideo
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:100)
... 97 more
sending notification to server...server

strange error, couldn't resolve it for 2 days, and at last today I resolved it. As I think, stupid bug, stupid error. How to resolve it? Very simple, you have to launch glass admin panel (e.g. right click on Service->Servers->GlassFish->View Admin Console), next click on Application Server and JVM Settings->Path Settings. In classpath type full path to postgresql .jar file, restart glassfish server and that's all. Tutorial apps now is able to connect to database :-)

4 comments:

DNJ said...

Great! Thanks! Your trick saves me!

Unknown said...

thx!!!, extrange behavior of glassfish. This error usually is thrown when the URL is invalid for the driver. I having been 2 hours with this problem (Netbeans + Woodstock + JPA + postgresqk).

ARomanyuk said...

thanx... I'm was stuck at this issue for a whole day (-:

Kiichiro said...

hi, thanks your doc.
i spend 2 days....
the tutrial need to explain this...