Hi
I am in big trouble folks. i am not able to configure getting SessionFactory from JNDI . Please help me details about the cfg and error stackTrace are mentioned below.
This is my cfg file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="SessionFactory"> <property name="connection.pool_size">1</property> <property name="hibernate.session_factory_name">SessionFactory</property> <!-- <property name="hibernate.jndi.url"></property> <property name="hibernate.jndi.class"></property> -->
<!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto"></property>
<mapping resource="com/ocr/wms/hib/mapping/HiberTableMapping.hbm.xml" /> <mapping resource="com/ocr/wms/hib/mapping/HiberTableSecondMapping.hbm.xml" /> <mapping resource="com/ocr/wms/hib/mapping/HibernateTableCompositeMapping.hbm.xml" />
</session-factory>
</hibernate-configuration>
Code calling Session factory using JNDI lookup try { Context ctx = new InitialContext(); SessionFactory sesionf = (SessionFactory) ctx.lookup("SessionFactory"); Session session = sesionf.getCurrentSession(); session.beginTransaction(); query="from HiberTableSecond hts where hts.serialid = any(select ht.id from HiberTable ht)"; List sourcelist = session.createQuery(query).list(); return sourcelist; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; }
This is the Full stack trace of the exception that occured:
13:26:57,629 ERROR [STDERR] javax.naming.NameNotFoundException: SessionFactory not bound 13:26:57,629 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:495) 13:26:57,629 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:503) 13:26:57,645 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:509) 13:26:57,645 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:282) 13:26:57,645 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:445) 13:26:57,645 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:429) 13:26:57,645 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:347) 13:26:57,645 ERROR [STDERR] at com.ocr.wms.manager.FacadeWmsManagerBean.selectDataSubQuery(FacadeWmsManagerBean.java:113) 13:26:57,645 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 13:26:57,645 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 13:26:57,645 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 13:26:57,645 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer .java:664) 13:26:57,645 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInter ceptor.java:147) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInte rceptor.java:77) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313) 13:26:57,645 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:705) 13:26:57,645 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491) 13:26:57,645 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364) 13:26:57,645 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 13:26:57,645 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 13:26:57,645 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 13:26:57,645 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324) 13:26:57,645 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) 13:26:57,645 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:148) 13:26:57,645 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method) 13:26:57,645 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:144) 13:26:57,645 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) 13:26:57,645 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) 13:26:57,645 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)
Please help me. I have to imlement it in both websphere and jboss Application Server.
Joseph C
_________________ JosephC
|