The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Nic Doye
I know that oodles of kind people have put Grails/Tomcat/JNDI howtos
on the web now, but I _still_ have problems with this.

Here's the guide (for Grails 1.1.1) that I've followed:

http://refactor.com.au/blog/idiots-guide-tomcat-6-grails-jndi-datasource

I think my major deviations (apart from using PostgreSQL on RHEL) are
that I just have <Context reloadable="true"> in the individual context
files in /opt/apache-tomcat-6.0.20/conf/Catalina/localhost (tomcat
uses the name of the context file to work out the associated webapp).

Now I know that JNDI is working on the server as I have super-simple
apps that can talk to the DB, but I'm desperate to use grails. (This
latest app only took 2 days to write, and I want to prove to all and
sundry how quick and easy grails is).

(As a separate point, does anyone how to "SET search_path TO
myschema;" in Tomcat JNDI? I can do it JBoss, but getting grails and
JBoss 5 working is like hitting yourself with two bricks at the same
time).

--
http://worldofnic.org

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

eyck.jentzsch
Nicolas Doye schrieb:

> I know that oodles of kind people have put Grails/Tomcat/JNDI howtos
> on the web now, but I _still_ have problems with this.
>
> Here's the guide (for Grails 1.1.1) that I've followed:
>
> http://refactor.com.au/blog/idiots-guide-tomcat-6-grails-jndi-datasource
>
> I think my major deviations (apart from using PostgreSQL on RHEL) are
> that I just have <Context reloadable="true"> in the individual context
> files in /opt/apache-tomcat-6.0.20/conf/Catalina/localhost (tomcat
> uses the name of the context file to work out the associated webapp).
>
> Now I know that JNDI is working on the server as I have super-simple
> apps that can talk to the DB, but I'm desperate to use grails. (This
> latest app only took 2 days to write, and I want to prove to all and
> sundry how quick and easy grails is).
>
> (As a separate point, does anyone how to "SET search_path TO
> myschema;" in Tomcat JNDI? I can do it JBoss, but getting grails and
> JBoss 5 working is like hitting yourself with two bricks at the same
> time).
>
> --
> http://worldofnic.org
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>  
And what are the problems?
-Eyck

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Marc Palmer Local
In reply to this post by Nic Doye

On 26 Jan 2010, at 18:32, Nicolas Doye wrote:

> I know that oodles of kind people have put Grails/Tomcat/JNDI howtos
> on the web now, but I _still_ have problems with this.
>
> Here's the guide (for Grails 1.1.1) that I've followed:
>
> http://refactor.com.au/blog/idiots-guide-tomcat-6-grails-jndi-datasource
>
> I think my major deviations (apart from using PostgreSQL on RHEL) are
> that I just have <Context reloadable="true"> in the individual context
> files in /opt/apache-tomcat-6.0.20/conf/Catalina/localhost (tomcat
> uses the name of the context file to work out the associated webapp).

I know this isn't really going to help, but from a philosophical standpoint it might in time...

I used to battle with this stuff myself, and now I pay somebody else (not very much considering) to do this crap. Life is just TOO SHORT. Get someone else to solve these problems for you. We use contegix managed boxes and while I wince sometimes at the price I shouldn't because for the amount they get paid for the management part, they will do pretty much anything for you.

I am not affiliated to Contegix in any way, I'm just vouching for any good managed services. (Formerly used Rackspace for sites but their managed services, as we experienced them, were pretty minimal).

Before you say "but I don't have the money to spend on it", be honest and add up the time you spend on these horrible admin tasks and cost it up based on what your time is worth!

Even if you're being paid a salary to do this stuff, its usually not an efficient use of the company's money or staff to wrestle with these things.

$0.02

Marc
~ ~ ~
Marc Palmer
Blog         > http://www.anyware.co.uk
Twitter      > http://twitter.com/wangjammer5
Grails Rocks > http://www.grailsrocks.com







---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Cochran, Keith
I second that.  I use Congetix too, and I'm not a paid spokesperson, but
they do save me lots of headaches.

-Keith

-----Original Message-----
From: Marc Palmer [mailto:[hidden email]]
Sent: Tuesday, January 26, 2010 4:25 PM
To: [hidden email]
Subject: Re: [grails-user] The eternal struggle: Tomcat 6, JNDI and
Grails (1.2)


On 26 Jan 2010, at 18:32, Nicolas Doye wrote:

> I know that oodles of kind people have put Grails/Tomcat/JNDI howtos
> on the web now, but I _still_ have problems with this.
>
> Here's the guide (for Grails 1.1.1) that I've followed:
>
>
http://refactor.com.au/blog/idiots-guide-tomcat-6-grails-jndi-datasource
>
> I think my major deviations (apart from using PostgreSQL on RHEL) are
> that I just have <Context reloadable="true"> in the individual context
> files in /opt/apache-tomcat-6.0.20/conf/Catalina/localhost (tomcat
> uses the name of the context file to work out the associated webapp).

I know this isn't really going to help, but from a philosophical
standpoint it might in time...

I used to battle with this stuff myself, and now I pay somebody else
(not very much considering) to do this crap. Life is just TOO SHORT. Get
someone else to solve these problems for you. We use contegix managed
boxes and while I wince sometimes at the price I shouldn't because for
the amount they get paid for the management part, they will do pretty
much anything for you.

I am not affiliated to Contegix in any way, I'm just vouching for any
good managed services. (Formerly used Rackspace for sites but their
managed services, as we experienced them, were pretty minimal).

Before you say "but I don't have the money to spend on it", be honest
and add up the time you spend on these horrible admin tasks and cost it
up based on what your time is worth!

Even if you're being paid a salary to do this stuff, its usually not an
efficient use of the company's money or staff to wrestle with these
things.

$0.02

Marc
~ ~ ~
Marc Palmer
Blog         > http://www.anyware.co.uk
Twitter      > http://twitter.com/wangjammer5
Grails Rocks > http://www.grailsrocks.com







---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Nic Doye
Unfortunately this is an internal project at my employer, but in a
part of the network that doesn't have complete "buy-in" from all
departments yet. (This sounds stupid and is stupid, but I'm stuck with
it).

As grails and tomcat are both heavily supported/funded by
SpringSource, I naïvely assumed that Tomcat would be the easiest path
to glory and a well trodden path by millions of (or at least, several)
other users. ;-)

So here's the full information that Eyck asked for.

I'd appreciate any help anyone can offer.

# cat /opt/apache-tomcat-6.0.20/conf/Catalina/localhost/datafill-upload.xml
<Context reloadable="true">
    <Resource name="jdbc/NemsDB"
                auth="Container"
                type="javax.sql.DataSource"
                driverClassName="org.postgresql.Driver"
                url="jdbc:postgresql://x.x.x.x/xxx"
                username="XXXX"
                password="XXXX"
                maxActive="100"
                maxIdle="10"
                maxWait="-1"
    />
 </Context>

Bit of web.xml (doesn't seem to matter if this in there or not):

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

DataSource.groovy: production segment (although, I do note I _still_
have the default dataSource settings at the top of the file):

        production {
                dataSource {
                        pooled = false
                        dbCreate = "create"
                        jndiName = "jdbc/NemsDB"
                }
        }

Everyone's favourite: a stack trace:

27-Jan-2010 09:58:06 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener
instance of class
org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'messageSource': Initialization of bean
failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager': Cannot resolve reference
to bean 'sessionFactory' while setting bean property 'sessionFactory';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Cannot resolve reference to
bean 'dataSource' while setting bean property 'dataSource'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'transactionManager': Cannot resolve
reference to bean 'sessionFactory' while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Cannot resolve reference to
bean 'dataSource' while setting bean property 'dataSource'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        ... 1 more
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory': Cannot resolve
reference to bean 'dataSource' while setting bean property
'dataSource'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        ... 1 more
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        ... 1 more
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound
in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        ... 1 more
27-Jan-2010 09:58:06 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
27-Jan-2010 09:58:06 org.apache.catalina.core.StandardContext start
SEVERE: Context [/datafill-upload] startup failed due to previous errors
27-Jan-2010 09:58:06 org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance
of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'messageSource': Initialization of bean
failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager': Cannot resolve reference
to bean 'sessionFactory' while setting bean property 'sessionFactory';
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Cannot resolve reference to
bean 'dataSource' while setting bean property 'dataSource'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'transactionManager': Cannot resolve
reference to bean 'sessionFactory' while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory': Cannot resolve reference to
bean 'dataSource' while setting bean property 'dataSource'; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        ... 1 more
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory': Cannot resolve
reference to bean 'dataSource' while setting bean property
'dataSource'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        ... 1 more
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource': Invocation of init method
failed; nested exception is javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
        ... 1 more
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound
in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        ... 1 more

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Ian Roberts
Nicolas Doye wrote:
> production {
> dataSource {
> pooled = false
> dbCreate = "create"
> jndiName = "jdbc/NemsDB"
> }
> }

Maybe it needs the java:comp/env prefix, i.e. jndiName =
"java:comp/env/jdbc/NemsDB" - I remember reading somewhere that that was
needed with Tomcat but not with Jetty or something (I may be
mis-remembering but it's worth a try).

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

cazacugmihai
In reply to this post by Nic Doye
Use:

jndiName = "java:comp/env/jdbc/NemsDB"

Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Nic Doye
Thank you Ian and Mihai, I'm now definitely able to talk to Postgres
(but it's moaning for another reason - damn our overzealous PG admin).

2010/1/27 Mihai Cazacu <[hidden email]>:
> Use:
>
> jndiName = "java:comp/env/jdbc/NemsDB"
>
>



--
http://worldofnic.org

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Nic Doye
I now have my app successfully deployed. By the close of play today I
shall have 2 grails apps deployed on this box. Thank you ever so much
for your help

nic

2010/1/27 Nicolas Doye <[hidden email]>:

> Thank you Ian and Mihai, I'm now definitely able to talk to Postgres
> (but it's moaning for another reason - damn our overzealous PG admin).
>
> 2010/1/27 Mihai Cazacu <[hidden email]>:
>> Use:
>>
>> jndiName = "java:comp/env/jdbc/NemsDB"
>>
>>
>
>
>
> --
> http://worldofnic.org
>



--
http://worldofnic.org

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: The eternal struggle: Tomcat 6, JNDI and Grails (1.2)

Milind Patil
In reply to this post by Nic Doye
In my case, the database is on MS SQL Server on one server. The password for the MS SQL Server user had been expired, hence not able to connect to database from other server. Reset the password for user on MS SQL Server on first server and updating context.xml on Apache Tomcat on other server lead to resolve the issue.