• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Struts 2 + Spring 3 +Hibernate 3.5 Integration Problem session factory nullpointer exception

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I'm new using these frameworks. I've used this tutorial as a starting point. My problem is that none of my actions work. When the jsp input form is shown and you submit the values I get this error:




My Spring application context is as follows:



My hibernate.cfg is:



Struts.xml:



The base action is:




And the Login action:



I've tried to substitute in Login.action by and this way this action works fine and the rest keep showing the error. So I think maybe there is a problem with the session factory, but I can't see the problem in the configuration.

Thanks in advance.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without knowing what line the error message actually corresponds to it's difficult to help.

I don't see anywhere were you attempt to set logicaComun, though.
 
Tony Manello
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error line corresponds to this line of Login action class:



I forgot including the bussiness class LogicaComun:



When I try to use any method of the bussiness layer in an action in which is injected factory session, I get the error in the web browser.

LogicaComun (the bussiness layer or DAO), in the same way as session factory before, is injected to AccionBase action and it's Spring the responsible of injecting the bussiness sinlgeton in it.

All of this is the expected behaviour I understood from the tutorial, but I guess I'm wrong.

Any idea?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But you *don't* inject it anywhere, that's what I'm saying. Where and how do you believe it's being set on the action?
 
Tony Manello
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand what you say but now I'm so confused. According to this reference documentation is not need to set the reference by yourself because Spring's context do that with declared beans. So if I reference the bean "session factory" in the DAO LogicaComun with

and then I do the same with bean DAO in the Base Action (AccionBase)


It should be ok shouldn't it?

What am I doing wrong?

Thanks for your patience!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But your bean is named something else:I'm also assuming you're deploying the Struts 2 Spring plugin... although I don't actually know if it works with Spring 3 or not; I've never tried.
 
Tony Manello
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Struts2 Spring plugin and it works at least with an example.

I changed the name reference for dependency injection in AccionBase from

to

Now it seems to work OK. So as you said the problem was the bean name

Thanks a lot David!

reply
    Bookmark Topic Watch Topic
  • New Topic