cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From D Tim Cummings <...@triptera.com.au>
Subject Re: How to use JNDI in development
Date Fri, 25 Apr 2014 23:03:51 GMT
Thanks Richard

I had found the JNDI option but I wasn't sure how to set the JNDI configuration. I tried adding
the jetty-env.xml as suggested by Michael but got class errors.

Do you have to add any jars to Jetty Classpath > Custom Jetty Classpath in the run configurations.
I have added mysql-connector-java-5.1.26.jar and commons-dbcp-1.4.jar

I suspect you are right about matching Jetty version to Jetty configuration. Do you have a
complete example of configuration and versions which work?

With the following jetty-env.xml

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
	<New id="ds" class="org.eclipse.jetty.plus.jndi.Resource">
		<Arg>jdbc/db_tims</Arg>
		<Arg><New class="org.apache.commons.dbcp.BasicDataSource">
				<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
				<Set name="url">jdbc:mysql://localhost/tmc_tims?autoReconnect=true</Set>
				<Set name="username">tmc_tims</Set>
				<Set name="password">not_secret</Set>
				<Set name="initialSize">1</Set>
				<Set name="minIdle">1</Set>
				<Set name="maxActive">10</Set>
				<Set name="maxIdle">2</Set>
			</New>
		</Arg>
	</New>
</Configure>

I am getting the following errors.

Loading Jetty.xml:/Users/tim/github/tims-app/tims-app/src/main/webapp/WEB-INF/jetty-env.xml
Exception happened when loading Jetty.xml:
java.lang.IllegalArgumentException: Object of class 'org.eclipse.jetty.server.Server' is not
of type 'org.eclipse.jetty.webapp.WebAppContext'. 
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:318)
	at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:279)
	at runjettyrun.Bootstrap.main(Bootstrap.java:66)
2014-04-26 08:51:26.238:INFO:oejs.Server:jetty-7.6.2.v20120308
2014-04-26 08:51:26.350:WARN:oejuc.AbstractLifeCycle:FAILED o.e.j.w.WebAppContext{/tims-app,[file:/Users/tim/github/tims-app/tims-app/src/main/webapp/]}:
java.lang.NoClassDefFoundError: org/apache/commons/pool/KeyedObjectPoolFactory
java.lang.NoClassDefFoundError: org/apache/commons/pool/KeyedObjectPoolFactory
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
	at java.lang.Class.getConstructors(Class.java:1517)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:751)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.itemValue(XmlConfiguration.java:1082)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.value(XmlConfiguration.java:997)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:744)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:386)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:320)
	at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:279)
	at org.eclipse.jetty.plus.webapp.EnvConfiguration.configure(EnvConfiguration.java:119)
	at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:429)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1217)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:676)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:455)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
	at org.eclipse.jetty.server.Server.doStart(Server.java:261)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at runjettyrun.Bootstrap.main(Bootstrap.java:82)
Caused by: 
java.lang.ClassNotFoundException: org.apache.commons.pool.KeyedObjectPoolFactory
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)



On 26 Apr 2014, at 4:16, Richard Frovarp <rfrovarp@apache.org> wrote:

> RunJettyRun handles JNDI. Just tick the Show Advanced Options, then choose JNDI. Make
sure your Jetty JNDI configuration matches your Jetty version. I think Jetty 7+ changed package
names.
> 
> 
> On 04/25/2014 08:40 AM, Michael Gentry wrote:
>> Hi Tim,
>> 
>> RunJettyRun uses plain Jetty and not Jetty+ (which includes the JNDI
>> extension).  What I do in my development is use the Jetty Maven plugin and
>> then just use Maven to run Jetty.  Has worked pretty well so far for me.
>> 
>> 
>> On Thu, Apr 24, 2014 at 9:38 PM, D Tim Cummings <tim@triptera.com.au> wrote:
>> 
>>> Hi
>>> 
>>> I am using cayenne in a tapestry project and my final deployment will be
>>> in Tomcat 7 using JNDI for defining the data source. I am developing in
>>> Eclipse 4.3.1 and would like my development environment to be as close to
>>> deployment as possible. What is the recommended way of using JNDI in
>>> development.
>>> 
>>> I have tried the instructions on
>>> 
>>> http://tynamo.org/Developing+with+Tomcat+and+Eclipse
>>> 
>>> using sysdeo tomcat plugin for eclipse. I haven't been able to get it to
>>> read the jndi information.
>>> 
>>> Apr 25, 2014 11:25:40 AM org.apache.catalina.deploy.NamingResources
>>> addResource
>>> WARNING: Failed to create MBean for naming resource [null]
>>> 
>>> I have tried using RunJettyRun but get.
>>> 
>>> Exception happened when loading Jetty.xml:
>>> java.lang.ClassNotFoundException: org.eclipse.jetty.plus.jndi.Resource
>>> 
>>> 
>>> RunJettyRun works great when I configure cayenne-project.xml to
>>> XMLPoolingDataSourceFactory but I don't want to have to keep switching
>>> between this and JNDI when ready to deploy. I would also prefer to use
>>> tomcat in dev so it is same as prod.
>>> 
>>> JNDI works great when I build a war file and deploy to tomcat but that
>>> would slow my development if I had to do that every time.
>>> 
>>> I don't necessarily have to solve these problems if you can recommend an
>>> alternative way of keeping database config separate to the war. The war
>>> will be deployed by unskilled users on Windows and skilled users on Linux
>>> and Mac so I am trying to keep the steps to deploy simple and not hard code
>>> absolute paths of properties files into my app.
>>> 
>>> Thanks
>>> 
>>> Tim
>>> 
>> 
> 


Mime
View raw message