tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 4ndrew <jov...@gmail.com>
Subject Could not locate SessionFactory in JNDI
Date Mon, 28 Nov 2011 01:39:04 GMT
Hi, 

Im trying make my test run, but it gives me the following exception. I
really dont have any idea where can I find the solution. Any help would be
appreciated.

*Exception:*
Caused by: java.lang.IllegalStateException: Could not locate SessionFactory
in JNDI
	at
com.my.dpro.session.dao.DproServiceDAO.getSessionFactory(DproServiceDAO.java:49)

*DproServiceDAO:*
private final SessionFactory sessionFactory = getSessionFactory();

	protected SessionFactory getSessionFactory() {
		try {
			return (SessionFactory) new InitialContext()
					.lookup("java:/hibernate/SessionFactorySession");
		} catch (Exception e) {
			log.error("Could not locate SessionFactory in JNDI", e);
			throw new IllegalStateException(
					"Could not locate SessionFactory in JNDI");
		}
	}

*Test:*
	private AccessManagerLocal accManBean;
	private Properties p;
	private EJBContainer ejbContainer;

	@Before
	public void setUp() throws Exception {
		p = new Properties();

		// set the initial context factory
		p.put("java.naming.factory.initial ",
				"org.apache.openejb.client.LocalInitialContextFactory");


		p.put("myStatelessContainer", "new://Container?type=STATELESS");

		// set some openejb flags
		p.put("openejb.jndiname.format ", " {ejbName}/{interfaceClass}");
		p.put("openejb.descriptors.output ", " true");
		p.put("openejb.validation.output.level ", " verbose");

		InitialContext initialContext = new InitialContext(p);
	}

	@Test
	public void test() {
		try {
			ejbContainer = OpenEjbContainer.createEJBContainer();
			Object object = ejbContainer.getContext().lookup(
					"java:global/DproBoAccessManager/AccessManagerBean");
//			assertTrue(object instanceof AccessManagerBean);
			
			accManBean = (AccessManagerLocal) object;
...
	
*Console:*
Apache OpenEJB 4.0.0-beta-1    build: 20111002-11:30
http://openejb.apache.org/
INFO - openejb.home = C:\work\dpro\DproBoAccessManager
INFO - openejb.base = C:\work\dpro\DproBoAccessManager
INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Inspecting classpath for applications: 36 urls. Consider adjusting
your exclude/include.  Current settings:
openejb.deployments.classpath.exclude='',
openejb.deployments.classpath.include='.*'
INFO - Found PersistenceModule in classpath:
C:\localRepo\.m2\repository\Dpro\DproBoConfigDB\0.0.1\DproBoConfigDB-0.0.1-jar.jar
INFO - Found PersistenceModule in classpath:
C:\localRepo\.m2\repository\Dpro\DproBoSessionDB\0.0.1\DproBoSessionDB-0.0.1-jar.jar
INFO - Found EjbModule in classpath:
C:\localRepo\.m2\repository\Dpro\DproBoSessionManager\0.0.1\DproBoSessionManager-0.0.1.jar
INFO - Found EjbModule in classpath:
C:\work\dpro\DproBoAccessManager\target\classes
INFO - Searched 36 classpath urls in 1475 milliseconds.  Average 40
milliseconds per url.
INFO - Beginning load:
C:\localRepo\.m2\repository\Dpro\DproBoConfigDB\0.0.1\DproBoConfigDB-0.0.1-jar.jar
INFO - Beginning load:
C:\localRepo\.m2\repository\Dpro\DproBoSessionDB\0.0.1\DproBoSessionDB-0.0.1-jar.jar
INFO - Beginning load:
C:\localRepo\.m2\repository\Dpro\DproBoSessionManager\0.0.1\DproBoSessionManager-0.0.1.jar
INFO - Beginning load: C:\work\dpro\DproBoAccessManager\target\classes
INFO - Configuring enterprise application: C:\work\dpro\DproBoAccessManager
WARN - Method 'lookup' is not available for 'javax.annotation.Resource'.
Probably using an older Runtime.
INFO - Configuring Service(id=Default Stateless Container, type=Container,
provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean SessionManagerBean:
Container(type=STATELESS, id=Default Stateless Container)
INFO - Configuring Service(id=Default MDB Container, type=Container,
provider-id=Default MDB Container)
INFO - Auto-creating a container for bean RequestInstallContext:
Container(type=MESSAGE, id=Default MDB Container)
INFO - Configuring Service(id=Default JMS Resource Adapter, type=Resource,
provider-id=Default JMS Resource Adapter)
INFO - Configuring Service(id=Default JMS Connection Factory, type=Resource,
provider-id=Default JMS Connection Factory)
INFO - Auto-creating a Resource with id 'Default JMS Connection Factory' of
type 'javax.jms.QueueConnectionFactory for 'RequestInstallContext'.
INFO - Auto-linking resource-ref
'java:comp/env/com.my.dpro.aman.consumer.RequestInstallContext/queueConnectionFactory'
in bean RequestInstallContext to Resource(id=Default JMS Connection Factory)
INFO - Configuring Service(id=queue.access.in, type=Resource,
provider-id=Default Queue)
INFO - Auto-creating a Resource with id 'queue.access.in' of type
'javax.jms.Queue for 'RequestInstallContext'.
INFO - Configuring Service(id=Default Managed Container, type=Container,
provider-id=Default Managed Container)
INFO - Auto-creating a container for bean
com.my.dpro.aman.consumer.AccessManagerOpenEJBTest: Container(type=MANAGED,
id=Default Managed Container)
INFO - Configuring PersistenceUnit(name=unitConfig,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Configuring Service(id=Default JDBC Database, type=Resource,
provider-id=Default JDBC Database)
INFO - Auto-creating a Resource with id 'Default JDBC Database' of type
'DataSource for 'unitConfig'.
INFO - Configuring Service(id=Default Unmanaged JDBC Database,
type=Resource, provider-id=Default Unmanaged JDBC Database)
INFO - Auto-creating a Resource with id 'Default Unmanaged JDBC Database' of
type 'DataSource for 'unitConfig'.
INFO - Adjusting PersistenceUnit unitConfig <jta-data-source> to Resource ID
'Default JDBC Database' from 'java:/OracleDSDproSession'
INFO - Adjusting PersistenceUnit unitConfig <non-jta-data-source> to
Resource ID 'Default Unmanaged JDBC Database' from 'null'
INFO - Configuring PersistenceUnit(name=unitSession,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting PersistenceUnit unitSession <jta-data-source> to Resource
ID 'Default JDBC Database' from 'java:/OracleDSDproSession'
INFO - Adjusting PersistenceUnit unitSession <non-jta-data-source> to
Resource ID 'Default Unmanaged JDBC Database' from 'null'
INFO - Enterprise application "C:\work\dpro\DproBoAccessManager" loaded.
INFO - Assembling app: C:\work\dpro\DproBoAccessManager
INFO - PersistenceUnit(name=unitConfig,
provider=org.hibernate.ejb.HibernatePersistence) - provider time 674ms
INFO - PersistenceUnit(name=unitSession,
provider=org.hibernate.ejb.HibernatePersistence) - provider time 98ms
INFO -
Jndi(name="java:global/DproBoSessionManager-0.0.1/SessionManagerBean!com.my.dpro.session.facade.SessionManagerLocal")
INFO -
Jndi(name="java:global/DproBoSessionManager-0.0.1/SessionManagerBean")
INFO -
Jndi(name="java:global/DproBoAccessManager/AccessManagerBean!com.my.dpro.aman.ejb.AccessManagerLocal")
INFO - Jndi(name="java:global/DproBoAccessManager/AccessManagerBean")
INFO -
Jndi(name="java:global/EjbModule689037010/com.my.dpro.aman.consumer.AccessManagerOpenEJBTest!com.my.dpro.aman.consumer.AccessManagerOpenEJBTest")
INFO -
Jndi(name="java:global/EjbModule689037010/com.my.dpro.aman.consumer.AccessManagerOpenEJBTest")
INFO - Created Ejb(deployment-id=SessionManagerBean,
ejb-name=SessionManagerBean, container=Default Stateless Container)
INFO - Created Ejb(deployment-id=AccessManagerBean,
ejb-name=AccessManagerBean, container=Default Stateless Container)
INFO - Created
Ejb(deployment-id=com.my.dpro.aman.consumer.AccessManagerOpenEJBTest,
ejb-name=com.my.dpro.aman.consumer.AccessManagerOpenEJBTest,
container=Default Managed Container)
INFO - Created Ejb(deployment-id=RequestInstallContext,
ejb-name=RequestInstallContext, container=Default MDB Container)
INFO - Started Ejb(deployment-id=SessionManagerBean,
ejb-name=SessionManagerBean, container=Default Stateless Container)
INFO - Started Ejb(deployment-id=AccessManagerBean,
ejb-name=AccessManagerBean, container=Default Stateless Container)
INFO - Started
Ejb(deployment-id=com.my.dpro.aman.consumer.AccessManagerOpenEJBTest,
ejb-name=com.my.dpro.aman.consumer.AccessManagerOpenEJBTest,
container=Default Managed Container)
INFO - Started Ejb(deployment-id=RequestInstallContext,
ejb-name=RequestInstallContext, container=Default MDB Container)
INFO - Deployed Application(path=C:\work\dpro\DproBoAccessManager)


--
View this message in context: http://openejb.979440.n4.nabble.com/Could-not-locate-SessionFactory-in-JNDI-tp4113852p4113852.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message