You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by D Tim Cummings <ti...@triptera.com.au> on 2014/04/25 03:38:08 UTC

How to use JNDI in development

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

Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
And of course it shouldn't be resource-ref-name but res-ref-name. 

	<resource-ref>
		<res-ref-name>jdbc/db_tims</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>


Fixing that and I can now use RunJettyRun or mvn jetty:run or Andrus's system properties which allow me to leave my JNDI configuration in place during development.

Thanks for everyone's help

Tim

On 27 Apr 2014, at 6:54, D Tim Cummings <ti...@triptera.com.au> wrote:

> Hi Michael
> 
> Problem was a wrong case on the s in DataSource in my web.xml file 
> 
> I had
> 
> 	<resource-ref>
> 		<resource-ref-name>jdbc/db_tims</resource-ref-name>
> 		<res-type>javax.sql.Datasource</res-type>
> 		<res-auth>Container</res-auth>
> 	</resource-ref>
> 
> But I should have had
> 
> 	<resource-ref>
> 		<resource-ref-name>jdbc/db_tims</resource-ref-name>
> 		<res-type>javax.sql.DataSource</res-type>
> 		<res-auth>Container</res-auth>
> 	</resource-ref>
> 
> So mvn jetty:run is working now for me. It just doesn't do live class reloading in Tapestry project. Does live class reloading work for you?
> 
> Tim
> 
> On 26 Apr 2014, at 22:19, Michael Gentry <mg...@masslight.net> wrote:
> 
>> Hi Tim,
>> 
>> Given the exception:
>> 
>> Caused by:
>> java.lang.ClassNotFoundException: javax.sql.Datasource
>> 
>> I'm going to guess you perhaps forgot to include this dependency in the POM?
>> 
>>        <dependency>
>>            <!-- Used by jetty:run to define JDNI data source -->
>>            <groupId>commons-dbcp</groupId>
>>            <artifactId>commons-dbcp</artifactId>
>>            <version>1.4</version>
>>            <scope>runtime</scope>
>>        </dependency>
>> 
>> mrg
>> 
>> 
>> On Fri, Apr 25, 2014 at 6:39 PM, D Tim Cummings <ti...@triptera.com.au> wrote:
>> 
>>> Thanks Michael.
>>> 
>>> This is very handy. I downloaded cbe and was able to get it running
>>> talking to a mysql database by changing the jndi config. Now I am trying to
>>> retrofit config to my app and I get the following error when I do mvn
>>> jetty:run. I have all the same dependencies and plugins (plus a few more)
>>> although some of my versions are more recent.
>>> 
>>> [INFO] Scanning for projects...
>>> [INFO]
>>> 
>>> [INFO]
>>> ------------------------------------------------------------------------
>>> [INFO] Building Tims App 0.0.8
>>> [INFO]
>>> ------------------------------------------------------------------------
>>> [INFO]
>>> [INFO] >>> jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>>>>>> 
>>> [INFO]
>>> [INFO] --- maven-cayenne-plugin:3.2M1:cgen (default-cli) @ tims-app ---
>>> [INFO]
>>> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
>>> tims-app ---
>>> [WARNING] File encoding has not been set, using platform encoding UTF-8,
>>> i.e. build is platform dependent!
>>> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
>>> resources, i.e. build is platform dependent!
>>> [INFO] Copying 33 resources
>>> [INFO]
>>> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tims-app
>>> ---
>>> [INFO] Nothing to compile - all classes are up to date
>>> [INFO]
>>> [INFO] --- maven-resources-plugin:2.6:testResources
>>> (default-testResources) @ tims-app ---
>>> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
>>> resources, i.e. build is platform dependent!
>>> [INFO] skip non existing resourceDirectory
>>> /Users/tim/github/tims-app/tims-app/src/test/resources
>>> [INFO]
>>> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
>>> tims-app ---
>>> [INFO] Nothing to compile - all classes are up to date
>>> [INFO]
>>> [INFO] <<< jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>>> <<<
>>> [INFO]
>>> [INFO] --- jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>>> ---
>>> [INFO] Configuring Jetty for project: Tramanco Vehicle Weigh
>>> [INFO] Webapp source directory =
>>> /Users/tim/github/tims-app/tims-app/src/main/webapp
>>> [INFO] Reload Mechanic: automatic
>>> [INFO] Classes =
>>> /Users/tim/github/tims-app/tims-app/target/tims-app/WEB-INF/classes
>>> [INFO] Added extra scan
>>> target:/Users/tim/github/tims-app/tims-app/src/main/resources
>>> [INFO] Context path = /tims-app
>>> [INFO] Tmp directory = /Users/tim/github/tims-app/tims-app/target/tmp
>>> [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
>>> [INFO] Web overrides =  none
>>> [INFO] web.xml file =
>>> file:/Users/tim/github/tims-app/tims-app/src/main/webapp/WEB-INF/web.xml
>>> [INFO] Webapp directory = /Users/tim/github/tims-app//src/main/webapp
>>> [INFO] Starting jetty 7.5.1.v20110908 ...
>>> 2014-04-26 08:28:40.142:INFO:oejs.Server:jetty-7.5.1.v20110908
>>> 2014-04-26 08:28:41.030:INFO:oejpw.PlusConfiguration:No Transaction
>>> manager found - if your webapp requires one, please configure one.
>>> 2014-04-26 08:28:41.068:WARN:oejw.WebAppContext:Failed startup of context
>>> o.m.j.p.JettyWebAppContext{/tims-app,file:/Users/tim/github/tims-app/tims-app/src/main/webapp/},file:/Users/tim/github/tims-app/tims-app/src/main/webapp/
>>> java.lang.reflect.InvocationTargetException
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>> at
>>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>>> at
>>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
>>> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
>>> at
>>> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>>> at
>>> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
>>> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
>>> at
>>> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>>> at
>>> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
>>> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
>>> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
>>> at
>>> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>>> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
>>> at
>>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
>>> at
>>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>>> at
>>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>>> at
>>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
>>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
>>> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>>> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
>>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>>> Caused by:
>>> java.lang.ClassNotFoundException: javax.sql.Datasource
>>> 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
>>> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
>>> at
>>> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
>>> at
>>> org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1323)
>>> at
>>> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.visitResourceRef(PlusDescriptorProcessor.java:245)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>> at
>>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>>> at
>>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
>>> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
>>> at
>>> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>>> at
>>> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
>>> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
>>> at
>>> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>>> at
>>> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
>>> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
>>> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>>> at
>>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>>> at
>>> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
>>> at
>>> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>>> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
>>> at
>>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
>>> at
>>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>>> at
>>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>>> at
>>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>>> at
>>> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
>>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
>>> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>>> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
>>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>>> at
>>> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>>> 2014-04-26 08:28:41.087:INFO:oejs.AbstractConnector:Started
>>> SelectChannelConnector@0.0.0.0:8088 STARTING
>>> [INFO] Started Jetty Server
>>> 
>>> 
>>> On 25 Apr 2014, at 23:43, Michael Gentry <mg...@masslight.net> wrote:
>>> 
>>> Here is a pom.xml which includes the Jetty plugin:
>>> 
>>> https://github.com/mrg/cbe/blob/master/WebApplications/pom.xml
>>> 
>>> And a jetty-env.xml which defines the JNDI lookup:
>>> 
>>> 
>>> https://github.com/mrg/cbe/blob/master/WebApplications/src/main/webapp/WEB-INF/jetty-env.xml
>>> 
>>> 
>>> mrg
>>> 
>>> 
>>> 
>>> On Fri, Apr 25, 2014 at 9:40 AM, Michael Gentry <mgentry@masslight.net
>>>> 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
>>> 
>>> 
>>> 
>>> 
>>> 
> 


Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks. Live class reloading is working now.

Tim

On 27 Apr 2014, at 10:06, Michael Gentry <mg...@masslight.net> wrote:

> Hi Tim,
> 
> Yes, live class reloading (within the Tapestry realm --
> pages/components/services) works for me.  Make sure you are running
> your application in development mode instead of production mode.
> (Production mode is the default.)
> 
> If you look at the POM I shared with you, you'll see I have:
> 
>                        <systemProperty>
>                            <name>tapestry.production-mode</name>
>                            <value>false</value>
>                        </systemProperty>
> 
> This overrides the default when you run the application via Maven.
> 
> mrg
> 
> 
> 
> On Sat, Apr 26, 2014 at 4:54 PM, D Tim Cummings <ti...@triptera.com.au> wrote:
> 
>> Hi Michael
>> 
>> Problem was a wrong case on the s in DataSource in my web.xml file
>> 
>> I had
>> 
>> <resource-ref>
>> <resource-ref-name>jdbc/db_tims</resource-ref-name>
>> <res-type>javax.sql.Datasource</res-type>
>> <res-auth>Container</res-auth>
>> </resource-ref>
>> 
>> But I should have had
>> 
>> <resource-ref>
>> <resource-ref-name>jdbc/db_tims</resource-ref-name>
>> <res-type>javax.sql.DataSource</res-type>
>> <res-auth>Container</res-auth>
>> </resource-ref>
>> 
>> So mvn jetty:run is working now for me. It just doesn't do live class
>> reloading in Tapestry project. Does live class reloading work for you?
>> 
>> Tim
>> 
>> On 26 Apr 2014, at 22:19, Michael Gentry <mg...@masslight.net> wrote:
>> 
>> Hi Tim,
>> 
>> Given the exception:
>> 
>> Caused by:
>> java.lang.ClassNotFoundException: javax.sql.Datasource
>> 
>> I'm going to guess you perhaps forgot to include this dependency in the
>> POM?
>> 
>>       <dependency>
>>           <!-- Used by jetty:run to define JDNI data source -->
>>           <groupId>commons-dbcp</groupId>
>>           <artifactId>commons-dbcp</artifactId>
>>           <version>1.4</version>
>>           <scope>runtime</scope>
>>       </dependency>
>> 
>> mrg
>> 
>> 
>> On Fri, Apr 25, 2014 at 6:39 PM, D Tim Cummings <ti...@triptera.com.au>
>> wrote:
>> 
>> Thanks Michael.
>> 
>> This is very handy. I downloaded cbe and was able to get it running
>> talking to a mysql database by changing the jndi config. Now I am trying to
>> retrofit config to my app and I get the following error when I do mvn
>> jetty:run. I have all the same dependencies and plugins (plus a few more)
>> although some of my versions are more recent.
>> 
>> [INFO] Scanning for projects...
>> [INFO]
>> 
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Building Tims App 0.0.8
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO]
>> [INFO] >>> jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>> 
>> 
>> [INFO]
>> [INFO] --- maven-cayenne-plugin:3.2M1:cgen (default-cli) @ tims-app ---
>> [INFO]
>> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
>> tims-app ---
>> [WARNING] File encoding has not been set, using platform encoding UTF-8,
>> i.e. build is platform dependent!
>> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
>> resources, i.e. build is platform dependent!
>> [INFO] Copying 33 resources
>> [INFO]
>> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tims-app
>> ---
>> [INFO] Nothing to compile - all classes are up to date
>> [INFO]
>> [INFO] --- maven-resources-plugin:2.6:testResources
>> (default-testResources) @ tims-app ---
>> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
>> resources, i.e. build is platform dependent!
>> [INFO] skip non existing resourceDirectory
>> /Users/tim/github/tims-app/tims-app/src/test/resources
>> [INFO]
>> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
>> tims-app ---
>> [INFO] Nothing to compile - all classes are up to date
>> [INFO]
>> [INFO] <<< jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>> <<<
>> [INFO]
>> [INFO] --- jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>> ---
>> [INFO] Configuring Jetty for project: Tramanco Vehicle Weigh
>> [INFO] Webapp source directory =
>> /Users/tim/github/tims-app/tims-app/src/main/webapp
>> [INFO] Reload Mechanic: automatic
>> [INFO] Classes =
>> /Users/tim/github/tims-app/tims-app/target/tims-app/WEB-INF/classes
>> [INFO] Added extra scan
>> target:/Users/tim/github/tims-app/tims-app/src/main/resources
>> [INFO] Context path = /tims-app
>> [INFO] Tmp directory = /Users/tim/github/tims-app/tims-app/target/tmp
>> [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
>> [INFO] Web overrides =  none
>> [INFO] web.xml file =
>> file:/Users/tim/github/tims-app/tims-app/src/main/webapp/WEB-INF/web.xml
>> [INFO] Webapp directory = /Users/tim/github/tims-app//src/main/webapp
>> [INFO] Starting jetty 7.5.1.v20110908 ...
>> 2014-04-26 08:28:40.142:INFO:oejs.Server:jetty-7.5.1.v20110908
>> 2014-04-26 08:28:41.030:INFO:oejpw.PlusConfiguration:No Transaction
>> manager found - if your webapp requires one, please configure one.
>> 2014-04-26 08:28:41.068:WARN:oejw.WebAppContext:Failed startup of context
>> 
>> o.m.j.p.JettyWebAppContext{/tims-app,file:/Users/tim/github/tims-app/tims-app/src/main/webapp/},file:/Users/tim/github/tims-app/tims-app/src/main/webapp/
>> java.lang.reflect.InvocationTargetException
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> 
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>> at
>> 
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
>> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
>> at
>> 
>> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>> at
>> 
>> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
>> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
>> at
>> 
>> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> 
>> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
>> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
>> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
>> at
>> 
>> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
>> at
>> 
>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
>> at
>> 
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>> at
>> 
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>> at
>> 
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
>> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> 
>> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>> at
>> 
>> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>> Caused by:
>> java.lang.ClassNotFoundException: javax.sql.Datasource
>> 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
>> 
>> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
>> at
>> 
>> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
>> at
>> 
>> org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1323)
>> at
>> 
>> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.visitResourceRef(PlusDescriptorProcessor.java:245)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> 
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>> at
>> 
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
>> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
>> at
>> 
>> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>> at
>> 
>> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
>> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
>> at
>> 
>> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> 
>> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
>> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
>> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>> at
>> 
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> 
>> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
>> at
>> 
>> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
>> at
>> 
>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
>> at
>> 
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>> at
>> 
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>> at
>> 
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>> at
>> 
>> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
>> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> 
>> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>> at
>> 
>> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>> 2014-04-26 08:28:41.087:INFO:oejs.AbstractConnector:Started
>> SelectChannelConnector@0.0.0.0:8088 STARTING
>> [INFO] Started Jetty Server
>> 
>> 
>> On 25 Apr 2014, at 23:43, Michael Gentry <mg...@masslight.net> wrote:
>> 
>> Here is a pom.xml which includes the Jetty plugin:
>> 
>> https://github.com/mrg/cbe/blob/master/WebApplications/pom.xml
>> 
>> And a jetty-env.xml which defines the JNDI lookup:
>> 
>> 
>> 
>> https://github.com/mrg/cbe/blob/master/WebApplications/src/main/webapp/WEB-INF/jetty-env.xml
>> 
>> 
>> mrg
>> 
>> 
>> 
>> On Fri, Apr 25, 2014 at 9:40 AM, Michael Gentry <mgentry@masslight.net
>> 
>> 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
>> 
>> 
>> 
>> 
>> 
>> 
>> 


Re: How to use JNDI in development

Posted by Michael Gentry <mg...@masslight.net>.
Hi Tim,

Yes, live class reloading (within the Tapestry realm --
pages/components/services) works for me.  Make sure you are running
your application in development mode instead of production mode.
 (Production mode is the default.)

If you look at the POM I shared with you, you'll see I have:

                        <systemProperty>
                            <name>tapestry.production-mode</name>
                            <value>false</value>
                        </systemProperty>

This overrides the default when you run the application via Maven.

mrg



On Sat, Apr 26, 2014 at 4:54 PM, D Tim Cummings <ti...@triptera.com.au> wrote:

> Hi Michael
>
> Problem was a wrong case on the s in DataSource in my web.xml file
>
> I had
>
>  <resource-ref>
>  <resource-ref-name>jdbc/db_tims</resource-ref-name>
>  <res-type>javax.sql.Datasource</res-type>
>  <res-auth>Container</res-auth>
>  </resource-ref>
>
> But I should have had
>
>  <resource-ref>
>  <resource-ref-name>jdbc/db_tims</resource-ref-name>
>  <res-type>javax.sql.DataSource</res-type>
>  <res-auth>Container</res-auth>
>  </resource-ref>
>
> So mvn jetty:run is working now for me. It just doesn't do live class
> reloading in Tapestry project. Does live class reloading work for you?
>
> Tim
>
> On 26 Apr 2014, at 22:19, Michael Gentry <mg...@masslight.net> wrote:
>
> Hi Tim,
>
> Given the exception:
>
> Caused by:
> java.lang.ClassNotFoundException: javax.sql.Datasource
>
> I'm going to guess you perhaps forgot to include this dependency in the
> POM?
>
>        <dependency>
>            <!-- Used by jetty:run to define JDNI data source -->
>            <groupId>commons-dbcp</groupId>
>            <artifactId>commons-dbcp</artifactId>
>            <version>1.4</version>
>            <scope>runtime</scope>
>        </dependency>
>
> mrg
>
>
> On Fri, Apr 25, 2014 at 6:39 PM, D Tim Cummings <ti...@triptera.com.au>
> wrote:
>
> Thanks Michael.
>
> This is very handy. I downloaded cbe and was able to get it running
> talking to a mysql database by changing the jndi config. Now I am trying to
> retrofit config to my app and I get the following error when I do mvn
> jetty:run. I have all the same dependencies and plugins (plus a few more)
> although some of my versions are more recent.
>
> [INFO] Scanning for projects...
> [INFO]
>
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Tims App 0.0.8
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] >>> jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>
>
> [INFO]
> [INFO] --- maven-cayenne-plugin:3.2M1:cgen (default-cli) @ tims-app ---
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> tims-app ---
> [WARNING] File encoding has not been set, using platform encoding UTF-8,
> i.e. build is platform dependent!
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 33 resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tims-app
> ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:testResources
> (default-testResources) @ tims-app ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory
> /Users/tim/github/tims-app/tims-app/src/test/resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
> tims-app ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] <<< jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
> <<<
> [INFO]
> [INFO] --- jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
> ---
> [INFO] Configuring Jetty for project: Tramanco Vehicle Weigh
> [INFO] Webapp source directory =
> /Users/tim/github/tims-app/tims-app/src/main/webapp
> [INFO] Reload Mechanic: automatic
> [INFO] Classes =
> /Users/tim/github/tims-app/tims-app/target/tims-app/WEB-INF/classes
> [INFO] Added extra scan
> target:/Users/tim/github/tims-app/tims-app/src/main/resources
> [INFO] Context path = /tims-app
> [INFO] Tmp directory = /Users/tim/github/tims-app/tims-app/target/tmp
> [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
> [INFO] Web overrides =  none
> [INFO] web.xml file =
> file:/Users/tim/github/tims-app/tims-app/src/main/webapp/WEB-INF/web.xml
> [INFO] Webapp directory = /Users/tim/github/tims-app//src/main/webapp
> [INFO] Starting jetty 7.5.1.v20110908 ...
> 2014-04-26 08:28:40.142:INFO:oejs.Server:jetty-7.5.1.v20110908
> 2014-04-26 08:28:41.030:INFO:oejpw.PlusConfiguration:No Transaction
> manager found - if your webapp requires one, please configure one.
> 2014-04-26 08:28:41.068:WARN:oejw.WebAppContext:Failed startup of context
>
> o.m.j.p.JettyWebAppContext{/tims-app,file:/Users/tim/github/tims-app/tims-app/src/main/webapp/},file:/Users/tim/github/tims-app/tims-app/src/main/webapp/
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
>
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
> at
>
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
> at
>
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
> at
>
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
> at
>
> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
> at
>
> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
> at
>
> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
> at
>
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
> at
>
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
> at
>
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> at
>
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
>
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> at
>
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> Caused by:
> java.lang.ClassNotFoundException: javax.sql.Datasource
> 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
>
> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
> at
>
> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
> at
>
> org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1323)
> at
>
> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.visitResourceRef(PlusDescriptorProcessor.java:245)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
>
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
> at
>
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
> at
>
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
> at
>
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
> at
>
> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
> at
>
> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
> at
>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
>
> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
> at
>
> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
> at
>
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
> at
>
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
> at
>
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> at
>
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
> at
>
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at
>
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> at
>
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> 2014-04-26 08:28:41.087:INFO:oejs.AbstractConnector:Started
> SelectChannelConnector@0.0.0.0:8088 STARTING
> [INFO] Started Jetty Server
>
>
> On 25 Apr 2014, at 23:43, Michael Gentry <mg...@masslight.net> wrote:
>
> Here is a pom.xml which includes the Jetty plugin:
>
> https://github.com/mrg/cbe/blob/master/WebApplications/pom.xml
>
> And a jetty-env.xml which defines the JNDI lookup:
>
>
>
> https://github.com/mrg/cbe/blob/master/WebApplications/src/main/webapp/WEB-INF/jetty-env.xml
>
>
> mrg
>
>
>
> On Fri, Apr 25, 2014 at 9:40 AM, Michael Gentry <mgentry@masslight.net
>
> 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
>
>
>
>
>
>
>

Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
Hi Michael

Problem was a wrong case on the s in DataSource in my web.xml file 

I had

	<resource-ref>
		<resource-ref-name>jdbc/db_tims</resource-ref-name>
		<res-type>javax.sql.Datasource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>

But I should have had

	<resource-ref>
		<resource-ref-name>jdbc/db_tims</resource-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>

So mvn jetty:run is working now for me. It just doesn't do live class reloading in Tapestry project. Does live class reloading work for you?

Tim

On 26 Apr 2014, at 22:19, Michael Gentry <mg...@masslight.net> wrote:

> Hi Tim,
> 
> Given the exception:
> 
> Caused by:
> java.lang.ClassNotFoundException: javax.sql.Datasource
> 
> I'm going to guess you perhaps forgot to include this dependency in the POM?
> 
>        <dependency>
>            <!-- Used by jetty:run to define JDNI data source -->
>            <groupId>commons-dbcp</groupId>
>            <artifactId>commons-dbcp</artifactId>
>            <version>1.4</version>
>            <scope>runtime</scope>
>        </dependency>
> 
> mrg
> 
> 
> On Fri, Apr 25, 2014 at 6:39 PM, D Tim Cummings <ti...@triptera.com.au> wrote:
> 
>> Thanks Michael.
>> 
>> This is very handy. I downloaded cbe and was able to get it running
>> talking to a mysql database by changing the jndi config. Now I am trying to
>> retrofit config to my app and I get the following error when I do mvn
>> jetty:run. I have all the same dependencies and plugins (plus a few more)
>> although some of my versions are more recent.
>> 
>> [INFO] Scanning for projects...
>> [INFO]
>> 
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Building Tims App 0.0.8
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO]
>> [INFO] >>> jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>>>>> 
>> [INFO]
>> [INFO] --- maven-cayenne-plugin:3.2M1:cgen (default-cli) @ tims-app ---
>> [INFO]
>> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
>> tims-app ---
>> [WARNING] File encoding has not been set, using platform encoding UTF-8,
>> i.e. build is platform dependent!
>> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
>> resources, i.e. build is platform dependent!
>> [INFO] Copying 33 resources
>> [INFO]
>> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tims-app
>> ---
>> [INFO] Nothing to compile - all classes are up to date
>> [INFO]
>> [INFO] --- maven-resources-plugin:2.6:testResources
>> (default-testResources) @ tims-app ---
>> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
>> resources, i.e. build is platform dependent!
>> [INFO] skip non existing resourceDirectory
>> /Users/tim/github/tims-app/tims-app/src/test/resources
>> [INFO]
>> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
>> tims-app ---
>> [INFO] Nothing to compile - all classes are up to date
>> [INFO]
>> [INFO] <<< jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>> <<<
>> [INFO]
>> [INFO] --- jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
>> ---
>> [INFO] Configuring Jetty for project: Tramanco Vehicle Weigh
>> [INFO] Webapp source directory =
>> /Users/tim/github/tims-app/tims-app/src/main/webapp
>> [INFO] Reload Mechanic: automatic
>> [INFO] Classes =
>> /Users/tim/github/tims-app/tims-app/target/tims-app/WEB-INF/classes
>> [INFO] Added extra scan
>> target:/Users/tim/github/tims-app/tims-app/src/main/resources
>> [INFO] Context path = /tims-app
>> [INFO] Tmp directory = /Users/tim/github/tims-app/tims-app/target/tmp
>> [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
>> [INFO] Web overrides =  none
>> [INFO] web.xml file =
>> file:/Users/tim/github/tims-app/tims-app/src/main/webapp/WEB-INF/web.xml
>> [INFO] Webapp directory = /Users/tim/github/tims-app//src/main/webapp
>> [INFO] Starting jetty 7.5.1.v20110908 ...
>> 2014-04-26 08:28:40.142:INFO:oejs.Server:jetty-7.5.1.v20110908
>> 2014-04-26 08:28:41.030:INFO:oejpw.PlusConfiguration:No Transaction
>> manager found - if your webapp requires one, please configure one.
>> 2014-04-26 08:28:41.068:WARN:oejw.WebAppContext:Failed startup of context
>> o.m.j.p.JettyWebAppContext{/tims-app,file:/Users/tim/github/tims-app/tims-app/src/main/webapp/},file:/Users/tim/github/tims-app/tims-app/src/main/webapp/
>> java.lang.reflect.InvocationTargetException
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>> at
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
>> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
>> at
>> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>> at
>> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
>> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
>> at
>> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
>> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
>> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
>> at
>> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
>> at
>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
>> at
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>> at
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>> at
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
>> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>> Caused by:
>> java.lang.ClassNotFoundException: javax.sql.Datasource
>> 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
>> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
>> at
>> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
>> at
>> org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1323)
>> at
>> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.visitResourceRef(PlusDescriptorProcessor.java:245)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>> at
>> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
>> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
>> at
>> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>> at
>> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
>> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
>> at
>> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
>> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
>> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>> at
>> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>> at
>> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
>> at
>> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>> at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
>> at
>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
>> at
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>> at
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>> at
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>> at
>> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
>> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>> at
>> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
>> 2014-04-26 08:28:41.087:INFO:oejs.AbstractConnector:Started
>> SelectChannelConnector@0.0.0.0:8088 STARTING
>> [INFO] Started Jetty Server
>> 
>> 
>> On 25 Apr 2014, at 23:43, Michael Gentry <mg...@masslight.net> wrote:
>> 
>> Here is a pom.xml which includes the Jetty plugin:
>> 
>> https://github.com/mrg/cbe/blob/master/WebApplications/pom.xml
>> 
>> And a jetty-env.xml which defines the JNDI lookup:
>> 
>> 
>> https://github.com/mrg/cbe/blob/master/WebApplications/src/main/webapp/WEB-INF/jetty-env.xml
>> 
>> 
>> mrg
>> 
>> 
>> 
>> On Fri, Apr 25, 2014 at 9:40 AM, Michael Gentry <mgentry@masslight.net
>>> 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
>> 
>> 
>> 
>> 
>> 


Re: How to use JNDI in development

Posted by Michael Gentry <mg...@masslight.net>.
Hi Tim,

Given the exception:

Caused by:
java.lang.ClassNotFoundException: javax.sql.Datasource

I'm going to guess you perhaps forgot to include this dependency in the POM?

        <dependency>
            <!-- Used by jetty:run to define JDNI data source -->
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
            <scope>runtime</scope>
        </dependency>

mrg


On Fri, Apr 25, 2014 at 6:39 PM, D Tim Cummings <ti...@triptera.com.au> wrote:

> Thanks Michael.
>
> This is very handy. I downloaded cbe and was able to get it running
> talking to a mysql database by changing the jndi config. Now I am trying to
> retrofit config to my app and I get the following error when I do mvn
> jetty:run. I have all the same dependencies and plugins (plus a few more)
> although some of my versions are more recent.
>
> [INFO] Scanning for projects...
> [INFO]
>
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Tims App 0.0.8
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> [INFO] >>> jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
> >>>
> [INFO]
> [INFO] --- maven-cayenne-plugin:3.2M1:cgen (default-cli) @ tims-app ---
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @
> tims-app ---
> [WARNING] File encoding has not been set, using platform encoding UTF-8,
> i.e. build is platform dependent!
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] Copying 33 resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tims-app
> ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] --- maven-resources-plugin:2.6:testResources
> (default-testResources) @ tims-app ---
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory
> /Users/tim/github/tims-app/tims-app/src/test/resources
> [INFO]
> [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
> tims-app ---
> [INFO] Nothing to compile - all classes are up to date
> [INFO]
> [INFO] <<< jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
> <<<
> [INFO]
> [INFO] --- jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app
> ---
> [INFO] Configuring Jetty for project: Tramanco Vehicle Weigh
> [INFO] Webapp source directory =
> /Users/tim/github/tims-app/tims-app/src/main/webapp
> [INFO] Reload Mechanic: automatic
> [INFO] Classes =
> /Users/tim/github/tims-app/tims-app/target/tims-app/WEB-INF/classes
> [INFO] Added extra scan
> target:/Users/tim/github/tims-app/tims-app/src/main/resources
> [INFO] Context path = /tims-app
> [INFO] Tmp directory = /Users/tim/github/tims-app/tims-app/target/tmp
> [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
> [INFO] Web overrides =  none
> [INFO] web.xml file =
> file:/Users/tim/github/tims-app/tims-app/src/main/webapp/WEB-INF/web.xml
> [INFO] Webapp directory = /Users/tim/github/tims-app//src/main/webapp
> [INFO] Starting jetty 7.5.1.v20110908 ...
> 2014-04-26 08:28:40.142:INFO:oejs.Server:jetty-7.5.1.v20110908
> 2014-04-26 08:28:41.030:INFO:oejpw.PlusConfiguration:No Transaction
> manager found - if your webapp requires one, please configure one.
> 2014-04-26 08:28:41.068:WARN:oejw.WebAppContext:Failed startup of context
> o.m.j.p.JettyWebAppContext{/tims-app,file:/Users/tim/github/tims-app/tims-app/src/main/webapp/},file:/Users/tim/github/tims-app/tims-app/src/main/webapp/
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>  at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
>  at
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>  at
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
> at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
>  at
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>  at
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
> at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
>  at
> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>  at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>  at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>  at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
>  at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>  at
> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
> at org.eclipse.jetty.server.Server.doStart(Server.java:261)
>  at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>  at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> at
> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
>  at
> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>  at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
> at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
>  at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>  at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>  at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>  at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>  at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
>  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke(Method.java:606)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>  at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>  at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> Caused by:
> java.lang.ClassNotFoundException: javax.sql.Datasource
>  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
> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
>  at
> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
>  at
> org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1323)
> at
> org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.visitResourceRef(PlusDescriptorProcessor.java:245)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke(Method.java:606)
> at
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
>  at
> org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
>  at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
> at
> org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
>  at
> org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
>  at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
> at
> org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
>  at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>  at
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
> at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
>  at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>  at
> org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
> at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>  at
> org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
>  at org.eclipse.jetty.server.Server.doStart(Server.java:261)
> at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
>  at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>  at
> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
> at
> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
>  at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
>  at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
> at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
>  at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>  at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>  at
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>  at
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
> at
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
>  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
>  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
>  at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>  at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
>  at
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>  at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>  at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> 2014-04-26 08:28:41.087:INFO:oejs.AbstractConnector:Started
> SelectChannelConnector@0.0.0.0:8088 STARTING
> [INFO] Started Jetty Server
>
>
> On 25 Apr 2014, at 23:43, Michael Gentry <mg...@masslight.net> wrote:
>
> Here is a pom.xml which includes the Jetty plugin:
>
> https://github.com/mrg/cbe/blob/master/WebApplications/pom.xml
>
> And a jetty-env.xml which defines the JNDI lookup:
>
>
> https://github.com/mrg/cbe/blob/master/WebApplications/src/main/webapp/WEB-INF/jetty-env.xml
>
>
> mrg
>
>
>
> On Fri, Apr 25, 2014 at 9:40 AM, Michael Gentry <mgentry@masslight.net
> >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
>
>
>
>
>

Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks Michael. 

This is very handy. I downloaded cbe and was able to get it running talking to a mysql database by changing the jndi config. Now I am trying to retrofit config to my app and I get the following error when I do mvn jetty:run. I have all the same dependencies and plugins (plus a few more) although some of my versions are more recent.

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Tims App 0.0.8
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app >>>
[INFO] 
[INFO] --- maven-cayenne-plugin:3.2M1:cgen (default-cli) @ tims-app ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tims-app ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 33 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tims-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tims-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/tim/github/tims-app/tims-app/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ tims-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app <<<
[INFO] 
[INFO] --- jetty-maven-plugin:7.5.1.v20110908:run (default-cli) @ tims-app ---
[INFO] Configuring Jetty for project: Tramanco Vehicle Weigh
[INFO] Webapp source directory = /Users/tim/github/tims-app/tims-app/src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = /Users/tim/github/tims-app/tims-app/target/tims-app/WEB-INF/classes
[INFO] Added extra scan target:/Users/tim/github/tims-app/tims-app/src/main/resources
[INFO] Context path = /tims-app
[INFO] Tmp directory = /Users/tim/github/tims-app/tims-app/target/tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = file:/Users/tim/github/tims-app/tims-app/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /Users/tim/github/tims-app//src/main/webapp
[INFO] Starting jetty 7.5.1.v20110908 ...
2014-04-26 08:28:40.142:INFO:oejs.Server:jetty-7.5.1.v20110908
2014-04-26 08:28:41.030:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
2014-04-26 08:28:41.068:WARN:oejw.WebAppContext:Failed startup of context o.m.j.p.JettyWebAppContext{/tims-app,file:/Users/tim/github/tims-app/tims-app/src/main/webapp/},file:/Users/tim/github/tims-app/tims-app/src/main/webapp/
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
	at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
	at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
	at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
	at org.eclipse.jetty.server.Server.doStart(Server.java:261)
	at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
	at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: 
java.lang.ClassNotFoundException: javax.sql.Datasource
	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 org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:415)
	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
	at org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1323)
	at org.eclipse.jetty.plus.webapp.PlusDescriptorProcessor.visitResourceRef(PlusDescriptorProcessor.java:245)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
	at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
	at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:321)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1211)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:589)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
	at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:219)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
	at org.eclipse.jetty.server.Server.doStart(Server.java:261)
	at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:333)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:273)
	at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:548)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
2014-04-26 08:28:41.087:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8088 STARTING
[INFO] Started Jetty Server


On 25 Apr 2014, at 23:43, Michael Gentry <mg...@masslight.net> wrote:

> Here is a pom.xml which includes the Jetty plugin:
> 
> https://github.com/mrg/cbe/blob/master/WebApplications/pom.xml
> 
> And a jetty-env.xml which defines the JNDI lookup:
> 
> https://github.com/mrg/cbe/blob/master/WebApplications/src/main/webapp/WEB-INF/jetty-env.xml
> 
> 
> mrg
> 
> 
> 
> On Fri, Apr 25, 2014 at 9:40 AM, Michael Gentry <mg...@masslight.net>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 <ti...@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
>>> 
>> 
>> 


Re: How to use JNDI in development

Posted by Michael Gentry <mg...@masslight.net>.
Here is a pom.xml which includes the Jetty plugin:

https://github.com/mrg/cbe/blob/master/WebApplications/pom.xml

And a jetty-env.xml which defines the JNDI lookup:

https://github.com/mrg/cbe/blob/master/WebApplications/src/main/webapp/WEB-INF/jetty-env.xml


mrg



On Fri, Apr 25, 2014 at 9:40 AM, Michael Gentry <mg...@masslight.net>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 <ti...@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
>>
>
>

Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
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 <rf...@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 <ti...@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
>>> 
>> 
> 


Re: How to use JNDI in development

Posted by Michael Gentry <mg...@masslight.net>.
That's cool.  I don't recall that being an option when I first used RJR 4-5
years ago.


On Fri, Apr 25, 2014 at 2:16 PM, Richard Frovarp <rf...@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 <ti...@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
>>>
>>>
>>
>

Re: How to use JNDI in development

Posted by Richard Frovarp <rf...@apache.org>.
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 <ti...@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
>>
>


Re: How to use JNDI in development

Posted by Michael Gentry <mg...@masslight.net>.
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 <ti...@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
>

Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
It turns out I can ignore these IllegalArgumentExceptions. I had another error later on which was stopping my app from running in jetty.

Tim


On 26 Apr 2014, at 19:22, D Tim Cummings <ti...@triptera.com.au> wrote:

> I got mvn jetty:run to run. It turned out I had a mistake in my web.xml. In the resource-ref I had res-type javax.sql.Datasource instead of javax.sql.DataSource. This was triggering a ClassNotFound on javax.sql.Datasource
> 
> The problem with mvn jetty:run is it doesn't seem to support Tapestry's live class reloading even though production mode is false. Using RunJettyRun with Andrus's solution does support live class reloading. Using RunJettyRun with JNDI and jetty 7 I get the following errors.
> 
> When my jetty-env.xml tries to configure jndi in (as per Michael's "Cayenne by Example")
> 
> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
> 
> I get 
> 
> 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 18:50:26.242:INFO:oejs.Server:jetty-7.6.2.v20120308
> 
> 
> When I edit jetty-env.xml to be
> 
> <Configure class="org.eclipse.jetty.server.Server">
> 
> I get 
> 
> 2014-04-26 18:53:30.942:INFO:oejs.Server:jetty-7.6.2.v20120308
> 2014-04-26 18:53:31.054:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/tims-app,[file:/Users/tim/github/tims-app/tims-app/src/main/webapp/]}
> java.lang.IllegalArgumentException: Object of class 'org.eclipse.jetty.webapp.WebAppContext' is not of type 'org.eclipse.jetty.server.Server'. 
> 	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:318)
> 	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)
> 
> I noticed also that mvn jetty:run launches jetty 7.5.1.c20110908
> RunJettyRun gives an option to select jetty 7.5.1.v20110908 but when I select it the actual jetty which runs is 7.6.2.v20120308
> 
> (To remove some error messages in RunJettyRun with JNDI I had to add mysql-connector-java-5.1.26.jar, commons-dbcp-1.4.jar and commons-pool-1.5.4.jar to Custom Jetty Classpath.)
> 
> So for now I will use Andrus's suggestion of system properties to bypass JNDI in development, unless someone can advise how to get live class reloading from mvn jetty:run or how to get JNDI working in RunJettyRun.
> 
> Cheers
> 
> Tim
> 
> On 26 Apr 2014, at 10:11, Mike Kienenberger <mk...@gmail.com> wrote:
> 
>> On Fri, Apr 25, 2014 at 7:27 PM, D Tim Cummings <ti...@triptera.com.au> wrote:
>> 
>>> I am certainly finding jetty easier than tomcat in eclipse and once I get more familiar with it I may recommend it for production.  I am a bit concerned at all the different versions of jetty floating around with so many people sticking to old versions. Many people use version 6 while version 9 is recommended by http://www.eclipse.org/jetty. RunJettyRun doesn't have a version 9 option.
>> 
>> Really, once you get the basics of the jetty config file, it's just
>> faster and easier to run jetty directly rather than messing around
>> with the eclipse plugin.   You don't have to worry about the plugin
>> supporting your jetty version or settings.   When you want to upgrade,
>> you just update your user library to contain the new jetty version.
>> 
>> 
>>> Embedded jetty sounds very tempting. I am not sure what the deployment options on Windows are. I can't expect my Windows users to go to the command line, and I don't know enough about Windows to create alternative launch techniques.
>> 
>> Basically, you build a jar file instead of a war/ear file, then you
>> just run it with java -jar myapp.jar.   You'd probably want to set an
>> environment variable to point at your config file or something along
>> those lines.
> 


Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
I got mvn jetty:run to run. It turned out I had a mistake in my web.xml. In the resource-ref I had res-type javax.sql.Datasource instead of javax.sql.DataSource. This was triggering a ClassNotFound on javax.sql.Datasource

The problem with mvn jetty:run is it doesn't seem to support Tapestry's live class reloading even though production mode is false. Using RunJettyRun with Andrus's solution does support live class reloading. Using RunJettyRun with JNDI and jetty 7 I get the following errors.

When my jetty-env.xml tries to configure jndi in (as per Michael's "Cayenne by Example")

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

I get 

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 18:50:26.242:INFO:oejs.Server:jetty-7.6.2.v20120308


When I edit jetty-env.xml to be

<Configure class="org.eclipse.jetty.server.Server">

I get 

2014-04-26 18:53:30.942:INFO:oejs.Server:jetty-7.6.2.v20120308
2014-04-26 18:53:31.054:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/tims-app,[file:/Users/tim/github/tims-app/tims-app/src/main/webapp/]}
java.lang.IllegalArgumentException: Object of class 'org.eclipse.jetty.webapp.WebAppContext' is not of type 'org.eclipse.jetty.server.Server'. 
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:318)
	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)

I noticed also that mvn jetty:run launches jetty 7.5.1.c20110908
RunJettyRun gives an option to select jetty 7.5.1.v20110908 but when I select it the actual jetty which runs is 7.6.2.v20120308

(To remove some error messages in RunJettyRun with JNDI I had to add mysql-connector-java-5.1.26.jar, commons-dbcp-1.4.jar and commons-pool-1.5.4.jar to Custom Jetty Classpath.)

So for now I will use Andrus's suggestion of system properties to bypass JNDI in development, unless someone can advise how to get live class reloading from mvn jetty:run or how to get JNDI working in RunJettyRun.

Cheers

Tim

On 26 Apr 2014, at 10:11, Mike Kienenberger <mk...@gmail.com> wrote:

> On Fri, Apr 25, 2014 at 7:27 PM, D Tim Cummings <ti...@triptera.com.au> wrote:
> 
>> I am certainly finding jetty easier than tomcat in eclipse and once I get more familiar with it I may recommend it for production.  I am a bit concerned at all the different versions of jetty floating around with so many people sticking to old versions. Many people use version 6 while version 9 is recommended by http://www.eclipse.org/jetty. RunJettyRun doesn't have a version 9 option.
> 
> Really, once you get the basics of the jetty config file, it's just
> faster and easier to run jetty directly rather than messing around
> with the eclipse plugin.   You don't have to worry about the plugin
> supporting your jetty version or settings.   When you want to upgrade,
> you just update your user library to contain the new jetty version.
> 
> 
>> Embedded jetty sounds very tempting. I am not sure what the deployment options on Windows are. I can't expect my Windows users to go to the command line, and I don't know enough about Windows to create alternative launch techniques.
> 
> Basically, you build a jar file instead of a war/ear file, then you
> just run it with java -jar myapp.jar.   You'd probably want to set an
> environment variable to point at your config file or something along
> those lines.


Re: How to use JNDI in development

Posted by Mike Kienenberger <mk...@gmail.com>.
On Fri, Apr 25, 2014 at 7:27 PM, D Tim Cummings <ti...@triptera.com.au> wrote:

> I am certainly finding jetty easier than tomcat in eclipse and once I get more familiar with it I may recommend it for production.  I am a bit concerned at all the different versions of jetty floating around with so many people sticking to old versions. Many people use version 6 while version 9 is recommended by http://www.eclipse.org/jetty. RunJettyRun doesn't have a version 9 option.

Really, once you get the basics of the jetty config file, it's just
faster and easier to run jetty directly rather than messing around
with the eclipse plugin.   You don't have to worry about the plugin
supporting your jetty version or settings.   When you want to upgrade,
you just update your user library to contain the new jetty version.


> Embedded jetty sounds very tempting. I am not sure what the deployment options on Windows are. I can't expect my Windows users to go to the command line, and I don't know enough about Windows to create alternative launch techniques.

Basically, you build a jar file instead of a war/ear file, then you
just run it with java -jar myapp.jar.   You'd probably want to set an
environment variable to point at your config file or something along
those lines.

Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks Mike

I am certainly finding jetty easier than tomcat in eclipse and once I get more familiar with it I may recommend it for production.  I am a bit concerned at all the different versions of jetty floating around with so many people sticking to old versions. Many people use version 6 while version 9 is recommended by http://www.eclipse.org/jetty. RunJettyRun doesn't have a version 9 option.

Embedded jetty sounds very tempting. I am not sure what the deployment options on Windows are. I can't expect my Windows users to go to the command line, and I don't know enough about Windows to create alternative launch techniques.

Tim

On 26 Apr 2014, at 0:11, Mike Kienenberger <mk...@gmail.com> wrote:

> I started with Eclipse using Tomcat and Sysdao.  I did this for a year
> or two before switching over to jetty.   At first I used a jetty
> eclipse plugin, but for the last few years, I have switched over to
> just configuring jetty by hand in an xml file, adding jetty to the
> project as user library, and starting each project with a launch
> target.   This has worked great for me, and has also worked well in a
> team environment where people use different versions of jetty, or even
> tomcat with manual deploys inside of eclipse, as each person is free
> to define the web-container environment differently in their version
> of the user library.
> 
> If you have the option, I'd suggest deploying to jetty rather than
> tomcat to keep things simple, but it's not really that important.
> 
> Actually I suggest deploying with no app container (embedded jetty) if
> you have an environment where you can get away with it.
> 
> http://johannesbrodwall.com/2010/03/08/why-and-how-to-use-jetty-in-mission-critical-production/
> 
> As for JNDI, I started with that approach because Cayenne supported
> it, jett supported, tomcat supported, and the various production
> containers used supported it, but my primary client these days has
> switched to reading a config file provided on each host rather than
> JNDI.   I'm actually finding this far easier that figuring out how to
> set up and maintain JNDI for the container-of-the-day, and it's still
> usable when there's no container, such as batch job processes.
> Again, it probably depends on your environment.
> 
> If you'd like additional help setting up Eclipse to run your projects
> with jetty like I do, let me know.   The only issue I've come across
> is that the jetty WebAppClassLoader points to the same to the same
> location as the eclipse classpath, so I had to write a subclass of it
> to stop it from finding two copies of the same file -- certain
> frameworks like JSF don't handle finding two copies of the same
> resource well.   Then I added it to my user library and set it as the
> classloader in my jetty config file.  Might be fixed in newer versions
> of jetty.
> 
> The specific problem you are having with jetty appears to be that you
> haven't added the libs from jetty that deal with JNDI.   Jetty is
> modular, and by default, it ships with a minimal set of supported
> features -- you need to add additional jars if you want to have JSP,
> JNDI, etc, support enabled.
> 
> On Thu, Apr 24, 2014 at 9:38 PM, D Tim Cummings <ti...@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


Re: How to use JNDI in development

Posted by Mike Kienenberger <mk...@gmail.com>.
I started with Eclipse using Tomcat and Sysdao.  I did this for a year
or two before switching over to jetty.   At first I used a jetty
eclipse plugin, but for the last few years, I have switched over to
just configuring jetty by hand in an xml file, adding jetty to the
project as user library, and starting each project with a launch
target.   This has worked great for me, and has also worked well in a
team environment where people use different versions of jetty, or even
tomcat with manual deploys inside of eclipse, as each person is free
to define the web-container environment differently in their version
of the user library.

If you have the option, I'd suggest deploying to jetty rather than
tomcat to keep things simple, but it's not really that important.

Actually I suggest deploying with no app container (embedded jetty) if
you have an environment where you can get away with it.

http://johannesbrodwall.com/2010/03/08/why-and-how-to-use-jetty-in-mission-critical-production/

As for JNDI, I started with that approach because Cayenne supported
it, jett supported, tomcat supported, and the various production
containers used supported it, but my primary client these days has
switched to reading a config file provided on each host rather than
JNDI.   I'm actually finding this far easier that figuring out how to
set up and maintain JNDI for the container-of-the-day, and it's still
usable when there's no container, such as batch job processes.
Again, it probably depends on your environment.

If you'd like additional help setting up Eclipse to run your projects
with jetty like I do, let me know.   The only issue I've come across
is that the jetty WebAppClassLoader points to the same to the same
location as the eclipse classpath, so I had to write a subclass of it
to stop it from finding two copies of the same file -- certain
frameworks like JSF don't handle finding two copies of the same
resource well.   Then I added it to my user library and set it as the
classloader in my jetty config file.  Might be fixed in newer versions
of jetty.

The specific problem you are having with jetty appears to be that you
haven't added the libs from jetty that deal with JNDI.   Jetty is
modular, and by default, it ships with a minimal set of supported
features -- you need to add additional jars if you want to have JSP,
JNDI, etc, support enabled.

On Thu, Apr 24, 2014 at 9:38 PM, D Tim Cummings <ti...@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

Re: How to use JNDI in development

Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks Andrus. This works

On 26 Apr 2014, at 1:59, Andrus Adamchik <an...@objectstyle.org> wrote:

> 
>> I don't necessarily have to solve these problems if you can recommend an alternative way of keeping database config separate to the war.
> 
> Absolutely! Cayenne 3.1 solves this exact problem. You specify JNDI in the mapping, but in development you’d override that with a set of properties with -D. Here is a list of properties:
> 
> http://cayenne.apache.org/docs/3.1/cayenne-guide/configuration-properties.html
> 
> Those that start with “cayenne.jdbc.*” is what you need to define to get yourself a local DataSource without JNDI.
> 
> Andrus
> 
> On Apr 25, 2014, at 4:38 AM, D Tim Cummings <ti...@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
> 


Re: How to use JNDI in development

Posted by Andrus Adamchik <an...@objectstyle.org>.
> I don't necessarily have to solve these problems if you can recommend an alternative way of keeping database config separate to the war.

Absolutely! Cayenne 3.1 solves this exact problem. You specify JNDI in the mapping, but in development you’d override that with a set of properties with -D. Here is a list of properties:

http://cayenne.apache.org/docs/3.1/cayenne-guide/configuration-properties.html

Those that start with “cayenne.jdbc.*” is what you need to define to get yourself a local DataSource without JNDI.

Andrus

On Apr 25, 2014, at 4:38 AM, D Tim Cummings <ti...@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