Jetty and Wildfly JNDI compatible
I'm a bit rusty on configurations as I haven't written anything from scratch for years .. I'm writing a webservice that I want to use locally with a jetty in eclipse and then on a server with Wildfly. I figured it out separately, but not so that both work at the same time. I have: In java Im looking for a dbsource with
final DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/smartieDB");
For jetty, this works in jetty-env.xml:
<Configure class="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<New id="smartieDB" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/smartieDB</Arg> ..... etc
web.xml:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>/comp/env/jdbc/smartieDB</res-ref-name> <!--<-this was for wildfly, for jetty this only works: jdbc/smartieDB -->
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
In wildfly, a datasource is configured named jndi:
<datasource jndi-name="java:/comp/env/jdbc/smartieDB" pool-name="PostgrePool">
Any ideas how I can optimize this so that I don't have to do checks on where it is on the dock and when it runs on the server? Thanks for all the advice!
Cheers, Nikki
+3
source to share
No one has answered this question yet
Check out similar questions: