Search code examples
springweb-applicationswebspherejndi

Spring Error: org.springframework.beans.factory.BeanCreationException


I have a web application which I am exporting as EAR and trying to deploy on Websphere 6.1 application server.

The deployment goes fine. Even, the index page loads fine which is a login screen.

However, on entering credentials and hitting enter, the next page does not load and HTTP 500 Internal Server Error is thrown.

The next page which gets loaded is a JSP having a country drop down, whose values gets fetched from database via hibernate.

I have Datasource created in Websphere with all details and even test connection succeeds.

However, I get the below error on checking the server System.out logs:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds': 
Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: 
Context: uschwasvmdev04Cell01/clusters/URMDUS, name: jdbc/mydbXA: First component in name 
mydbXA not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: 
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]

The description of NameNotFoundException says:

"This exception is thrown when a component of the name cannot be resolved because it is not bound. "

JNDI Lookup in my services.xml also seems fine:

<jee:jndi-lookup id="ds" jndi-name="jdbc/mydbXA" resource-ref="true" />

What am I missing here ?

Thanks for reading!


Solution

  • You are using resource-ref="true". Have you created the according resource-reference in your web.xml and did you map the DataSource to the application?

    If you set it to false you can do a global lookup. Otherwise you have to configure it.