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.
Main Appconfig class
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
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.
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.
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..........
posted 5 years ago
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
posted 5 years ago
Disregard last statment! is there a delete statement somehhow?
It is not working stuck in the original place in the ad.
ice is for people that are not already cool. Chill with this tiny ad: