Jetty, JNDI, Postgresql: class not found

I am trying to configure JNDI DataSource in Jetty. In the start.ini file, I add the jetty-plus.xml file and the parameters look like this:

OPTIONS=Server,resources,websocket,ext,plus,annotations

Then I add the resource to my context file:

<New id="Traildevils" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg/>
    <Arg>jdbc/Traildevils</Arg>
    <Arg>
        <New class="org.postgresql.ds.PGConnectionPoolDataSource">
            <Set name="User">recom</Set>
            <Set name="Password">recom</Set>
            <Set name="DatabaseName">Traildevils</Set>
            <Set name="ServerName">localhost</Set>
            <Set name="PortNumber">5432</Set>
        </New>
    </Arg>
</New>

The postgresql-9.1-901.jdbc4.jar file is located in the WEB-INF / lib of my war file.

When I try to launch the pier, I get the following error:

2012-04-12 12:58:09.723:WARN:oejx.XmlConfiguration:Config error at 
<New id="Traildevils" class="org.eclipse.jetty.plus.jndi.Resource"><Arg/>
<Arg>jdbc/Traildevils</Arg>
<Arg>|???<New class="org.postgresql.ds.PGConnectionPoolDataSource">
<Set name="User">recom</Set>
<Set name="Password">recom</Set>
<Set name="DatabaseName">Traildevils</Set>
<Set name="ServerName">localhost</Set><Set name="PortNumber">5432</Set></New>|??</Arg></New> 
java.lang.ClassNotFoundException: org.postgresql.ds.PGConnectionPoolDataSource

What did I miss?

+3
source share
1 answer

You need to add postgresql-9.1-901.jdbc4.jar to $JETTY_HOME/lib/ext.

This is because jetty initializes the JNDI context before it loads the classes from your WAR.

+6
source

All Articles