Brajesh Choudhary wrote: First I use *.html but after that I use *.do extension but it also not work for me as you see in my files.

Hum... If you only use one, does it work? i.e. just have the single servlet-mapping entry. Also can't you do multiple url-pattern entries inside of the servlet-mapping? Perhaps having two mappings screws it up.

Have you tried /login.do instead of login.do? i.e. putting the path in first?

Also, have you tried path-based mapping? If you're on Spring 3.0.6 or higher you could literally use /* for the URL mapping, coupled with the <mvc:resources /> tag that describes where the non-JSP resources reside...

Otherwise in earlier versions you could use /controllers/* or something like that. Then in your UrlMapping you could use "/controllers/foo" and it would map. Generally path-based mapping seems to be a 'best practice' these days.

Brajesh Choudhary
Greenhorn

Joined: May 24, 2012
Posts: 8

posted May 30, 2012 09:01:20

0

Hi Ken

I don't know how but yesterday code works today but i get a new problem today while integrating hibernate with my spring project.

I haven't done the hbm.xml mappings as part of a JPA 2 application, but I think it should be possible as long as you use the entity manager.

I am wondering if you want to use the container's Entity Manager. It's not needed in Spring, you could be using the LocalContainerEntityManagerFactoryBean - which is app server independent. While I would think the connection pool could be fetched from a Java EE datasource in JNDI, there is no practical benefit to using the container's entity manager that I can see and you make your application slightly less portable (you could run it on Tomcat or Jetty with the Spring one). Try setting up just these things:

- a Spring LocalContainerEntityManagerFactoryBean that sets up your JPA container
- a Spring JNDI DataSource - inject it into the bean above
- a JTA transaction manager - which you currently have commented out

That's all you really need. Make sure you include core hibernate as well as the hibernate entity manager, and you're on your way. Maybe a JBoss / Hibernate / Spring person will set me straight on this though (please do as I've not done that specific config myself).

I believe it's possible your class not found exception is coming from the fact that you're using an App Server's factory bean and maybe it doesn't implement or include the jar with that class in it? I'm not sure how JBoss's hibernate configuration matches or does not match the Spring way, but if you're on Spring, you want the Spring way primarily.

Here is setting up the entity factory - see the datasource injection, that's the key thing there. The transaction manager you use is Spring's delegate to the container's JTA manager, which relies on JBoss's configured datasources and is automatically enlisted (provide you've used XA drivers).

Here is an example of setting the persistence provider to Hibernate's entity manager - it's the org.hibernate.ejb.HibernatePersistence class:

More importantly, do you know that you're using <dependencyManagement> to define your dependencies?

That really means you're not defining real dependencies. You're stating a preference that if a sub-project or one of your dependencies depends on something, you want it to depend on that version. I don't see all of them being used down below, so I'm assuming some either aren't being imported or are transitive.

If you're unsure whether this build is correct, you need to do some digging... Maybe the problem is related to a mixed up jar import being missing.

You can do a mvn help:effective-pom and paste that, it will tell you how the pom evaluates and what jars end up in the project. Better yet, mvn dependency:list and mvn dependency:tree output -Dverbose=true - that will tell us what it selected, and what conflicts, if any, existed.

Brajesh Choudhary
Greenhorn

Joined: May 24, 2012
Posts: 8

posted May 31, 2012 08:45:46

0

Hi Ken

Thanks for your quick reply.I have solved the previous problem but now a new problem comes.

Here is the stack trace

my spring-business-context.xml

my controller class

There is also a problem when I provide the hbm file or cfg file it gives error that file not found.As you see I have commented that code.

Also, on line 52 of your spring config, the bean setter is setTblSysUserDetailDAO, so your setter name is invalid. The property should have a name of "tblSysUserDetailDAO" - that's why it can't understand this.

Best of luck continuing on your project. I'd definitely take time to match your properties to log errors - I do this all the time and whenever I hand code XML I pay the price ;)

IntelliJ, Netbeans or Springsource Tool Suite (eclipse with the Spring IDE plugins installed) should help you with CTRL-SPACE so that you are picking valid bean and field names.