Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring 3

 
Marcos Vidolin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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?
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic