org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pmsDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'jdbc/pmsDataSource'

Spring JIRA | David Harrigan | 9 years ago
  1. 0

    Hi, I've found something very bizarre (probably my lack of understanding, but let's see..) I've posted a mailing list question on the jetty support mail list. Here's the reference: http://www.nabble.com/JNDI-Lookups-%2B-Spring-td16048065.html But for completeness, I'll C+P here: Hi (again!) Well, here's the jip, I don't know if I should report this here on in spring...so I'll do both :-) Spring 2.5.2 Jetty 6.1.8 Java 1.5 update 6 JEE5 I have this jetty-env.xml in my WEB-INF dir (I've removed the tag braces since nabble fubars up the look) Configure class="org.mortbay.jetty.webapp.WebAppContext" New id="pmsDataSource" class="org.mortbay.jetty.plus.naming.Resource" Arg jdbc/pmsDataSource Arg Arg New class="org.apache.commons.dbcp.BasicDataSource" Set name="driverClassName">org.postgresql.Driver Set Set name="url">jdbc:postgresql://production-db/reports Set Set name="username">fu Set Set name="password">bar Set New Arg New Configure I've got this configured in my spring applicationContext.xml jee:jndi-lookup id="pmsDataSource" jndi-name="jdbc/pmsDataSource" If I switch on -DDEBUG for Jetty, I get these lines: 2008-03-14 11:54:15.595::DEBUG: parse: file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/jetty-env.xml 2008-03-14 11:54:15.595::DEBUG: parsing: sid=file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/jetty-env.xml,pid=null So far so good (it's found the jetty-env.xml file), continuing onwards....more debug trace from jetty... 2008-03-14 11:54:15.626::DEBUG: >>> new root context requested 2008-03-14 11:54:15.626::DEBUG: Looking up name="comp/env" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for comp for context=null 2008-03-14 11:54:15.626::DEBUG: Using classloader of current org.mortbay.jetty.handler.ContextHandler 2008-03-14 11:54:15.626::DEBUG: Looking up name="env" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for env for context=comp 2008-03-14 11:54:15.626::DEBUG: Looking up name="org.mortbay.jetty.plus.naming.Resource" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for org.mortbay.jetty.plus.naming.Resource for context=env 2008-03-14 11:54:15.626::DEBUG: Looking up binding for org.mortbay.jetty.plus.naming.Resource for context=env 2008-03-14 11:54:15.626::DEBUG: Adding binding with key=org.mortbay.jetty.plus.naming.Resource obj=org.mortbay.naming.NamingContext@10655dd for context=env 2008-03-14 11:54:15.626::DEBUG: Subcontext org.mortbay.jetty.plus.naming.Resource created 2008-03-14 11:54:15.626::DEBUG: Looking up name="jdbc" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for jdbc for context=org.mortbay.jetty.plus.naming.Resource 2008-03-14 11:54:15.626::DEBUG: Looking up binding for jdbc for context=org.mortbay.jetty.plus.naming.Resource 2008-03-14 11:54:15.626::DEBUG: Adding binding with key=jdbc obj=org.mortbay.naming.NamingContext@ef5502 for context=org.mortbay.jetty.plus.naming.Resource 2008-03-14 11:54:15.641::DEBUG: Subcontext jdbc created 2008-03-14 11:54:15.641::DEBUG: Adding binding with key=pmsDataSource obj=org.mortbay.jetty.plus.naming.Resource@b61fd1 for context=jdbc 2008-03-14 11:54:15.641::DEBUG: Bound object to pmsDataSource 2008-03-14 11:54:15.641::DEBUG: Bound java:comp/env/org.mortbay.jetty.plus.naming.Resource/jdbc/pmsDataSource 2008-03-14 11:54:15.641::DEBUG: Looking up name="jdbc" 2008-03-14 11:54:15.641::DEBUG: Looking up binding for jdbc for context=env 2008-03-14 11:54:15.641::DEBUG: Looking up binding for jdbc for context=env 2008-03-14 11:54:15.641::DEBUG: Adding binding with key=jdbc obj=org.mortbay.naming.NamingContext@e2dae9 for context=env 2008-03-14 11:54:15.641::DEBUG: Subcontext jdbc created 2008-03-14 11:54:15.641::DEBUG: Adding binding with key=pmsDataSource obj=org.apache.commons.dbcp.BasicDataSource@13c1b02 for context=jdbc 2008-03-14 11:54:15.641::DEBUG: Bound object to pmsDataSource 2008-03-14 11:54:15.641::DEBUG: Bound java:comp/env/jdbc/pmsDataSource 2008-03-14 11:54:15.641::DEBUG: parse: file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/web.xml 2008-03-14 11:54:15.641::DEBUG: parsing: sid=file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/web.xml,pid=null 2008-03-14 11:54:16.720::DEBUG: loaded interface javax.servlet.ServletContextListener Notice that according to Jetty, it's bound a JNDI reference jdbc/pmsDataSource, so, all good so far! However, shortly after Spring decides to complain when it tries to boot up: 2008-03-14 11:54:19,263 [main] ERROR (ContextLoader:214:initWebApplicationContext) - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pmsDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'jdbc/pmsDataSource' at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404) at java.security.AccessController.doPrivileged(Native Method) You can see that Spring is upset. Note, that I've followed the example in the Spring docs, i.e: http://static.springframework.org/spring/docs/2.5.x/reference/xsd-config.html#xsd-config-body-schemas-jee-jndi-lookup section A.2.3.1. (look at the way the jdbc datasource is bound) Now, If I change the spring applicationContext bean definition to: jee:jndi-lookup id="pmsDataSource" jndi-name="java:comp/env/jdbc/pmsDataSource" It works. It finds the JNDI reference. Now, I don't know what is going on...is it spring or is it jetty? TIA :) -=david=-

    Spring JIRA | 9 years ago | David Harrigan
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pmsDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'jdbc/pmsDataSource'
  2. 0

    Hi, I've found something very bizarre (probably my lack of understanding, but let's see..) I've posted a mailing list question on the jetty support mail list. Here's the reference: http://www.nabble.com/JNDI-Lookups-%2B-Spring-td16048065.html But for completeness, I'll C+P here: Hi (again!) Well, here's the jip, I don't know if I should report this here on in spring...so I'll do both :-) Spring 2.5.2 Jetty 6.1.8 Java 1.5 update 6 JEE5 I have this jetty-env.xml in my WEB-INF dir (I've removed the tag braces since nabble fubars up the look) Configure class="org.mortbay.jetty.webapp.WebAppContext" New id="pmsDataSource" class="org.mortbay.jetty.plus.naming.Resource" Arg jdbc/pmsDataSource Arg Arg New class="org.apache.commons.dbcp.BasicDataSource" Set name="driverClassName">org.postgresql.Driver Set Set name="url">jdbc:postgresql://production-db/reports Set Set name="username">fu Set Set name="password">bar Set New Arg New Configure I've got this configured in my spring applicationContext.xml jee:jndi-lookup id="pmsDataSource" jndi-name="jdbc/pmsDataSource" If I switch on -DDEBUG for Jetty, I get these lines: 2008-03-14 11:54:15.595::DEBUG: parse: file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/jetty-env.xml 2008-03-14 11:54:15.595::DEBUG: parsing: sid=file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/jetty-env.xml,pid=null So far so good (it's found the jetty-env.xml file), continuing onwards....more debug trace from jetty... 2008-03-14 11:54:15.626::DEBUG: >>> new root context requested 2008-03-14 11:54:15.626::DEBUG: Looking up name="comp/env" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for comp for context=null 2008-03-14 11:54:15.626::DEBUG: Using classloader of current org.mortbay.jetty.handler.ContextHandler 2008-03-14 11:54:15.626::DEBUG: Looking up name="env" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for env for context=comp 2008-03-14 11:54:15.626::DEBUG: Looking up name="org.mortbay.jetty.plus.naming.Resource" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for org.mortbay.jetty.plus.naming.Resource for context=env 2008-03-14 11:54:15.626::DEBUG: Looking up binding for org.mortbay.jetty.plus.naming.Resource for context=env 2008-03-14 11:54:15.626::DEBUG: Adding binding with key=org.mortbay.jetty.plus.naming.Resource obj=org.mortbay.naming.NamingContext@10655dd for context=env 2008-03-14 11:54:15.626::DEBUG: Subcontext org.mortbay.jetty.plus.naming.Resource created 2008-03-14 11:54:15.626::DEBUG: Looking up name="jdbc" 2008-03-14 11:54:15.626::DEBUG: Looking up binding for jdbc for context=org.mortbay.jetty.plus.naming.Resource 2008-03-14 11:54:15.626::DEBUG: Looking up binding for jdbc for context=org.mortbay.jetty.plus.naming.Resource 2008-03-14 11:54:15.626::DEBUG: Adding binding with key=jdbc obj=org.mortbay.naming.NamingContext@ef5502 for context=org.mortbay.jetty.plus.naming.Resource 2008-03-14 11:54:15.641::DEBUG: Subcontext jdbc created 2008-03-14 11:54:15.641::DEBUG: Adding binding with key=pmsDataSource obj=org.mortbay.jetty.plus.naming.Resource@b61fd1 for context=jdbc 2008-03-14 11:54:15.641::DEBUG: Bound object to pmsDataSource 2008-03-14 11:54:15.641::DEBUG: Bound java:comp/env/org.mortbay.jetty.plus.naming.Resource/jdbc/pmsDataSource 2008-03-14 11:54:15.641::DEBUG: Looking up name="jdbc" 2008-03-14 11:54:15.641::DEBUG: Looking up binding for jdbc for context=env 2008-03-14 11:54:15.641::DEBUG: Looking up binding for jdbc for context=env 2008-03-14 11:54:15.641::DEBUG: Adding binding with key=jdbc obj=org.mortbay.naming.NamingContext@e2dae9 for context=env 2008-03-14 11:54:15.641::DEBUG: Subcontext jdbc created 2008-03-14 11:54:15.641::DEBUG: Adding binding with key=pmsDataSource obj=org.apache.commons.dbcp.BasicDataSource@13c1b02 for context=jdbc 2008-03-14 11:54:15.641::DEBUG: Bound object to pmsDataSource 2008-03-14 11:54:15.641::DEBUG: Bound java:comp/env/jdbc/pmsDataSource 2008-03-14 11:54:15.641::DEBUG: parse: file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/web.xml 2008-03-14 11:54:15.641::DEBUG: parsing: sid=file:/C:/javastuff/jetty-6.1.8/webapps/root/WEB-INF/web.xml,pid=null 2008-03-14 11:54:16.720::DEBUG: loaded interface javax.servlet.ServletContextListener Notice that according to Jetty, it's bound a JNDI reference jdbc/pmsDataSource, so, all good so far! However, shortly after Spring decides to complain when it tries to boot up: 2008-03-14 11:54:19,263 [main] ERROR (ContextLoader:214:initWebApplicationContext) - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pmsDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'jdbc/pmsDataSource' at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404) at java.security.AccessController.doPrivileged(Native Method) You can see that Spring is upset. Note, that I've followed the example in the Spring docs, i.e: http://static.springframework.org/spring/docs/2.5.x/reference/xsd-config.html#xsd-config-body-schemas-jee-jndi-lookup section A.2.3.1. (look at the way the jdbc datasource is bound) Now, If I change the spring applicationContext bean definition to: jee:jndi-lookup id="pmsDataSource" jndi-name="java:comp/env/jdbc/pmsDataSource" It works. It finds the JNDI reference. Now, I don't know what is going on...is it spring or is it jetty? TIA :) -=david=-

    Spring JIRA | 9 years ago | David Harrigan
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pmsDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'jdbc/pmsDataSource'
  3. 0

    Salmon Run: Workflow Reloaded : Moving to OSWorkflow

    blogspot.com | 9 months ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workflowFactory' defined in class path resource [workflow.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: com.opensymphony.workflow.InvalidWorkflowDescriptorException: Error in workflow config: root cause: Connection timed out: connect
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    WSDL generation issue with import on WLS - Spring Forum

    spring.io | 7 months ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schemas' defined in class path resource [endpoints.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: org.apache.ws.commons.schema.XmlSchemaException: C:\Code\trunk\elements\QuizElements.xsd (The system cannot find the path specified)
  6. 0

    Spring Hibernate Mapping Issue

    Stack Overflow | 3 years ago | Diode
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [database/hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: org.e.models.Annotation

    25 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.beans.factory.BeanCreationException

      Error creating bean with name 'pmsDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException; remaining name 'jdbc/pmsDataSource'

      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean()
    2. Spring Beans
      AbstractAutowireCapableBeanFactory$1.run
      1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302)
      2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
      3. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
      3 frames
    3. Java RT
      AccessController.doPrivileged
      1. java.security.AccessController.doPrivileged(Native Method)
      1 frame