This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Problem getting Bean reference which is in jar from JSP

Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


JSP calling methodA() of class Test which is in the jar file.
Code in JSP
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());

And structure of jar file which is in WEB-INF/lib

My beanRefFactory looks like this.
<?xml version="1.0" encoding="UTF-8"?>

<bean id="my-factory" class=" thXmlApplicationContext" lazy-init="true">

applicationContext is simlple bean definition with bean name as "my-Bean".

Even, I made following entry in web.xml(differenct different scenario/configuration)

<param-value>classpath*:/myconfig/applicationContext.xml myconfig/applicationContext.xml</param-value>

<param-value>classpath*:/beanRefContext.xml beanRefContext.xml</param-value>

<servlet-class>org.springframework.web.context.ContextLoade rServlet</servlet-class>
<listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>

Any help will be highly appreciated, I want to resolve this error.
Posts: 14691
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the directory "myconfig". It must be somewhere in the classpath. If you're using a web application, a good bet is under the "classes" directory.
A berm makes a great wind break. And Iwe all like to break wind once in a while. Like this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!