Vicky
Vicky

Reputation: 17375

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!

Upvotes: 0

Views: 5620

Answers (2)

jbbarquero
jbbarquero

Reputation: 2842

It's funny, but I've done the opposite: I created the resource-reference but I forget to tell Spring to use it.

Just in case, in the namespace it's done as you can see above: resource-ref="true"

If you're configuring your beans manually:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="jdbc/database" /> 
      <property name="resourceRef" value="true" /><!-- It's false by default -->
</bean>

Upvotes: 0

Udo Held
Udo Held

Reputation: 12538

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.

Upvotes: 3

Related Questions