Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty-8.1.1 - JNDI DB Resource not working with jetty-env.xml, works in jetty-web.xml

Jamie,

The set of configuration classes should be:

    <Call name="setAttribute">
      <Arg>org.eclipse.jetty.webapp.configuration</Arg>
      <Arg>
          <Array type="java.lang.String">
               <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
               <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
               <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
               <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
               <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
               <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
               <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
               <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
          </Array>
      </Arg>
    </Call>

I don't think that is the cause of your problem, but worth getting
that straight first. Note also that you don't need to put that into
jetty.xml. There should be a etc/jetty-plus.xml file which has that
defined, and that can be used by editing start.ini and either
uncommenting it or adding it in. I'll update the wiki documentation
page to reflect that.

Are you sure there are no other errors? Anything about classes not
found (eg where is the dbcp jar, is it in ext?)

regards
Jan
PS you may find it easier to download the jetty-hightide distribution,
which has jndi services enabled for all webapps by default:
http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-hightide/8.1.1.v20120215/


On 1 March 2012 11:40, Jamie Maher <jamie.maher@xxxxxxxxx> wrote:
> Hi there,
>
>  New Jetty user here and I'm having a problem with Jetty not being able
> to find my JNDI pooled database connection
> when it is configured in WEB-INF/jetty-env.xml
>
> I get an exception in Jetty-8.1.1-v20120215:
>
> javax.naming.NameNotFoundException; remaining name 'env/jdbc/MyDB'
>
> (Note: JNDI does work if I change the name to jetty-web.xml and specify
> the the full name of "java:comp/env/jdbc/MyDB" in the Resource)
>
> Can anyone shed any light or point out what I'm doing wrong, or is
> jetty-env.xml not supported anymore in 8.1.1?
> I've looked through the Eclipse Wiki and can't seem to figure out what's
> going wrong.
>
> See below for my setup..
>
> Thanks,
> Jamie
>
> ------------------------
> setup:
>
> start.ini contains the following OPTIONS:
> OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations
>
>
> jetty.xml - added the following just above "extra options"
>
>    <!-- =========================================================== -->
>    <!-- Support jetty-env.xml in webapps                         -->
>    <!-- =========================================================== -->
>    <Call name="setAttribute">
>      <Arg>org.eclipse.jetty.webapp.configuration</Arg>
>      <Arg>
>          <Array type="java.lang.String">
>          <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
>          <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
>          <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
>          <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
>          <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
>          <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
>          <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
>          <Item>org.eclipse.jetty.webapp.TagLibConfiguration</Item>
>          </Array>
>      </Arg>
>    </Call>
>
>
>
> The jetty-env.xml file:
>
> <?xml version="1.0"  encoding="ISO-8859-1"?>
> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
> "http://www.eclipse.org/jetty/configure.dtd";>
>
> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
>
>  <New id="DpsDB" class="org.eclipse.jetty.plus.jndi.Resource">
>    <Arg></Arg>
>    <Arg>jdbc/MyDB</Arg>
>    <Arg>
>     <New class="org.apache.commons.dbcp.BasicDataSource">
>         <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
>         <Set name="url">jdbc:mysql://192.168.1.1:3306/MyDB</Set>
>         <Set name="username">myuser</Set>
>         <Set name="password">mypw</Set>
>     </New>
>    </Arg>
>   </New>
>
> </Configure>
>
>
>
> web.xml file contains:
> <resource-ref>
>     <description>MyDB datasource reference</description>
>     <res-ref-name>jdbc/MyDB</res-ref-name>
>     <res-type>javax.sql.DataSource</res-type>
>     <res-auth>Container</res-auth>
>  </resource-ref>
>
>
>
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top