-->
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.  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: issues with HibernatePlugIn.java
PostPosted: Tue Feb 10, 2004 2:39 pm 
Newbie

Joined: Tue Feb 10, 2004 2:11 pm
Posts: 15
Hello,

I am using Struts with Hibernate for an application. I followed the instructions in the "HibernatePlugIn for Struts" page. I am using Hibernate 2.1.1, struts 2.0, and Tomcat 5. When I compiled and started the server, the following error was thrown. Please note I did not change anything in the HibernatePlugIn.java.

javax.servlet.ServletException
edu.arbor.util.plugin.HibernatePlugIn.initHibernate(HibernatePlugIn.java:124)
edu.arbor.util.plugin.HibernatePlugIn.init(HibernatePlugIn.java:90)
org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:868)
org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
javax.servlet.GenericServlet.init(GenericServlet.java:256)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Unknown Source)


root cause

java.lang.NullPointerException
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:858)
edu.arbor.util.plugin.HibernatePlugIn.initHibernate(HibernatePlugIn.java:111)
edu.arbor.util.plugin.HibernatePlugIn.init(HibernatePlugIn.java:90)
org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:868)
org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
javax.servlet.GenericServlet.init(GenericServlet.java:256)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Unknown Source)



Below is the Hibernate.cfg.xml file.
------------------------------------------
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="guava:/hibernate/SessionFactory">
<!-- properties -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.url">jdbc:mysql:///guava</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<property name="dbcp.minIdle">1</property>
<property name="cache.use_query_cache">true</property>

<!-- mapping files -->
<mapping resource="com/tjgrp/guava/timesheet/GuavaUser.hbm.xml"/>
</session-factory>

</hibernate-configuration>


Struts.config.xml: (I am showing only the part I modified)
------------------------------------------------------------------------
<plug-in className="edu.arbor.util.plugin.HibernatePlugIn">
<!-- 'path-to-config-file' is relative to the root of the class
path. It MUST start with a '/'. The default is "/hibernate.cfg.xml -->
<set-property property="configFilePath" value="path-to-config-file" />
<set-property property="storeInServletContext" value="true-or-false" />
<set-property property="storedInServletContext" value="true"/>
</plug-in>

LoginAction.java: (only the 'execute' part)
---------------------------------------------------
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
ActionForward forward = null;
LoginForm loginform = (LoginForm) form;

String password = loginform.getPassword();
String identifier = loginform.getIdentifier();

try
{
Context ctx = new InitialContext();
sessionFactory = (SessionFactory) ctx.lookup("guava:/hibernate/SessionFactory");
}
catch (NamingException e)
{
System.err.println("Naming Exception" + e.getMessage());
throw new RuntimeException(e);
}

try
{
String query = "select guavauser from com.tjgrp.guava.timesheet.GuavaUser guavauser " +
"where guavauser.password = :password and " +
"guavauser.identifier = :identifier";
/*
* Build HQL (Hibernate Query Language) query to retrieve a tuple.
*/
Session session = sessionFactory.openSession();
Query q = session.createQuery(query);
q.setParameter("password", password, Hibernate.STRING);
q.setParameter("identifier", identifier, Hibernate.STRING);
GuavaUser gUser = (GuavaUser)q.uniqueResult();
request.setAttribute("identifier", gUser.getIdentifier());
request.setAttribute("password", gUser.getPassword());
}
catch (HibernateException e)
{
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}
forward = mapping.findForward("success");
loginform.clear();
return forward;
}


I am a newbie to both Struts and Hibernate ... so would like some help here. Thanks a lot :-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2004 6:32 pm 
Newbie

Joined: Tue Feb 10, 2004 2:11 pm
Posts: 15
Well, I took a look at the log file and I know where things are going wrong... though don't know what to do about it :-(

The error is being thrown from the 'initHibernate()' method. In particular the following lines of code are not being executed as expected and subsequently throwing the exception below.


configFileURL = HibernatePlugIn.class.getResource(_configFilePath);
context = _servlet.getServletContext();

if (_log.isDebugEnabled()) {
_log.debug("Initializing Hibernate from "
+ _configFilePath + "...");
}

configuration = (new Configuration()).configure(configFileURL);
_factory = configuration.buildSessionFactory();

if (_storedInServletContext) {
_log.debug("Storing SessionFactory in ServletContext...");

context.setAttribute(SESSION_FACTORY_KEY, _factory);
}

} catch (Throwable t) {
_log.error("Exception while initializing Hibernate.");
_log.error("Rethrowing exception...", t);

throw (new ServletException(t));
}


Please some hints here...I tried to look for other posts but nothing seems to address this issue....help :-(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 6:27 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Somehow your _configFileURL is null
You'll have to dig an find why HibernatePlugIn.class.getResource(_configFilePath);
return null.
Probably because the config file is not found

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 11:26 am 
Newbie

Joined: Tue Feb 10, 2004 2:11 pm
Posts: 15
emmanuel wrote:
Somehow your _configFileURL is null
You'll have to dig an find why HibernatePlugIn.class.getResource(_configFilePath);
return null.
Probably because the config file is not found


Hi Emmanuel,
Is the "config file" the Hibernate.cfg.xml file?
If so, where should it be in relation to the HibernatePlugIn file?

Thanks
Helen


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 12:28 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hhanna wrote:
Is the "config file" the Hibernate.cfg.xml file?
If so, where should it be in relation to the HibernatePlugIn file?

Yes
HibernatePlugIn init Hibernate, so it need Hibernate config file.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 12:34 pm 
Beginner
Beginner

Joined: Wed Nov 26, 2003 9:04 am
Posts: 23
As the docs say the hibernate.cfg.xml needs to be at the base of the classpath usually /WEB-INF/classes/ ..


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 1:15 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I hope you replaced
Code:
<set-property property="configFilePath" value="path-to-config-file" />


by

Code:
<set-property property="configFilePath" value="/hibernate.cfg.xml" />

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 2:26 pm 
Newbie

Joined: Tue Feb 10, 2004 2:11 pm
Posts: 15
Hey Emmanuel,

Well, you are right (of course) ... this was one of the problems. I've fixed it. But I think there is something else missing.... (sorry )

This line in HibernatePlugIn is causing it grief:
configuration = (new Configuration()).configure(configFileURL);
_factory = configuration.buildSessionFactory();

I then tried to do it differently. So I wrote:
configuration = new Configuration().addClass(GuavaUser.class);
_factory = configuration.buildSessionFactory();

The thing is, when I looked at the log, it clearly indicated that Hibernate is able to connect to my database. But now I am getting a different type of error:
Below is a piece of the log output ...

INFO: Server startup in 42047 ms
13:04:40,312 INFO Configuration:858 - configuring from url: file:/C:/Apache%20Software/Tomcat%205.0/webapps/build/WEB-INF/classes/hibernate.cfg.xml
13:04:40,328 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath under net/sf/hibernate/
13:04:40,328 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath
13:04:40,328 DEBUG Configuration:801 - dialect=net.sf.hibernate.dialect.MySQLDialect
13:04:40,343 DEBUG Configuration:801 - connection.username=root
13:04:40,343 DEBUG Configuration:801 - connection.password=
13:04:40,343 DEBUG Configuration:801 - connection.url=jdbc:mysql:///guava
13:04:40,343 DEBUG Configuration:801 - connection.driver_class=com.mysql.jdbc.Driver
13:04:40,343 DEBUG Configuration:801 - show_sql=true
13:04:40,343 DEBUG Configuration:801 - use_outer_join=true
13:04:40,343 DEBUG Configuration:801 - transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory
13:04:40,343 DEBUG Configuration:801 - dbcp.minIdle=1
13:04:40,343 DEBUG Configuration:801 - cache.use_query_cache=true
13:04:40,343 DEBUG Configuration:952 - guava:/hibernate/SessionFactory<-org.dom4j.tree.DefaultAttribute@6691da [Attribute: name resource value "com/tjgrp/guava/timesheet/GuavaUser.hbm.xml"]
13:04:40,343 INFO Configuration:300 - Mapping resource: com/tjgrp/guava/timesheet/GuavaUser.hbm.xml
13:04:40,343 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
13:04:40,359 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
13:04:40,375 INFO Binder:225 - Mapping class: com.tjgrp.guava.timesheet.GuavaUser -> guavauser
13:04:40,375 DEBUG Binder:449 - Mapped property: objId -> objId, type: long
13:04:40,375 DEBUG Binder:449 - Mapped property: identifier -> identifier, type: string
13:04:40,375 DEBUG Binder:449 - Mapped property: password -> password, type: string
13:04:40,375 DEBUG Binder:449 - Mapped property: firstName -> firstName, type: string
13:04:40,375 DEBUG Binder:449 - Mapped property: lastName -> lastName, type: string
13:04:40,375 INFO Configuration:998 - Configured SessionFactory: guava:/hibernate/SessionFactory
13:04:40,375 DEBUG Configuration:999 - properties: {show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=C:\Apache Software\Tomcat 5.0, hibernate.connection.url=jdbc:mysql:///guava, catalina.useNaming=true, os.name=Windows XP, sun.boot.class.path=C:\Apache Software\Tomcat 5.0\common\endorsed\xercesImpl.jar;C:\Apache Software\Tomcat 5.0\common\endorsed\xmlParserAPIs.jar;C:\Program Files\Java\j2re1.4.2_03\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_03\lib\i18n.jar;C:\Program Files\Java\j2re1.4.2_03\lib\sunrsasign.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_03\lib\jce.jar;C:\Program Files\Java\j2re1.4.2_03\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_03\classes, sun.java2d.fontpath=, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.4.2_03-b02, user.name=SYSTEM, shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, hibernate.session_factory_name=guava:/hibernate/SessionFactory, connection.driver_class=com.mysql.jdbc.Driver, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=C:\Program Files\Java\j2re1.4.2_03\bin, dialect=net.sf.hibernate.dialect.MySQLDialect, java.version=1.4.2_03, user.timezone=America/New_York, sun.arch.data.model=32, hibernate.use_outer_join=true, java.endorsed.dirs=C:\Apache Software\Tomcat 5.0\common\endorsed, sun.cpu.isalist=pentium i486 i386, file.encoding.pkg=sun.io, cache.use_query_cache=true, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=\, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=48.0, hibernate.dbcp.minIdle=1, user.country=US, connection.url=jdbc:mysql:///guava, java.home=C:\Program Files\Java\j2re1.4.2_03, java.vm.info=mixed mode, os.version=5.1, transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory, path.separator=;, connection.password=, java.vm.version=1.4.2_03-b02, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, hibernate.connection.password=, user.variant=, java.awt.printerjob=sun.awt.windows.WPrinterJob, sun.io.unicode.encoding=UnicodeLittle, awt.toolkit=sun.awt.windows.WToolkit, hibernate.connection.username=root, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., java.naming.factory.url.pkgs=org.apache.naming, user.home=C:\Documents and Settings\LocalService, java.specification.vendor=Sun Microsystems Inc., java.library.path=C:\Program Files\Java\j2re1.4.2_03\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\System32;C:\j2sdk1.4.2_03\bin, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, connection.username=root, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, common.loader=${catalina.home}/common/classes,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=C:\Apache Software\Tomcat 5.0\bin\bootstrap.jar, use_outer_join=true, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=C:\Apache Software\Tomcat 5.0, hibernate.cache.use_query_cache=true, sun.cpu.endian=little, sun.os.patch.level=Service Pack 1, java.io.tmpdir=C:\WINDOWS\TEMP\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, os.arch=x86, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.ext.dirs=C:\Program Files\Java\j2re1.4.2_03\lib\ext, user.dir=C:\Apache Software\Tomcat 5.0, dbcp.minIdle=1, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, file.encoding=Cp1252, java.specification.version=1.4, hibernate.show_sql=true}
13:04:40,390 INFO Configuration:584 - processing one-to-many association mappings
13:04:40,390 INFO Configuration:593 - processing one-to-one association property references
13:04:40,406 INFO Configuration:618 - processing foreign key constraints
13:04:40,406 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
13:04:40,406 INFO SettingsFactory:62 - Use outer join fetching: true
13:04:40,406 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
13:04:40,406 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
13:04:40,406 INFO DriverManagerConnectionProvider:71 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///guava
13:04:40,406 INFO DriverManagerConnectionProvider:72 - connection properties: {user=root, password=}
13:04:40,406 INFO TransactionFactoryFactory:31 - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
13:04:40,421 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
13:04:40,421 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
13:04:40,421 DEBUG DriverManagerConnectionProvider:94 - opening new JDBC connection
13:04:40,437 DEBUG DriverManagerConnectionProvider:100 - created connection to: jdbc:mysql:///guava, Isolation Level: 4
13:04:40,437 DEBUG DriverManagerConnectionProvider:114 - returning connection to pool, pool size: 1
13:04:40,437 INFO SettingsFactory:89 - Use scrollable result sets: true
13:04:40,437 INFO SettingsFactory:90 - JDBC 2 max batch size: 15
13:04:40,437 INFO SettingsFactory:96 - echoing all SQL to stdout
13:04:40,437 INFO SettingsFactory:99 - Query language substitutions: {}
13:04:40,437 INFO SettingsFactory:110 - cache provider: net.sf.ehcache.hibernate.Provider
13:04:40,437 INFO Configuration:1057 - instantiating and configuring caches


AT THIS POINT (I get the following exception, which is the line I mentioned at the beginning of this message):

13:04:40,453 ERROR HibernatePlugIn:121 - Exception while initializing Hibernate.
13:04:40,453 ERROR HibernatePlugIn:122 - Rethrowing exception...
java.lang.NoClassDefFoundError
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:739)
at edu.arbor.util.plugin.HibernatePlugIn.initHibernate(HibernatePlugIn.java:113)
at edu.arbor.util.plugin.HibernatePlugIn.init(HibernatePlugIn.java:91)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:868)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:712)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:187)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
13:04:40,484 INFO DriverManagerConnectionProvider:137 - cleaning up connection pool: jdbc:mysql:///guava


Thank you so much for all your help...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 10:15 pm 
Newbie

Joined: Tue Feb 10, 2004 2:11 pm
Posts: 15
Ok I managed to fix that problem. Had a redundant jar file lying around.
So please disregard my previous posting.

Now though I am having another problem:
Recall how in http://www.hibernate.org/105.html, the hibernate.cfg.xml file has <session-factory name="foo:/hibernate/SessionFactory">

And this is used in the action file as:
SessionFactory sf = (SessionFactory) ctx.lookup("foo:/hibernate/
SessionFactory");

Well, I am getting the following error:
java.lang.RuntimeException: javax.naming.NameNotFoundException: Name blahblah is not bound in this Context

I read that I should add a resource under Tomcat/conf/servlet.xml in order to bind JNDI ... but I am confused .... should I have something like:
<Resource name="foo:/hibernate/SessionFactory"
</Resource>
I know I am doing something wrong...

Could you please help :-(

Thanks again


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 10:17 pm 
Newbie

Joined: Tue Feb 10, 2004 2:11 pm
Posts: 15
hhanna wrote:
<session-factory name="foo:/hibernate/SessionFactory">

Well, I am getting the following error:
java.lang.RuntimeException: javax.naming.NameNotFoundException: Name blahblah is not bound in this Context



Well the error is more like :
java.lang.RuntimeException: javax.naming.NameNotFoundException: Name foo is not bound in this Context


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 9:58 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Sorry, not a Tomcat and JNDI user. Anyone ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 11:23 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Hibernate can't bind a SessionFactory to JNDI in Tomcat. The Tomcat JNDI context is a half-finished read-only implementation. Get a real context and read about it here:

http://www.hibernate.org/Documentation/ ... catAndJNDI

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 11:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I suspect you are trying to use the stuff posted by mark.lowe in the comment section? This will not work with Tomcat as Christian said. As far as i understand the Struts Plugin Approach you should just have to configure this plugin in Struts, and then get the SessionFactory from the Servlet Context if you need it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:06 pm 
Newbie

Joined: Tue Feb 10, 2004 2:11 pm
Posts: 15
gloeglm wrote:
I suspect you are trying to use the stuff posted by mark.lowe in the comment section? This will not work with Tomcat as Christian said. As far as i understand the Struts Plugin Approach you should just have to configure this plugin in Struts, and then get the SessionFactory from the Servlet Context if you need it.


Do you mean that I should configure this in the struts.config.xml file?

emm... could you perhaps show me an example?

The thing is, in the example at http://www.hibernate.org/105.html, it seemed the only changes to be made were in the Hibernate.cfg.xml file and action file, and I made these changes....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well as far as I have understood this, you have to put the <plug-in> element stuff into your struts-config.xml and can then lookup your session factory in the servlet context. I can't give you an example because I don't use struts.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page 1, 2  Next

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.