This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Spring and the fly likes Injection Issue in standalone jar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Reply Bookmark "Injection Issue in standalone jar" Watch "Injection Issue in standalone jar" New topic
Author

Injection Issue in standalone jar

paresh doshi
Ranch Hand

Joined: Nov 20, 2006
Posts: 81
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

Thanks.<br />Paresh Doshi<br />SCJP 1.4
paresh doshi
Ranch Hand

Joined: Nov 20, 2006
Posts: 81
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Injection Issue in standalone jar
 
Similar Threads
Properties Setting of Spring beans
MDB deployed in WebLogic and Queues in IBM MQ
Unable to get Inject object thru Spring in WL 8.1.5
Injecting a Dependency through Spring
JMXConnectorFactory.connect