Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Robert Goddard
15,019 PointsUnable to complete challenge: Add a Spring Bean to configure a Hibernate SessionFactory with the following settings:
It says task 2 is failing... but I go back to task 2 and it works... Infuriating challenge.. I have this fully working in my own IDE.
package com.teamtreehouse.contactmgr.config;
import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import javax.sql.DataSource;
@Configuration
public class DataConfig {
@Autowired
private Environment env;
@Bean
public LocalSessionFactoryBean sessionFactory() {
Resource config = new ClassPathResource("hibernate.cfg.xml");
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setConfigLocation(config);
sessionFactory.setPackagesToScan(env.getProperty("com.teamtreehouse.contactmgr.model"));
sessionFactory.setDataSource(dataSource());
return sessionFactory;
}
@Bean
public DataSource dataSource() {
BasicDataSource ds = new BasicDataSource();
// Driver class name
ds.setDriverClassName("org.h2.Driver");
// Set URL
ds.setUrl("jdbc:h2:mem:contactmgr");
return ds;
}
}
Ed Cooney
11,772 PointsEd Cooney
11,772 PointsMake sure you check the app.properties *.db.url value and that its pointing to contactmgr, not something else.