Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Context-Scoped JNDI Datasource in Context XML

Marvin,

You need to ensure that you have the extra Configurations (in the
correct order) to support JNDI deployments defined for your webapp:
http://wiki.eclipse.org/Jetty/Feature/JNDI#Setting_up_the_list_of_Configurations

The other likely thing that is wrong is that you don't have the
org.apache.tomcat.jdbc.pool.DataSource class on the jetty container's
classpath - check that you have the relevant jar in $JETTY_HOME/lib
(eg in $JETTY_HOME/lib/ext with OPTIONS=ext specified on the runline
or start.ini).

Thirdly, and probably the moist common problem I see with people
moving from Tomcat, is that the servlet spec wants you to link up
resources defined to the container via <resource-ref>,
<resource-env-ref> etc entries in web.xml. Apparently Tomcat makes
available all resources in the container's environment without
requiring that - but that is not portable behaviour.

regards
Jan

On 30 January 2013 08:16, Marvin Addison <marvin.addison@xxxxxxxxx> wrote:
> I'm new to Jetty and am investigating migrating to Jetty 8 from
> Tomcat. Our deployment model makes use of JNDI data sources created
> and registered via context configuration files. I'm trying to
> replicate this setup in Jetty, which by my careful reading of
> http://wiki.eclipse.org/Jetty/Feature/JNDI appears to be supported.
> Yet I'm getting NameNotFoundException on deployment.
>
> Based on the order of log entries and stepping through the JNDI
> components in a debugger, it appears that the EnvConfiguration
> component is firing _before_ the JNDI components get
> created/registered in the context XML. Moreover, I can't find a
> complete example that demonstrates what I'm trying to do. I see
> repeated examples of using jetty-env.xml to register context-scoped
> entries, but I want to do all context configuration in a single file.
>
> My context XML follows for reference:
>
> <Configure id="cas" class="org.eclipse.jetty.webapp.WebAppContext">
>
>   <Set name="contextPath">/</Set>
>   <Set name="war">/home/marvin/apps/cas/cas.war</Set>
>   <Call name="setInitParameter">
>     <Arg>cas.home</Arg>
>     <Arg>/home/marvin/apps/cas</Arg>
>   </Call>
>
>   <New id="CASDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
>     <Arg><Ref id="cas"/></Arg>
>     <Arg>jdbc/cas</Arg>
>     <Arg>
>       <New class="org.apache.tomcat.jdbc.pool.DataSource">
>         <Set name="driverClassName">org.postgresql.Driver</Set>
>         <Set name="url">${cas.db.url}</Set>
>         <Set name="username">${cas.db.username}</Set>
>         <Set name="password">${cas.db.password}</Set>
>         <Set name="initialSize">2</Set>
>         <Set name="maxActive">4</Set>
>         <Set name="minIdle">2</Set>
>         <Set name="maxWait">5000</Set>
>         <Set name="testWhileIdle" type="boolean">true</Set>
>         <Set name="testOnBorrow" type="boolean">false</Set>
>         <Set name="testOnReturn" type="boolean">false</Set>
>         <Set name="validationQuery">SELECT 1</Set>
>         <Set name="validationInterval">30000</Set>
>         <Set name="timeBetweenEvictionRunsMillis">10000</Set>
>         <Set name="minEvictableIdleTimeMillis">600000</Set>
>         <Set name="removeAbandoned" type="boolean">true</Set>
>         <Set name="jmxEnabled" type="boolean">false</Set>
>       </New>
>     </Arg>
>   </New>
>
> </Configure>
>
> Is there a way to accomplish this? If not, are there alternatives? The
> ultimate goal is a deployable that is environment agnostic, which
> precludes a /WEB-INF/jetty-env.xml file in the war file.
>
> Thanks,
> Marvin
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users



-- 
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com – Developer advice, services and support
from the Jetty & CometD experts.


Back to the top