Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:08:55+00:00 2026-06-17T20:08:55+00:00

More specifically i got executable war containing all the dependencies. Application starts without jndi

  • 0

More specifically i got executable war containing all the dependencies.
Application starts without jndi datasource like a charm runing it with jndi datasource failed though.
I believe there is no place for jetty.xml in such a configuration so jetty-env.xml is no go either since jetty wont read it by default. I attempted to use jetty-web.xml for jndi datasource configuration but jetty fails to deploy application returning 503 error code.
I am using Jetty9-M4.
Attempted tomcat pooling and BoneCP both with same result.

Starter class:

import java.net.URL;
import java.security.ProtectionDomain;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.webapp.WebAppContext;


public final class Loader {

    public static void main(String[] args) throws Exception
    {
         String jetty_home = "..";
         int appli_port = 8080;
         Server server = new Server(appli_port);
         ProtectionDomain protectionDomain = Loader.class.getProtectionDomain();
         URL location = protectionDomain.getCodeSource().getLocation();
         WebAppContext webapp = new WebAppContext();
         webapp.setContextPath("/");
         webapp.setWar(location.toExternalForm());    
         server.setHandler(webapp);

         server.start();
         server.join();
    }
}

jetty-web.xml:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <New id="testDS" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg></Arg>
        <Arg>jdbc/testDS</Arg>
        <Arg>
            <New class="com.jolbox.bonecp.BoneCPDataSource">
                <Set name="driverClass">org.postgresql.Driver</Set>
                <Set name="jdbcUrl">jdbc:postgresql://localhost:5432/testDS</Set>
                <Set name="username">name</Set>
                <Set name="password">password</Set>
                <Set name="minConnectionsPerPartition">5</Set>
                <Set name="maxConnectionsPerPartition">50</Set>
                <Set name="acquireIncrement">5</Set>
                <Set name="idleConnectionTestPeriod">30</Set>
            </New>
        </Arg>
    </New>
</Configure>

I suspect that its either to late for jndi on jetty-web phase or config is just wrong.

Sorry for bad english.


Forgot to mention i am using Hibernate as ORM.

web.xml contains:

<resource-ref>
    <description>Postgres datasource</description>
    <res-ref-name>jdbc/testDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

Hibernate.cfg.xml contains

<property name="hibernate.connection.datasource">java:comp/env/jdbc/testDS</property>

attempted

<property name="hibernate.connection.datasource">jdbc/testDS</property>

not working either.


As a little side note jetty-web.xml placed in WEB-INF of your war is fine for JNDI resource configuration and it is used by default.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:08:56+00:00Added an answer on June 17, 2026 at 8:08 pm

    jetty-env.xml files should be picked up from WEB-INF/jetty-env.xml automatically, see here: http://www.eclipse.org/jetty/documentation/current/jetty-env-xml.html. I would suggest going with jetty-env.xml as opposed to jetty-web.xml.

    Can you also show how you are performing the JNDI look up from within your application? Maybe the JNDI datasource is being initialized correctly but the JNDI name isn’t correct?

    There are some jetty JNDI examples here: http://www.eclipse.org/jetty/documentation/current/jndi-datasource-examples.html

    Update:
    Seems like Jetty won’t pick it up automatically when running embedded. Try this:

    public static void main(String[] args) throws Exception
    {
        String jetty_home = "..";
        int appli_port = 8080;
        Server server = new Server(appli_port);
        ProtectionDomain protectionDomain = Loader.class.getProtectionDomain();
        URL location = protectionDomain.getCodeSource().getLocation();
        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath("/");
        webapp.setWar(location.toExternalForm());
    
        // setup JNDI
        EnvConfiguration envConfiguration = new EnvConfiguration();
        URL url = new File("path to jetty-env.xml").toURI().toURL();
        envConfiguration.setJettyEnvXml(url);
        webapp.setConfigurations(new Configuration[] {new WebInfConfiguration(), envConfiguration, new WebXmlConfiguration()});
    
        server.setHandler(webapp); 
        server.start();
        server.join();
    }
    

    (See http://blog.armhold.com/2011/12/27/how-to-get-jndi-working-with-wicket-1-5-and-jetty-7-5/)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

More specifically, I was using homebrew to install MySQL, and I got this error:
More specifically I want to test whether Oracle ODP.Net is installed on a machine.
More specifically, is List(T)(IEnumerable(T)) thread-safe if the IEnumerable used to initialize the list is
More specifically, does NDK have a complete STL implementation. We're looking at this for
...or more specifically, how are they able to create animations via javascript, which is
I am making a GUI in OpenGL (more specifically lwjgl). I have tried hard
http://developer.yahoo.com/yui/button More specifically, I want radio buttons. that can be checked/unchecked.
When using the PHP Tidy Library (More Specifically, The tidy_repair_string function) I keep getting
I'm writing some coordinate transformations (more specifically the Joukoswky Transform, Wikipedia Joukowsky Transform ),
Editing a RichTextBox control's text (more specifically, modifying selection font/color) programmatically seems to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.