• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Spring MVC, Spring Security, Hibernate, Cannot Persist a User  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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 IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!