Adding JNDI names to jettyRun?

I’d liek to create a suite of integration tests that simply starts jettyRun up, runs the tests, then calls jettyStop. This part is simple, but the part that has been killing me is just getting the jndi names setup and working.

I followed the example on the jetty site, but so far no luck. Does anyone have any simple jetty.xml example that includes simple jndi setup?

Thanks, James

We’re using a jetty-config.xml file to pass a file in as a JNDI property, the jetty-config file looks something like:

<?xml version="1.0"
encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">
  <New class="org.mortbay.jetty.plus.naming.EnvEntry">
    <Arg>jndiReference</Arg>
    <Arg type="java.lang.String">file:/some/file/we/use.properties</Arg>
  </New>
</Configure>

James, does this answer your query?

I have the same question as James and the above response doesn’t answer the question for me.

I am new to Gradle and Jetty and am stuck in the gap between Gradle documentation and Jetty documentation.

How do I know which version of Jetty is being used (so I can read the correct Jetty documentation)?

The Gradle documentation says: jettyConfig – The jetty configuration file to use. When null, no configuration file is used.

Which config file are they referring to (Jetty has at least 3) When the setting is null and no config file is used, how is Jetty configured? Can I provide a jetty-web.xml or jetty-env.xml? If so, where do I put them? How do I override the default location? Are there any Groovy/DSL tricks for controlling/overriding configuration?

These kinds of questions are not addressed in the Web App Quickstart or in the Jetty Plugin reference. The Web App Quickstart should provide a complete example with a JNDI DataSource configuration.

Thanks,

Sean

p.s. Get Satisfaction is very unsatisfying. I was unable to login using either the Google or OpenId options. Even clicking “Reply” and then immediately canceling leaves the “Reply” button in the “Replying…” state so you have to copy your reply, save it elsewhere, and reload the page to try again.

Hi Sean,

Not sure about all the different config files for Jetty…

All I’m doing is setting the jettyConfig property of the JettyRunWar task to be a file that I generate that looks like the one above.

And once I do that, our application that looks for the property out of JNDI works fine.

Joel

I’ve got JNDI DataSources working by dropping a jetty-env.xml in src/main/webapp/WEB-INF/

The format of jetty-env.xml is similar to yours, Joel, but is create a DataSource object.

My problem is solved, but I would recommend that someone pass along my questions above to whoever is working on the documentation.

Sorry, I wish I had gotten a chance to reply to this originally but at the time I had an extreme deadline to meet with one of my projects. :wink:

I took some time out today to create an example project. BEHOLD!

https://github.com/jamescarr/gradle-jetty-h2/blob/master/build.gradle

Also, I recommend putting the jetty configuration file somewhere besides under your WEB-INF unless jetty is your production runtime. We use ours for local development so I put the config file under src/test/resources.