Trying to Unit Test A Class That Makes DB Queries Using Hibernate And Can't Get Session Created...
Posted
by Jared Michaels
on Stack Overflow
See other posts from Stack Overflow
or by Jared Michaels
Published on 2010-04-23T20:41:40Z
Indexed on
2010/04/23
20:53 UTC
Read the original article
Hit count: 300
I am trying to implement JUnit tests for a class that performs DB queries using Hibernate. When I create the class under test, I get access to the session through the factory by doing the following:
InitialContext context = new InitialContext();
sessionFactory = (SessionFactory) context.lookup(hibernateContext);
This works fine when I deploy this to JBoss 5.1. I am trying to figure out how to get this to work with my JUnit test. I keep getting an exception stating that I "Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial". I've searched high and low but haven't been able to find any information about what specifically I need to do to get this to work. I am not using Spring or any frameworks, just plain old Java and JUnit.
© Stack Overflow or respective owner