This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Injection Issue in standalone jar

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a standalone executable jar which uses spring injection through test1-context.xml. The dependency code is as below:

<bean id="TestDAO" class="com.test.dao.TestDAO">
<property name="dbResourceHandler"><ref bean="dbResourceHandler" /></property>
</bean>

here dbResourceHandler is the injected bean property, which lies in a different jar file. I have the dbUtils.jar in my classpath and i import context file using the below text:

<import resource="classpath*:com/**/resource-context.xml"/>

The entry of the dbResourceHandler in dbUtil jar is as below:

<bean id="dbResourceHandler" class="com.test.dbutils.DBResourceHandler">
<property name="dataSourceUK"><ref bean="dataSourceUK" /></property>
</bean>

It seems that the dbResourceHandler is not being injected properly and the code gives error:

ClassCastException: com.test.dbutils.DBResourceHandler not found.

Regards,
Paresh
 
paresh doshi
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the exact error message:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TestDAO' defined in class path resource [com/test/test1-context.xml]: Cannot resolve reference to bean 'dbResourceHandler' while setting bean property 'dbResourceHandler'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dbResourceHandler' is defined
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!