I'm having a problem getting a servet (part of a plugin) to connect to an external datasource. The datasource is a postgresql DB, and is defined in server.xml and can be accessed through the (wonderful) SQL plugin.
However, I cannot get to the DB through my servlet. I've tried three things:
1) By the standard Class.forName("org.postgresql.Driver"); syntax. I get a "no class found" error.
2) By directly instantiating a postgresql Driver object (Driver d = new org.postgresql.Driver()) and registering it. I get a java.lang.NoClassDefFoundError: org/postgresql/Driver error.
3) By getting an initial context within the servlet's init method ( Context ctx = InitialContext() ) and going after the datasource since clearly the SQL plugin can read the data source.
Nothing has worked to date. First, how is it that the postgresql libs appear to not be within the servlet's classpath? They are obviously accessible to Confluence as it is the database for the instance as well as for the SQL plugin calls.
Second, I'd rather use the datasource approach to raw JDBC connections. Does anyone have a code snippet that shows how that can work within the context of a servlet?
Thanks!
Paul