struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Hertz" <jhe...@speakeasy.net>
Subject RE: Hibernate 2.1.X and Struts 1.2
Date Thu, 22 Apr 2004 21:02:26 GMT
Unfortunately, not a bit :(

It's not getting to the point of storing the SessionFactory in the JNDI
tree or Servlet Context. It dies on construction of the SessionFactory.

Ted's Plugin from the Struts-Hibernate example (still there as it turns
out) avoids JNDI anyway.

The current plugin listed on Hibernate.org *can* avoid it too, so I
grabbed it and tweaked it to provide some of the same Session
obtaining/releasing methods Ted's had.

Both PlugIns behave identically for me. It will complain about hbm.xml
errors if I have them, but once all solved, boom, NoClassDefFoundError

It be nice if someone on the Hibernate.org forum chimed in. I'm going a
bit nuts -- I'm getting closer to start questioning the contents of the
Hibernate Distribution I downloaded since this was supposed to be a
2.1.1 issue.

> -----Original Message-----
> From: John McGrath [mailto:jmcgrath@whoi.edu] 
> Sent: Thursday, April 22, 2004 4:46 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Hibernate 2.1.X and Struts 1.2
> 
> 
> we wrote our own. we might be doing this back-assward, but 
> basically our first step is to put the factory we want into 
> the JNDI tree. with tomcat or resin, this is done in 
> server.xml or web.xml; in weblogic it's done with a startup 
> class (ours is ContentServiceFactoryStartup, it puts an 
> instance of our edu.whoi.cms.ContentServiceFactory into JNDI).
> 
> then we have a class called edu.whoi.cms.ContentServiceFactoryPlugIn,
> which implements org.apache.struts.action.PlugIn. it's most 
> important job is to put the Factory into the servlet context, 
> where it can be accessed by action classes. here's an excerpt:
> 
> public void init( ActionServlet servlet, ModuleConfig config ) { ...
>   Context ctx = (Context) new InitialContext();
>   ContentServiceFactory theFactory = 
> (ContentServiceFactory)ctx.lookup(
> "ContentServiceFactory" );
>   this.theServlet = servlet;
>   servletCxt.setAttribute("CONTENT_SERVICE_FACTORY", 
> theFactory); ... }
> 
> 
> ContentServiceFactory has a method called getContentService, 
> this returns our content service interface (IContentService). 
> it's a little indirect, but if we ever decide to bail on 
> hibernate and use, say, iBatis, we would have to write an 
> iBatis implementation of IContentService, but none of our 
> other code would change.
> 
> this all gets triggered at startup by this line in struts-config:
> 
>   <plug-in className="edu.whoi.cms.ContentServiceFactoryPlugIn" />
> 
> then with our action classes, we have a BaseAction class that 
> all other action classes inherit. BaseAction has a 
> getContentService method:
> 
> public IContentService getContentService() {
>   return ( ( ContentServiceFactory ) 
> getServlet().getServletContext().getAttribute( 
> CONTENT_SERVICE_FACTORY )).getContentService(); }
> 
> so any action class can get a contentService instance, and 
> call stuff like getArticlesForUser (User theUser), etc, and 
> these methods actually execute the hibernate calls.
> 
> hope that helps,
> john
> 
> -----Original Message-----
> From: Joe Hertz [mailto:jhertz@speakeasy.net] 
> Sent: Thursday, April 22, 2004 2:43 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Hibernate 2.1.X and Struts 1.2
> 
> 
> What Plugin are you using?
> 
> Specifically, how do you go about generating your SessionFactory?
> 
> > -----Original Message-----
> > From: John McGrath [mailto:jmcgrath@whoi.edu]
> > Sent: Thursday, April 22, 2004 2:13 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Hibernate 2.1.X and Struts 1.2
> > 
> > 
> > we're using Struts 1.2 and Hibernate 2.1, works great, 
> though it took 
> > a little fiddling with the jars and classpath to get it 
> going. also, 
> > we had some problems with the version of cglib2 that came with 
> > hibernate (i think it was RC2), so we downloaded the final 
> version of 
> > 2, that worked.
> > 
> > we also had to make some other adjustments when we upgraded struts; 
> > for example, we use WebLogic 6.1, which needed to be 
> patched to sp3 to 
> > work.
> > 
> > this is what's in our classpath:
> > 
> > classes12.jar
> > weblogic.jar
> > mysql.jar
> > 
> > connector.jar
> > odmg-3.0.jar
> > struts.jar
> > hibernate2.jar
> > hibernate-tools.jar
> > dom4j-1.4.jar
> > jdom.jar
> > jdbc2_0-stdext.jar
> > jcs-1.0-dev.jar
> > cglib2.jar
> > ehcache-0.6.jar
> > log4j-1.2.8.jar
> > c3p0-0.8.3.jar.jar
> > proxool-0.8.3.jar
> > xalan-2.4.0.jar
> > xerces-2.4.0.jar
> > xml-apis.jar
> > 
> > # Commons jars
> > commons-collections-2.1.jar
> > commons-dbcp-1.1.jar
> > commons-digester.jar
> > commons-pool-1.1.jar
> > commons-lang-1.0.1.jar
> > commons-fileupload.jar
> > commons-logging-1.0.3.jar
> > commons-beanutils.jar
> > commons-validator.jar
> > 
> > john
> > 
> > 
> > -----Original Message-----
> > From: Joe Hertz [mailto:jhertz@speakeasy.net]
> > Sent: Thursday, April 22, 2004 10:16 AM
> > To: 'Struts Users Mailing List'
> > Subject: Hibernate 2.1.X and Struts 1.2
> > 
> > 
> > I'm trying to upgrade from Hibernate 2.0.3 to 2.1.2, and my 
> > pre-existing Hibernate Plugin hates it. (It's based on the 
> > Struts-Hibernate example Ted wrote, which doesn't appear to be on 
> > sourceforge. anymore).
> > 
> > I'm getting this exception, which implies I'm loading old jar files 
> > from 2.0.3, but I don't see them.
> > 
> > java.lang.NoClassDefFoundError
> >  at
> > net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configu
> > ration.jav
> > a:750) 
> > 
> > I am concerned that there may be a conflict with some of 
> the commons 
> > libraries Hibernate wants vs with what Struts wants (note 
> > commons-collections and commons-logging below).
> > 
> > Anyone else go through this?
> > 
> > Here's the jars my IDE says it is deploying:
> > 
> > FormDef.jar
> > activation.jar
> > antlr.jar 
> > cglib-2.0.jar 
> > commons-beanutils.jar 
> > commons-collections-2.1.jar 
> > commons-collections.jar 
> > commons-dbcp-1.1.jar 
> > commons-digester.jar 
> > commons-fileupload.jar 
> > commons-lang-1.0.1.jar 
> > commons-logging-1.0.3.jar 
> > commons-logging.jar 
> > commons-pool-1.1.jar 
> > commons-validator.jar 
> > dom4j-1.4.jar 
> > ehcache-0.6.jar 
> > hibernate2.jar 
> > jaas.jar 
> > jakarta-oro.jar 
> > jakarta-regexp-1.3.jar 
> > jcs-1.0-dev.jar 
> > jdbc2_0-stdext.jar 
> > jgroups-2.2.jar 
> > jstl.jar 
> > jta.jar 
> > junit-3.8.1.jar 
> > log4j-1.2.8.jar 
> > mail.jar 
> > odmg-3.0.jar 
> > oscache-2.0.jar 
> > proxool-0.8.3.jar 
> > standard.jar 
> > struts-el.jar 
> > struts.jar 
> > swarmcache-1.0rc2.jar 
> > xalan-2.4.0.jar 
> > xerces-2.4.0.jar 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message