1

I have a webapp for Jetty 8.1.16 that uses JNDI to read database connection information. The application is built with maven and can be successfully run on development machines using the maven jetty plugin.

However, when deploying to a remote server, jetty fails to find the JDNI data source:

SEVERE: [application] DataSource JNDI name not found.
javax.naming.NameNotFoundException; remaining name 'env/jdbc/Foo'

when trying to get the it programmatically:

DataSource datasource = (DataSource)ctx.lookup( "java:comp/env/jdbc/" + datasourceName);

with the jetty-env.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure id='wac' class="org.eclipse.jetty.webapp.WebAppContext">
  <New id="Foo" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/Foo</Arg>
    <Arg>
      <New class="com.microsoft.sqlserver.jdbc.SQLServerXADataSource">
        <Set name="URL">Connection String</Set>
      </New>
    </Arg>
  </New>
</Configure>

and resource definition in web.xml:

<resource-ref>
    <description>Foo DataSource Reference</description>
    <res-ref-name>jdbc/Foo</res-ref-name>
    <res-type>javax.sql.XADataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

start.ini

Options=Server,jsp,jmx,resource,websocket,ext,plus,annotations

etc/jetty.xml
etc/jetty-deploy.xml
etc/jetty-webapps.xml
etc/jetty-contexts.xml
etc/jetty-testrealm.xml
etc/jetty-plus.xml
etc/jetty-annotations.xml

I am completely defeated at this point.

Using the fully qualifying name in jetty-env.xml doesn't work. Having the code only call the partial name doesn't work Adding jetty plus to the options doesn't work.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
ThisIsNoZaku
  • 2,213
  • 2
  • 26
  • 37

0 Answers0