-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: using SessionFactory from a HAR from a webapp.
PostPosted: Wed Oct 27, 2004 4:39 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:56 am
Posts: 35
Hibernate version: 2.1.5

Mapping documents: n/a

Code between sessionFactory.openSession() and session.close():n/a

Full stack trace of any exception that occurs:n/a

Name and version of the database you are using:n/a

The generated SQL (show_sql=true):n/a

Debug level Hibernate log excerpt:n/a

Can the HibernateContext.getSession() call be used from a class inside a war to obtain a session from a deployed har, if the war resides in the same container as the har? Would you need to deploy them together as an ear for this to work?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 5:48 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:56 am
Posts: 35
Okay so I read the other thread about "the best way to access hibernate data" and have now incorporated the UserTransaction code into the servlet I'm trying to access this from:

Code:
UserTransaction transaction = (UserTransaction)(newInitialContext()).lookup("java:/UserTransaction");
transaction.begin();
Session sess = HibernateContext.getSession(DBO_SESSION);
         
         Criteria attrCrt = sess.createCriteria( attr )
            .addOrder( Order.asc("order") );
         
         results = attrCrt.list();
         transaction.commit();


However, when I try to run this, it says UserTransaction cannot be found, is there any special configuration I have to do to get it to locate the UserTransaction? I checked jndiView of the jmx-console and verified that the name UserTransaction is bound

Here's the exception.:

Code:
javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: UserTransaction not bound]
16:41:27,156 INFO  [STDOUT]    at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:971)
16:41:27,156 INFO  [STDOUT]    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:614)
16:41:27,156 INFO  [STDOUT]    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:643)
16:41:27,156 INFO  [STDOUT]    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508)
16:41:27,156 INFO  [STDOUT]    at javax.naming.InitialContext.lookup(InitialContext.java:351)
16:41:27,156 INFO  [STDOUT]    at com.dbo.db.facade.AttributeFacade.getAttributesByType(AttributeFacade.java:74)
16:41:27,156 INFO  [STDOUT]    at com.dbo.db.delegate.AttributeDelegate.getStates(AttributeDelegate.java:189)
16:41:27,156 INFO  [STDOUT]    at com.dbo.web.struts.RepositoryInitializer.doInitialization(RepositoryInitializer.java:41)
16:41:27,171 INFO  [STDOUT]    at com.litriusgroup.lib.web.init.WebAppInit.contextInitialized(WebAppInit.java:52)
16:41:27,171 INFO  [STDOUT]    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
16:41:27,171 INFO  [STDOUT]    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4343)
16:41:27,171 INFO  [STDOUT]    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
16:41:27,171 INFO  [STDOUT]    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
16:41:27,171 INFO  [STDOUT]    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:41:27,171 INFO  [STDOUT]    at java.lang.reflect.Method.invoke(Method.java:585)
16:41:27,171 INFO  [STDOUT]    at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
16:41:27,171 INFO  [STDOUT]    at org.apache.catalina.core.StandardContext.init(StandardContext.java:5441)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:41:27,171 INFO  [STDOUT]    at java.lang.reflect.Method.invoke(Method.java:585)
16:41:27,171 INFO  [STDOUT]    at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
16:41:27,171 INFO  [STDOUT]    at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:336)
16:41:27,171 INFO  [STDOUT]    at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:83)
16:41:27,171 INFO  [STDOUT]    at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:370)
16:41:27,171 INFO  [STDOUT]    at org.jboss.web.WebModule.startModule(WebModule.java:62)
16:41:27,171 INFO  [STDOUT]    at org.jboss.web.WebModule.startService(WebModule.java:40)
16:41:27,171 INFO  [STDOUT]    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
16:41:27,171 INFO  [STDOUT]    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:41:27,171 INFO  [STDOUT]    at java.lang.reflect.Method.invoke(Method.java:585)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
16:41:27,171 INFO  [STDOUT]    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
16:41:27,171 INFO  [STDOUT]    at $Proxy0.start(Unknown Source)
16:41:27,171 INFO  [STDOUT]    at org.jboss.system.ServiceController.start(ServiceController.java:416)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:41:27,171 INFO  [STDOUT]    at java.lang.reflect.Method.invoke(Method.java:585)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
16:41:27,171 INFO  [STDOUT]    at $Proxy26.start(Unknown Source)
16:41:27,171 INFO  [STDOUT]    at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:362)
16:41:27,171 INFO  [STDOUT]    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:935)
16:41:27,171 INFO  [STDOUT]    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:927)
16:41:27,171 INFO  [STDOUT]    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:746)
16:41:27,171 INFO  [STDOUT]    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
16:41:27,171 INFO  [STDOUT]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:41:27,171 INFO  [STDOUT]    at java.lang.reflect.Method.invoke(Method.java:585)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:119)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
16:41:27,171 INFO  [STDOUT]    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
16:41:27,171 INFO  [STDOUT]    at $Proxy8.deploy(Unknown Source)
16:41:27,187 INFO  [STDOUT]    at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
16:41:27,187 INFO  [STDOUT]    at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:481)
16:41:27,187 INFO  [STDOUT]    at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
16:41:27,187 INFO  [STDOUT]    at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
16:41:27,187 INFO  [STDOUT]    at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
16:41:27,187 INFO  [STDOUT] Caused by: javax.naming.NameNotFoundException: UserTransaction not bound
16:41:27,187 INFO  [STDOUT]    at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
16:41:27,187 INFO  [STDOUT]    at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
16:41:27,187 INFO  [STDOUT]    at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
16:41:27,187 INFO  [STDOUT]    at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
16:41:27,187 INFO  [STDOUT]    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:529)
16:41:27,187 INFO  [STDOUT]    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508)
16:41:27,187 INFO  [STDOUT]    at javax.naming.InitialContext.lookup(InitialContext.java:351)
16:41:27,187 INFO  [STDOUT]    at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:965)
16:41:27,187 INFO  [STDOUT]    ... 80 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 11:32 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:56 am
Posts: 35
Well I got past this problem. Apparently I had to use:

Code:
UserTransaction transaction = (UserTransaction)(newInitialContext()).lookup("java:comp/UserTransaction");


I had to add comp to the JNDI path.

to grab a handle on the UserTransaction. I'm still having an issue where hibernate doesn't seem to want to return any results. I'm only trying Criteria queries right now. The all keep returning empty result sets even though the tables have data. I'm not getting any errors.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.