Hi - I've been using JSF with Glassfish successfully for the last few
months, but up to now have not tried to use databases with it, which
I'm now trying for the first time. Before I try writing any code, I
wanted to test out the code in chapter 10 of "Core JavaServer Faces"
to see if database access works with my configuration, and it does
not!
I configured the server as given in the book, and specified the JNDI
name as "jdbc/mydb", and compiled the code provided, created a war
file and deployed it. Online I found a file called
"postgresql-8.3dev-601.jdbc4.jar.zip", copied it to my "/glassfish/
domains/domain1/lib/ext/" folder, as instructed and started the server
and the application. However, after starting the application and
attempting to log in on its test page, I get the "Internal Error"
message produced by the code. In checking the log at localhost:4848 I
get various error messages saying that the connection was refused,
including that I should check TCP/IP.
Could someone kindly advise me on what is going wrong, as until I can
get an example running from the book, I can't go any further. The book
says on page 466 that I first have to create a table with a few
entries, with an example given, but nothing is said as to how I can do
that.
Some help would be most appreciated.
Lew - 22 Feb 2008 13:48 GMT
> I configured the server as given in the book, and specified the JNDI
> name as "jdbc/mydb", and compiled the code provided, created a war
> file and deployed it. Online I found a file called
> "postgresql-8.3dev-601.jdbc4.jar.zip", copied it to my "/glassfish/
> domains/domain1/lib/ext/" folder, as instructed and started the server
I just checked the PG JDBC web site download page
<http://jdbc.postgresql.org/download.html>
and find no '.zip' files, only '.jar' files. The only zipped (actually,
GZIPped) file I see is the source distribution; presumably you only downloaded
the binary distribution.
In any event, make sure that it is a JAR file in your path. You might use a
ZIP program to view the contents to make sure that it is a proper JAR file
that you downloaded.

Signature
Lew
csharpdotcom - 22 Feb 2008 19:41 GMT
> > I configured the server as given in the book, and specified the JNDI
> > name as "jdbc/mydb", and compiled the code provided, created a war
[quoted text clipped - 14 lines]
> --
> Lew
Thanks, well in fact I had downloaded the zipped file mentioned above
and unzipped it. Anyway, I've replaced it with
postgresql-8.3-603.jdbc4.jar from the link you gave, and put it in my
glassfish/domains/domain1/lib/ext/ directory, but I still don't know
how to go from there and get the first example in chapter 10 of Geary
and Horstmann "Core JavaServer Faces" to work. There is some
configuration I'm just not familiar with, as I'm new to this.
Incidentally I'm running Ubunto Linux.
Christopher
Lew - 22 Feb 2008 23:42 GMT
> Thanks, well in fact I had downloaded the zipped file mentioned above
> and unzipped it. Anyway, I've replaced it with
> postgresql-8.3-603.jdbc4.jar from the link you gave, and put it in my
[quoted text clipped - 3 lines]
> configuration I'm just not familiar with, as I'm new to this.
> Incidentally I'm running Ubunto Linux.
In my Glassfish installation I have the PG JDBC driver installed in
$GLASSFISH_HOME/domains/$USER/lib/postgresql-8.x-nnn.jdbc4.jar
no 'ext/'
I configure my datasources via http://localhost:xxxx/, where xxxx is the
'admin console' port.

Signature
Lew
Silvio Bierman - 23 Feb 2008 08:22 GMT
> Hi - I've been using JSF with Glassfish successfully for the last few
> months, but up to now have not tried to use databases with it, which
[quoted text clipped - 21 lines]
>
> Some help would be most appreciated.
The error seems to indicate that there is nothing wrong with your JDBC
driver but it just can't connect to a PostgreSQL database server. Is
that up and running and did you configure the correct JDBC connection URL?
Regards,
Silvio Bierman