Meaningless Drivel is fun!*
The moose likes Spring and the fly likes Spring 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring 3" Watch "Spring 3" New topic
Author

Spring 3

Marcos Vidolin
Greenhorn

Joined: May 10, 2011
Posts: 28
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

Joined: Jun 25, 2001
Posts: 16160
    
  21

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:


Customer surveys are for companies who didn't pay proper attention to begin with.
Marcos Vidolin
Greenhorn

Joined: May 10, 2011
Posts: 28
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

Joined: Jun 25, 2001
Posts: 16160
    
  21

This is just too little JSF and too much Spring, so I'm going to move it.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16160
    
  21

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

Joined: May 10, 2011
Posts: 28
Thanks Tim,

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring 3