You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Anderson <ar...@semiosix.com> on 2005/05/03 21:38:50 UTC

Hibernate Configuration and SessionFactory startup time

Hi everyone

A little background: I'm working on my first Tapestry app. I've been
involved with Java since 1.0, and involved with software dev for a lot
longer.

I'm using Hibernate for db access, having had much joy with it on
previous projects. The Hibernate Configuration and SessionFactory take
quite a while to start up. I've stashed the SessionFactory in a
subclassed Global object, and I'm doing Session disconnect/reconnect in
a subclassed Engine object. So far so good.

I have Tomcat configured via server.xml up to use my dev directory as a
webapp. Which has worked well for previous non-Tapestry apps.

Here's the problem: in order to get changes to the Java files showing up
via Tomcat, I need to enable reloading in Tomcat. But then every time
a .class file in the classes subdir changes, the app reloads. Which is
fine except for the long Hibernate startup time.

I've tried stashing the SessionFactory in another servlet, but that also
gets reloaded.

Of course I already have org.apache.tapestry.disable-caching=true, and
that's working nicely for the pages themselves.

The other option I thought of was to stash the SessionFactory in JNDI.
That has it's own drawbacks though, not least being the need to set up a
JNDI provider, and the fact that since I'm already cramming Tapestry
into my overloaded brain I'd prefer to avoid cramming yet another API in
as well.

So I'd really appreciate any suggestions how Hibernate can be used
without suffering the long startup time each time a .class file changes

thanks
John



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by John Anderson <ar...@semiosix.com>.
On Fri, 2005-05-06 at 16:46 -0500, Javier Sanchez wrote:
> Just use JNDI.  JBoss 3.2.7 supports Hibernate in native form making
> this configuration easier.  You just have to build the .har file,
> DS,... JBoss understands those files with no extra effort.

The configuration itself is fine. What I'm not happy with is the
constant recreating of the SessionFactory.

Is it possible to serialize a SessionFactory instance in JNDI? If so is
there a fairly lightweight JNDI provider I can use? I don't want to use
up 400M of memory running JBoss when I'm going to use only JNDI.

thanks
John



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by Javier Sanchez <ja...@gmail.com>.
Just use JNDI.  JBoss 3.2.7 supports Hibernate in native form making
this configuration easier.  You just have to build the .har file,
DS,... JBoss understands those files with no extra effort.

JAVIER SANCHEZ

On 5/6/05, Kent Tong <ke...@cpttm.org.mo> wrote:
> John Anderson <ardour <at> semiosix.com> writes:
> 
> > Exactly. But usually after one has made a change to a .class file, one
> > wants to see that the change did what one expected it to, not so?
> 
> It only takes a couple of seconds to configure the Configuration
> object for each test run. How does it bother you? If it is taking
> a lot of time, are you using logging? This will slow it down
> significantly.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

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


Re: Hibernate Configuration and SessionFactory startup time

Posted by Kent Tong <ke...@cpttm.org.mo>.
John Anderson <ardour <at> semiosix.com> writes:

> 10-20 seconds to reload the app, of which Hibernate is usually 5 - 8.
> Which doesn't seem like much, except when you do a change that takes 20
> or 30 seconds, and you do an hour of that, you spend 15-20 minutes of
> that hour waiting for app reloads.

How many persistent classes do you have? Have you tried the 
serialization tip (http://www.hibernate.org/194.html)?




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


Re: Hibernate Configuration and SessionFactory startup time

Posted by John Anderson <ar...@semiosix.com>.
On Fri, 2005-05-06 at 10:27 +0000, Kent Tong wrote:
> John Anderson <ardour <at> semiosix.com> writes:
> 
> > Exactly. But usually after one has made a change to a .class file, one
> > wants to see that the change did what one expected it to, not so?
> 
> It only takes a couple of seconds to configure the Configuration
> object for each test run. How does it bother you?

10-20 seconds to reload the app, of which Hibernate is usually 5 - 8.
Which doesn't seem like much, except when you do a change that takes 20
or 30 seconds, and you do an hour of that, you spend 15-20 minutes of
that hour waiting for app reloads.

And regardless of the numbers, it got to the point where that startup
time of the app was annoying.

> If it is taking a lot of time, are you using logging? This will slow
> it down significantly.

Exactly. I'm only allowing log4j to show Hibernate warnings, so I can
see if something goes wrong. The reams and reams of debug logging is
turned off. An app restart generates about 10 lines of logging, which I
don't think is going to cause much of a slowdown.

bye
John



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by Kent Tong <ke...@cpttm.org.mo>.
John Anderson <ardour <at> semiosix.com> writes:

> Exactly. But usually after one has made a change to a .class file, one
> wants to see that the change did what one expected it to, not so?

It only takes a couple of seconds to configure the Configuration
object for each test run. How does it bother you? If it is taking
a lot of time, are you using logging? This will slow it down
significantly.



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by John Anderson <ar...@semiosix.com>.
On Thu, 2005-05-05 at 08:11 +0000, Kent Tong wrote:
> John Anderson <ardour <at> semiosix.com> writes:
> 
> > Thanks for your suggestion. I tried that, but the Global class seems to
> > be destroyed every time one of the .class files in the app changes.
> 
> But it will not be recreated until an http request hits your app again.

Exactly. But usually after one has made a change to a .class file, one
wants to see that the change did what one expected it to, not so?

bye
John



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by Kent Tong <ke...@cpttm.org.mo>.
John Anderson <ardour <at> semiosix.com> writes:

> Thanks for your suggestion. I tried that, but the Global class seems to
> be destroyed every time one of the .class files in the app changes.

But it will not be recreated until an http request hits your app again.


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


Re: Hibernate Configuration and SessionFactory startup time

Posted by John Anderson <ar...@semiosix.com>.
On Thu, 2005-05-05 at 01:01 +0000, Kent Tong wrote:
> John Anderson <ardour <at> semiosix.com> writes:
> 
> > What I don't like is that every time I change something in the .java
> > files for the project, I have to wait 8-15 seconds for  the restart to
> > happen. Which adds up to lots of what when it's part of the
> > change/compile/reload cycle.
> > 
> > What exactly do you mean by "whenever your app is run"? Whenever a page
> > request hits the server?
> 
> Yes. Just create the Configuration in the constructor
> of your Global class. It will be created on the first
> http request.

Thanks for your suggestion. I tried that, but the Global class seems to
be destroyed every time one of the .class files in the app changes.

bye
John



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by Kent Tong <ke...@cpttm.org.mo>.
John Anderson <ardour <at> semiosix.com> writes:

> What I don't like is that every time I change something in the .java
> files for the project, I have to wait 8-15 seconds for  the restart to
> happen. Which adds up to lots of what when it's part of the
> change/compile/reload cycle.
> 
> What exactly do you mean by "whenever your app is run"? Whenever a page
> request hits the server?

Yes. Just create the Configuration in the constructor
of your Global class. It will be created on the first
http request.



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by John Anderson <ar...@semiosix.com>.
On Wed, 2005-05-04 at 01:41 +0000, Kent Tong wrote:
> John Anderson <ardour <at> semiosix.com> writes:
> 
> > Here's the problem: in order to get changes to the Java files showing up
> > via Tomcat, I need to enable reloading in Tomcat. But then every time
> > a .class file in the classes subdir changes, the app reloads. Which is
> > fine except for the long Hibernate startup time.
> 
> Are you saying that the Hibernate Configuration is loaded
> again whenever your app is reloaded or whenever your app
> is run?

Whenever the app is reloaded, which is as often as the .class files
change in the classes directory.

What I don't like is that every time I change something in the .java
files for the project, I have to wait 8-15 seconds for  the restart to
happen. Which adds up to lots of what when it's part of the
change/compile/reload cycle.

What exactly do you mean by "whenever your app is run"? Whenever a page
request hits the server?

bye
John



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


Re: Hibernate Configuration and SessionFactory startup time

Posted by Kent Tong <ke...@cpttm.org.mo>.
John Anderson <ardour <at> semiosix.com> writes:

> Here's the problem: in order to get changes to the Java files showing up
> via Tomcat, I need to enable reloading in Tomcat. But then every time
> a .class file in the classes subdir changes, the app reloads. Which is
> fine except for the long Hibernate startup time.

Are you saying that the Hibernate Configuration is loaded
again whenever your app is reloaded or whenever your app
is run? If it's the former and you don't mind the latter,
you can create the Configuration on-demand in your Global.



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