Announcement Announcement Module
Collapse
No announcement yet.
PostgreSQL won't work with Spring and Tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PostgreSQL won't work with Spring and Tomcat

    Hello,

    I'm not sure whether this is a problem with Spring or not, but I have to start asking somewhere. :wink:

    We're trying to access a PostgreSQL database using JDBC and JNDI. Our Spring-app (which provides remote services) is running on a Tomcat 5 server and the PostgreSQL JDBC jar is in [catalina-home]/common/lib. On startup the JNDI-resource is found and all is well until we try to call a function that accesses the database. When calling a remote method, we get a ClassNotFound exception claiming it cannot find org.postgresql.util.PSQLException. The logfiles provide the following information:
    2004-12-15 09:49:37,156 INFO org.springframework.jdbc.support.SQLErrorCodesFact ory - SQLErrorCodes loaded: [HSQL Database Engine, Oracle, Sybase SQL Server, Informix Dynamic Server, Microsoft SQL Server, PostgreSQL, MySQL, DB2*]
    2004-12-15 09:49:46,752 WARN org.springframework.jdbc.support.SQLErrorCodesFact ory - Error while extracting database product name - falling back to empty error codes

    What could be the problem? I've been trying to find it for 5 hours now... :?
    Thanks in advance for any help,

    -Petter-

  • #2
    I don't have an answer to your problem, but for what it's worth, I'm using Spring, JBoss & Postgresql without any problems. JBoss includes Tomcat, but of course the placing of common jars is different.

    You say
    When calling a remote method, we get a ClassNotFound exception
    You don't detail your setup. Is it the remote method doing the database call? If so, does the remote JVM have access to postgresql.jar? Sorry if I'm asking the obvious.

    Comment


    • #3
      You don't detail your setup. Is it the remote method doing the database call? If so, does the remote JVM have access to postgresql.jar? Sorry if I'm asking the obvious.
      It is I who should apologize for not providing enough details. However, I just found out that adding the postgresql.jar file to the client's classpath solved the problem. Is this normal? Now I need to distribute the database driver package with every client.

      -Petter-

      Comment


      • #4
        I'm into territory I don't know much about here, so this may be nonsense, but I'm wondering if it's just the postgresql Exception class that is a problem? And if so, if you catch that Exception at the server end and throw an Exception of your own, could you avoid having to distribute the postgresql jar?

        Comment


        • #5
          Originally posted by cmgharris
          I'm into territory I don't know much about here, so this may be nonsense, but I'm wondering if it's just the postgresql Exception class that is a problem? And if so, if you catch that Exception at the server end and throw an Exception of your own, could you avoid having to distribute the postgresql jar?
          Funny, I actually figured this one out myself! This is exactly what I have done and everything works fine. Case closed. Thanks for your help.

          -Petter-

          Comment


          • #6
            It's because of nested exceptions

            The answer is very simple: something wrong happens and PostgreSQL throws an exception. This is caught and wrapped in a NestedRuntimeException, that still contains the original org.postgresql.util.PSQLException. This exception is serialized and sent over the wire at the client where no such PostgreSQL jdbc classes are found.

            Comment

            Working...
            X