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
eclipse jetty datasource wildfly jndi


source to share


No one has answered this question yet

Check out similar questions:

3
Configuring a JNDI SQL Resource in Jetty
3
jetty: how to declare jndi JVM objects and bind to java: comp / env
2
Embedded Jetty H2 JNDI Datasouce - javax.naming.NameNotFoundException; remaining name
1
Search WSO2 AS JDNI
1
Finding JNDI datasource with error when using inline Jetty
1
Jetty Jndi datasource issue
0
Get JNDI datasource in Liferay 6.2 Plugin
0
maven storage container with jndi datasource
0
What is the JNDI datasource name running on both Wildfly and Websphere?
0
Jetty uberjar jndi datasource configuration



All Articles
Loading...
X
Show
Funny
Dev
Pics