• 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 MVC, Spring Security, Hibernate, Cannot Persist a User

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok so I am building an ecommerce site using java spring mvc, spring security, maven, hibernate, and some other technologies however those should be the only ones relevant to my problem. I am doing all java config with no XML by the way (which I am currently considering revising since I am running into situations where xml just seems easier).

When I try to build my program (maven install) it builds correctly without errors but when I start/restart my server I get exceptions about configuration.

I have tried to get this down to as simple as possible while still having a user and a role. When I am looking at the code, it really is pretty straight forward stuff - I am dying to find out why it errors out everytime.

Also sorry if this isnt in the correct section, I thought it could fit in the hibernate forum also but I think my root problem is spring based.

Thank you

Main Appconfig class


SecurityConfig.java




User class

UserRole class



UserDao Interface


UserDaoImpl

UserService Interface



User Service Impl


Database SQL used

CREATE TABLE users (
user_id int(11) NOT NULL AUTO_INCREMENT,
username VARCHAR(45) NOT NULL UNIQUE,
PRIMARY KEY (user_id));

I cant get the server to startup without errors. There has to be something wrong in the code above.

In AppConfig.java if I change the line "scanPackages...." to the actual class name

com.crutchsf.users.model.User

then my server starts up fine and the program is reachable via server on localhost:8080 but when it reaches the line in my userDao to be persisted

I get a different error from hibernate "Cant find entity com.crutchsf.users.model.User"

Here is the main error I get. Basically I can choose which error I want to get now.



thank you
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

At first sight, this looks suspicious:

As far as I know you cannot use wildcards in the @ComponentScan annotation, just do this instead:


Also, I don't see package statements in any of your source files, did you leave them out? Your classes should ofcourse be in package com.crutchsf or a subpackage of that.

There is a NullPointerException happening somewhere inside your AppConfig.sessionFactory() method. What does the complete stacktrace look like? Carefully inspect the stacktrace to find out exactly where the exception comes from.
 
bobby peccia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello! thank you for the response.

Here is the full line in the stack trace



Lower down the stack trace there is this line



Since I took out package and import names the line it is referencing is this one



When I use the debugger to trace the error, it takes me into the "buildSessionFactory", shown below



Failing on this line of that method



Something I thought that was weird was the above line has a line through it, the only the "buildSessionFactory" letters however.


this error is very strange to me as this code used to work. I had a simple class like the one written above that worked, persisted a user perfectly, it was only when I tried to make the class bigger that it stopped working, I have shortened it back to whats written above and still nothing. Driving me crazy..........
 
bobby peccia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok so I got past the server issue I beleive but I basically only swapped it for another one because now Hibernate is asking what my User class is, it should be completely aware of it

I changed my Autowire statements in my controller method to be



I am now plauged with the Hibernate error



thank you
 
bobby peccia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Disregard last statment! is there a delete statement somehhow?

It is not working stuck in the original place in the ad.

Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic