Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Hibernate Basics Getting Started with Hibernate Building a Hibernate SessionFactory

Type mismatch: cannot convert from StandardServiceRegistry to ServiceRegistry

I'm coding the same as the instructor is doing in this video. But I get a warning as given in the title. In eclipse, it is telling me to cast to ServiceRegistry(and it is working on cast). All I wanted to know is, how come the instructor not getting this error/warning. Is it because he is using IntelliJ? Is there a way that I can do it without casting the object, If so How can I do this?

4 Answers

Got it, There was a wrong Import done. :) I had to import:

import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

I am glad you figured it out! I marked your answer as best because it explains how you solved your problem. If you ever solve your own problem in the future, feel free to mark your own answer as best!

Marvin Deutz
Marvin Deutz
8,349 Points

Just a quick Headsup for anyone having the same problem. There is also a ServiceRegistry in Java (Javax.io I think). IntelliJ imported this one and the hibernate one for me automatically, but it somehow used the Java one. So I had to delete the Java Service registry import and then type the hibernate one again.

I had the same issue. I had to remove this import which intellij added:

import javax.imageio.spi.ServiceRegistry;

and add this one:

import org.hibernate.service.ServiceRegistry;

Nelson Fleig
Nelson Fleig
25,570 Points

I had the same problem. Thanks for pointing that out :)