• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring 3

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I don't know this is the right forum but, let me try... =]
I've had the below problem in my application (JSF 2, Spring 3.1, Hibernate/JPA) when I run on Glassfish 3.1:
It seems that Spring can't load the bean.



These are my configurations files:
web.xml


spring-persistence.xml


Does anybody can help me, please?
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably should have asked in the Spring forum, actually.

I see a definition for "entityManagerFactory" in your Spring config file. However, that definition isn't being applied. So either the config file isn't being used or there was an earlier failure in instantiating that object. If the emf couldn't be instantiated, that should have resulted in an error message in the log.

I haven't looked at the syntax for the web.xml Spring config file locations, but I do have some questions about what you did. First off, you qualified it with "classpath:", but your files aren't actually in the webapp's classpath. Secondly, you have that curious construct "*/WEB-INF". The WEB-INF directory is ALWAYS at the root of a WAR, per the J2EE spec, but you seem to be defining a case where you have several directories at the WAR root, each with a directory named WEB-INF under them. And while that's technically legal, naming a directory WEB-INF doesn't give it the magic powers that the root-level WEB-INF has, they would be plain old directories whose names just happened to be "WEB-INF" instead of something like "WEB-STUFF" or "web-inf".

So what I'd expect to see if you really wanted to keep your config files hidden from unfriendly eyes would be more like this:
 
Marcos Vidolin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim Holloway

You realy helped me, with that error but, I'm still with an error when I try to run the project. =[
Now Spring can read de spring-*.xml files, but the entityManagerFactory can't be created and not even injected in my CaixaDao class.
Can you help me more one time?

This is the error:
server.log


These are my configuration files:

spring-persistence.xml


database.properties


spring-datasource.xml


CaixaDao.java

[]'s
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is just too little JSF and too much Spring, so I'm going to move it.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Normally I'd expect that your DataSource Spring bean would be an input to an EntityManagerFactory Spring bean, and that bean would be injected into your DAOs. You don't seem to have defined that bean, so the dependent bean cannot be constructed.

For the record, all my DAOs implement the EntityManager as an injectable property, not as a constructor parameter.
 
Marcos Vidolin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim,

But I didn't understand how can I use generic DAO like that, injected a EntityManager in all my DAO?

 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic