I am having problem getting the bean reference (which is in jar file) in
JSP.
Everything works fine when I am running from RAD Locally but when I am porting to UNIX box
test server it fails to get bean reference.
I am trying to get reference of bean/java class which is in the jar file from JSP page.
Error is - Unable to return specified BeanFactory instance: factory key [my-factory], from group with resource name [classpath*:beanRefFactory.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'my-Bean' is define
Setup
-------
JSP calling methodA() of class Test which is in the jar file.
Code in JSP
try
{
BeanFactoryLocator beanFactoryLocator = SingletonBeanFactoryLocator.getInstance();
BeanFactoryReference beanFactoryReference = beanFactoryLocator.useBeanFactory("my-factory"); //*** HERE IS ERROR
bean = beanFactoryReference.getFactory().getBean("my-Bean");
}
catch(Throwable throwable)
{
System.out.println("\n\nProbem initializing BeanFactory : " + throwable.getMessage());
throwable.printStackTrace();
}
And structure of jar file which is in WEB-INF/lib
test.jar
beanRefFactory.xml
myconfig/applicationContext.xml
com/test/Test.class
My beanRefFactory looks like this.
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="my-factory" class="org.springframework.context.support.ClassPa thXmlApplicationContext" lazy-init="true">
<constructor-arg>
<value>classpath*:myconfig/applicationContext.xml</value>
</constructor-arg>
</bean>
</beans>
applicationContext is simlple bean definition with bean name as "my-Bean".
Even, I made following entry in web.xml(differenct different scenario/configuration)
-----------------------------------------------------------------------------------------
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/myconfig/applicationContext.xml myconfig/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>classpath*:/beanRefContext.xml beanRefContext.xml</param-value>
</context-param>
<
servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoade rServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<listener>
<listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
</listener>
Any help will be highly appreciated, I want to resolve this error.