Reputation: 24645
I have class that uses hibernate, I have included all required jars to classpath and class worked before Java updated itself. But now eclipse shows that it cannot resolve some hibernate imports. What could be solution to this?
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
Upvotes: 5
Views: 60357
Reputation: 1
In your pom.xml, add the below mentioned jar and take maven build of your project. change the version accordingly.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.5.Final</version>
</dependency>
Upvotes: 0
Reputation: 1
I faced this problem today.I think eclipse tell me that he want to resolve something but don't know what problem and how.And here it is:
SessionFactory factory;
try {
factory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex);
}
Maby it helps.In my case it was exception handling.
Upvotes: 0
Reputation: 365
Delete .m2/repository/org/hibernate/*, then in eclipse: Maven/update Project. It will download the dependencies again. It worked for me!
Upvotes: 6
Reputation: 11
even i was facing the same problem . every thing was working fine but all of a suden every jsp page started giving me error saying org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 1 in the generated java file The type org.hibernate.SessionFactory cannot be resolved. It is indirectly referenced from required .class files
An error occurred at line: 9 in the generated java file Only a type can be imported. org.hibernate.Query resolves to a package
An error occurred at line: 11 in the generated java file Only a type can be imported. org.hibernate.Session resolves to a package
An error occurred at line: 12 in the generated java file Only a type can be imported. org.hibernate.SessionFactory resolves to a package
An error occurred at line: 13 in the generated java file Only a type can be imported. org.hibernate.cfg.Configuration resolves to a package
to solve thi problem in eclipse i removed/deleted the server from eclipse and added my tomcat server back and every thing started working same as before .....
Thanks
Upvotes: 0
Reputation: 1828
If you type (Ctrl + shift + t), or open the Type Explorer and type SessionFactory or Configuration does Eclipse find them? If not, then for sure you have some problems in the .jar files. Try to delete and replace them.
By the way are you using a Mac or PC?
Upvotes: 5
Reputation: 6131
I experienced a similar problem that got fixed when I used Grails Tools > Refresh Dependencies (Alt+G,R). This was in SpringSource Tool Suite 2.7.1.
I had to run that once to get the plugins to initialize correctly (after an import from SVN) and then a second time to get references to work.
Upvotes: 2
Reputation: 36105
Did you try "Project > Clean ..."? What is the exact error message? After a Java update, you might need to update the path to the JDK: "Window > Preferences > Java > Installed JREs"
Upvotes: 5