cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: How to use JNDI in development
Date Fri, 25 Apr 2014 14:11:12 GMT
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 <tim@triptera.com.au> wrote:
> Hi
>
> I am using cayenne in a tapestry project and my final deployment will be in
> Tomcat 7 using JNDI for defining the data source. I am developing in Eclipse
> 4.3.1 and would like my development environment to be as close to deployment
> as possible. What is the recommended way of using JNDI in development.
>
> I have tried the instructions on
>
> http://tynamo.org/Developing+with+Tomcat+and+Eclipse
>
> using sysdeo tomcat plugin for eclipse. I haven't been able to get it to
> read the jndi information.
>
> Apr 25, 2014 11:25:40 AM org.apache.catalina.deploy.NamingResources
> addResource
> WARNING: Failed to create MBean for naming resource [null]
>
> I have tried using RunJettyRun but get.
>
> Exception happened when loading Jetty.xml:
> java.lang.ClassNotFoundException: org.eclipse.jetty.plus.jndi.Resource
>
>
> RunJettyRun works great when I configure cayenne-project.xml to
> XMLPoolingDataSourceFactory but I don't want to have to keep switching
> between this and JNDI when ready to deploy. I would also prefer to use
> tomcat in dev so it is same as prod.
>
> JNDI works great when I build a war file and deploy to tomcat but that would
> slow my development if I had to do that every time.
>
> I don't necessarily have to solve these problems if you can recommend an
> alternative way of keeping database config separate to the war. The war will
> be deployed by unskilled users on Windows and skilled users on Linux and Mac
> so I am trying to keep the steps to deploy simple and not hard code absolute
> paths of properties files into my app.
>
> Thanks
>
> Tim

Mime
View raw message