Quantcast

JBoss 4.2.x and JNDI

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

JBoss 4.2.x and JNDI

Nic Doye
Hi all,

any JBoss users out there who can help me? I think it's just a syntactic thing, but I can not for the love of all that's holy, get my JNDI lookup to work. From my comprehension of the JMX console, WorldofnicDS is set up correctly, but from all my tinkering with DataSource.groovy, jboss-web.xml and web.xml I can't get it right. :-(

I've looked at:

http://www.nabble.com/Problem-with-JBoss-4.2.2-deployment-td16834852.html

and like the author have tried multiple settings. I'm using 4.2.3GA and get the following error

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: jdbc not bound
...
Caused by: javax.naming.NameNotFoundException: jdbc not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)


In /opt/jboss-4.2/server/nic/deploy/postgres-ds.xml, I have a JNDI name of jdbc/WorldofnicDS

<datasources>
  <local-tx-datasource>
    <jndi-name>DefaultDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/bar</connection-url>
....
  </local-tx-datasource>

  <local-tx-datasource>
    <!-- <jndi-name>comp/env/jdbc/WorldofnicDS</jndi-name> -->
    <jndi-name>jdbc/WorldofnicDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/foo</connection-url>
....

In DataSource.groovy

production {
        dataSource {
            dbCreate = "create"
            jndiName = "java:jdbc/WorldofnicDS"
        }
    }

In jboss-web.xml

    <resource-ref>
        <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:jdbc/WorldofnicDS</jndi-name>
    </resource-ref>

and in web.xml

<resource-ref>
            <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
    </resource-ref>
--
http://worldofnic.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JBoss 4.2.x and JNDI

shareme
Hello, a Jboss user here. what is showing in JMX console?

On Sun, Aug 17, 2008 at 3:37 PM, Nicolas Doye <[hidden email]> wrote:
Hi all,

any JBoss users out there who can help me? I think it's just a syntactic thing, but I can not for the love of all that's holy, get my JNDI lookup to work. From my comprehension of the JMX console, WorldofnicDS is set up correctly, but from all my tinkering with DataSource.groovy, jboss-web.xml and web.xml I can't get it right. :-(

I've looked at:

http://www.nabble.com/Problem-with-JBoss-4.2.2-deployment-td16834852.html

and like the author have tried multiple settings. I'm using 4.2.3GA and get the following error

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: jdbc not bound
...
Caused by: javax.naming.NameNotFoundException: jdbc not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)


In /opt/jboss-4.2/server/nic/deploy/postgres-ds.xml, I have a JNDI name of jdbc/WorldofnicDS

<datasources>
  <local-tx-datasource>
    <jndi-name>DefaultDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/bar</connection-url>
....
  </local-tx-datasource>

  <local-tx-datasource>
    <!-- <jndi-name>comp/env/jdbc/WorldofnicDS</jndi-name> -->
    <jndi-name>jdbc/WorldofnicDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/foo</connection-url>
....

In DataSource.groovy

production {
        dataSource {
            dbCreate = "create"
            jndiName = "java:jdbc/WorldofnicDS"
        }
    }

In jboss-web.xml

    <resource-ref>
        <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:jdbc/WorldofnicDS</jndi-name>
    </resource-ref>

and in web.xml

<resource-ref>
            <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
    </resource-ref>
--
http://worldofnic.org



--
Fred Grott
blog: http://www.jroller.com/shareme
friendfeed: http://friendfeed.com/shareme


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JBoss 4.2.x and JNDI

Nic Doye
Ah - small problem, my dev server is in the guest room and I have a guest. Bad time to ask the question! I'll get back to you.

2008/8/18 Fred Grott <[hidden email]>
Hello, a Jboss user here. what is showing in JMX console?


On Sun, Aug 17, 2008 at 3:37 PM, Nicolas Doye <[hidden email]> wrote:
Hi all,

any JBoss users out there who can help me? I think it's just a syntactic thing, but I can not for the love of all that's holy, get my JNDI lookup to work. From my comprehension of the JMX console, WorldofnicDS is set up correctly, but from all my tinkering with DataSource.groovy, jboss-web.xml and web.xml I can't get it right. :-(

I've looked at:

http://www.nabble.com/Problem-with-JBoss-4.2.2-deployment-td16834852.html

and like the author have tried multiple settings. I'm using 4.2.3GA and get the following error

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: jdbc not bound
...
Caused by: javax.naming.NameNotFoundException: jdbc not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)


In /opt/jboss-4.2/server/nic/deploy/postgres-ds.xml, I have a JNDI name of jdbc/WorldofnicDS

<datasources>
  <local-tx-datasource>
    <jndi-name>DefaultDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/bar</connection-url>
....
  </local-tx-datasource>

  <local-tx-datasource>
    <!-- <jndi-name>comp/env/jdbc/WorldofnicDS</jndi-name> -->
    <jndi-name>jdbc/WorldofnicDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/foo</connection-url>
....

In DataSource.groovy

production {
        dataSource {
            dbCreate = "create"
            jndiName = "java:jdbc/WorldofnicDS"
        }
    }

In jboss-web.xml

    <resource-ref>
        <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:jdbc/WorldofnicDS</jndi-name>
    </resource-ref>

and in web.xml

<resource-ref>
            <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
    </resource-ref>
--
http://worldofnic.org



--
Fred Grott
blog: http://www.jroller.com/shareme
friendfeed: http://friendfeed.com/shareme





--
http://worldofnic.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JBoss 4.2.x and JNDI

Nic Doye
Fred et al.,

I _think_ the problem is that my war is being deployed before the datasource is bound? Does that make sense? In that case, I have a pure JBoss issue. :-(

If I grep the output of the startup verbosity from JBoss for my DS, I see

[Lots of lines deleted for sanity[
Caused by: javax.naming.NameNotFoundException: WorldofnicDS not bound
22:09:39,242 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=WorldofnicDS' to JNDI name 'java:WorldofnicDS'

- so it really does look like the binding works - it's just late.


PS. After looking at "JBoss at Work" ... I changed it to:

postgres-ds.xml
<jndi-name>WorldofnicDS</jndi-name>

jboss-web.xml
        <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:/WorldofnicDS</jndi-name>

web.xml
            <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>

Datasource.groovy
jndiName = "java:/WorldofnicDS"

2008/8/18 Nicolas Doye <[hidden email]>
Ah - small problem, my dev server is in the guest room and I have a guest. Bad time to ask the question! I'll get back to you.

2008/8/18 Fred Grott <[hidden email]>

Hello, a Jboss user here. what is showing in JMX console?


On Sun, Aug 17, 2008 at 3:37 PM, Nicolas Doye <[hidden email]> wrote:
Hi all,

any JBoss users out there who can help me? I think it's just a syntactic thing, but I can not for the love of all that's holy, get my JNDI lookup to work. From my comprehension of the JMX console, WorldofnicDS is set up correctly, but from all my tinkering with DataSource.groovy, jboss-web.xml and web.xml I can't get it right. :-(

I've looked at:

http://www.nabble.com/Problem-with-JBoss-4.2.2-deployment-td16834852.html

and like the author have tried multiple settings. I'm using 4.2.3GA and get the following error

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: jdbc not bound
...
Caused by: javax.naming.NameNotFoundException: jdbc not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)


In /opt/jboss-4.2/server/nic/deploy/postgres-ds.xml, I have a JNDI name of jdbc/WorldofnicDS

<datasources>
  <local-tx-datasource>
    <jndi-name>DefaultDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/bar</connection-url>
....
  </local-tx-datasource>

  <local-tx-datasource>
    <!-- <jndi-name>comp/env/jdbc/WorldofnicDS</jndi-name> -->
    <jndi-name>jdbc/WorldofnicDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/foo</connection-url>
....

In DataSource.groovy

production {
        dataSource {
            dbCreate = "create"
            jndiName = "java:jdbc/WorldofnicDS"
        }
    }

In jboss-web.xml

    <resource-ref>
        <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:jdbc/WorldofnicDS</jndi-name>
    </resource-ref>

and in web.xml

<resource-ref>
            <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
    </resource-ref>
--
http://worldofnic.org



--
Fred Grott
blog: http://www.jroller.com/shareme
friendfeed: http://friendfeed.com/shareme





--
http://worldofnic.org



--
http://worldofnic.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JBoss 4.2.x and JNDI

Nic Doye
OK all - it does appear to be a problem with deployment order on JBoss.

I followed the instructions at http://wiki.jboss.org/wiki/RedeployFromTheJMXConsole and redeployed the war file and it's all hunky dory.

Weird.

Now looking at the deployment order in server/<mumble>/conf/xmdesc/org.jboss.deployment.MainDeployer-xmbean.xml

we can see the -ds.xml is deployed befor .war, but it clearly isn't waiting for the datasource binding to finish.


2008/8/19 Nicolas Doye <[hidden email]>
Fred et al.,

I _think_ the problem is that my war is being deployed before the datasource is bound? Does that make sense? In that case, I have a pure JBoss issue. :-(

If I grep the output of the startup verbosity from JBoss for my DS, I see

[Lots of lines deleted for sanity[
Caused by: javax.naming.NameNotFoundException: WorldofnicDS not bound
22:09:39,242 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=WorldofnicDS' to JNDI name 'java:WorldofnicDS'

- so it really does look like the binding works - it's just late.


PS. After looking at "JBoss at Work" ... I changed it to:

postgres-ds.xml
<jndi-name>WorldofnicDS</jndi-name>

jboss-web.xml

        <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:/WorldofnicDS</jndi-name>

web.xml

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

Datasource.groovy
jndiName = "java:/WorldofnicDS"

2008/8/18 Nicolas Doye <[hidden email]>

Ah - small problem, my dev server is in the guest room and I have a guest. Bad time to ask the question! I'll get back to you.

2008/8/18 Fred Grott <[hidden email]>

Hello, a Jboss user here. what is showing in JMX console?


On Sun, Aug 17, 2008 at 3:37 PM, Nicolas Doye <[hidden email]> wrote:
Hi all,

any JBoss users out there who can help me? I think it's just a syntactic thing, but I can not for the love of all that's holy, get my JNDI lookup to work. From my comprehension of the JMX console, WorldofnicDS is set up correctly, but from all my tinkering with DataSource.groovy, jboss-web.xml and web.xml I can't get it right. :-(

I've looked at:

http://www.nabble.com/Problem-with-JBoss-4.2.2-deployment-td16834852.html

and like the author have tried multiple settings. I'm using 4.2.3GA and get the following error

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: jdbc not bound
...
Caused by: javax.naming.NameNotFoundException: jdbc not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)


In /opt/jboss-4.2/server/nic/deploy/postgres-ds.xml, I have a JNDI name of jdbc/WorldofnicDS

<datasources>
  <local-tx-datasource>
    <jndi-name>DefaultDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/bar</connection-url>
....
  </local-tx-datasource>

  <local-tx-datasource>
    <!-- <jndi-name>comp/env/jdbc/WorldofnicDS</jndi-name> -->
    <jndi-name>jdbc/WorldofnicDS</jndi-name>
    <connection-url>jdbc:postgresql://127.0.0.1:5432/foo</connection-url>
....

In DataSource.groovy

production {
        dataSource {
            dbCreate = "create"
            jndiName = "java:jdbc/WorldofnicDS"
        }
    }

In jboss-web.xml

    <resource-ref>
        <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:jdbc/WorldofnicDS</jndi-name>
    </resource-ref>

and in web.xml

<resource-ref>
            <res-ref-name>jdbc/WorldofnicDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
    </resource-ref>
--
http://worldofnic.org



--
Fred Grott
blog: http://www.jroller.com/shareme
friendfeed: http://friendfeed.com/shareme





--
http://worldofnic.org



--
http://worldofnic.org



--
http://worldofnic.org
Loading...