Account Options

  1. Sign in
Google Groups Home
« Groups Home
Shutting down Ebean
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Alex  
View profile  
 More options Oct 17 2009, 11:40 am
From: Alex <alxa...@googlemail.com>
Date: Sat, 17 Oct 2009 08:40:51 -0700 (PDT)
Local: Sat, Oct 17 2009 11:40 am
Subject: Shutting down Ebean
Hi,

A quick newbie question: how do we shutdown Ebean? After the main
thread has finished I have following threads:

BackgroundThread
H2 File Lock Watchdog
H2 Log Writer
TransactionManager.0
Timer-0
Timer-1
DestroyJavaVM

I've tryed calling ShutdownManager.shutdown() but I still have

Timer-0
Timer-1
DestroyJavaVM

running in background.

Thanks in advance

alx

P.S.1: My system

Ebean 2.1.0
DB: H2 Version 1.2.121
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)
OS: Ubuntu 8.0.4 LTS

P.S.2: By the way, I'm very new to Ebean, and its ORM approach seems
very interesting to me, but I'm having some trouble starting using it.
I've found the User Guide very good, but it would be very nice to have
very simple ready to run examples (yes, I've downloaded
EbeanExampleApp and I'm currently getting acquainted to it) such as:

Howto 1 - Hello World (with DDL)
Howto 2 - Saving / Retrieving objects (simple queries)
Howto 3 - ...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
edge  
View profile  
 More options Oct 17 2009, 12:16 pm
From: edge <e.mcgr...@imilia.com>
Date: Sat, 17 Oct 2009 09:16:47 -0700 (PDT)
Local: Sat, Oct 17 2009 12:16 pm
Subject: Re: Shutting down Ebean
some if not all of those threads might belong to H2 so you probably
need to shout down H2 to get rid of them

On Oct 17, 5:40 pm, Alex <alxa...@googlemail.com> wrote:

If you download the Ebean source code from SVN you will see lots of
tests - they are pretty good example of how to use Ebean - lots of
queries, saves etc
Hope that helps
Eddie

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex  
View profile  
 More options Oct 17 2009, 12:53 pm
From: Alex <alxa...@googlemail.com>
Date: Sat, 17 Oct 2009 09:53:54 -0700 (PDT)
Local: Sat, Oct 17 2009 12:53 pm
Subject: Re: Shutting down Ebean
Thanks for the hint.

> some if not all of those threads might belong to H2 so you probably
> need to shout down H2 to get rid of them

So, does anybody knows how can we get a reference to the underlying
database object (in this case I think it is an instance of
org.h2.engine.Database) ? By the way, isn't it something that Ebean
should take care of? I didn't initialize the db, so I shouldn't be
required to shut it down myself.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Bygrave  
View profile  
 More options Oct 17 2009, 8:50 pm
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Sun, 18 Oct 2009 13:50:36 +1300
Local: Sat, Oct 17 2009 8:50 pm
Subject: Re: [ebean] Re: Shutting down Ebean

When running the example application you should not need to shutdown H2.

It's actually not clear to me what you are doing and what your issue is ...
but I'll guess and say you are running the example application ... one of
the classes with a main method... and it is hanging / not terminating?

I haven't come across any problem like that... is this your issue or am I
misunderstanding?

Note that Ebean registers with the JVM shutdown hook ... and uses that to
close it's resources such as thread pools and Connection pools. It also can
trigger a GC to collection profiling information for Autofetch (with a small
wait of 100ms from memory).

Thanks, Rob.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex  
View profile  
 More options Oct 18 2009, 11:13 am
From: Alex <alxa...@googlemail.com>
Date: Sun, 18 Oct 2009 08:13:10 -0700 (PDT)
Local: Sun, Oct 18 2009 11:13 am
Subject: Re: Shutting down Ebean
Hi,
no, I'm not running the example application. Well, I've decided to
write a minimalistic howto on start using Ebean, please have a look
at  http://alxa.wikidot.com/ebean-howto-1 for the complete setup.

Below the main code:

public class HelloWorld {
    public static void main(String[] args) {
        // ### Configuration Objects ###
        ServerConfig serverConfig = new ServerConfig();
        DataSourceConfig dataSourceConfig = new DataSourceConfig();

        // ### Configuration Settings ###
        // -> data source
        dataSourceConfig.setDriver("org.h2.Driver");
        dataSourceConfig.setUsername("howtouser");
        dataSourceConfig.setPassword("");
        dataSourceConfig.setUrl("jdbc:h2:db/howto1");

        // -> server
        serverConfig.setName("default");
        serverConfig.setDataSourceConfig(dataSourceConfig);

        //  auto create db if it does not exist
        if(!(new File("db/howto1.h2.db")).exists()  ){
            serverConfig.setDdlGenerate(true);
            serverConfig.setDdlRun(true);
            serverConfig.addClass(Hello.class);
        }

        EbeanServer eServer = EbeanServerFactory.create(serverConfig);

        long id = 3;
        Hello data = eServer.find(Hello.class, id);
        if (data == null) {
            System.out.println("This is the first run, saving
data..");
            eServer.save(new Hello(id, "Hello World!"));
        } else {
            System.out.println(String.format("############\n%s
\n############", data.getMessage()));
        }
        ShutdownManager.shutdown();
    }

}

Thanks in advance

alx

On 18 Okt., 02:50, Rob Bygrave <robin.bygr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
edge  
View profile  
 More options Oct 18 2009, 2:10 pm
From: edge <e.mcgr...@imilia.com>
Date: Sun, 18 Oct 2009 11:10:30 -0700 (PDT)
Local: Sun, Oct 18 2009 2:10 pm
Subject: Re: Shutting down Ebean
I tried this out and you have to wait a while (1 min exactly as far as
I can tell) for the app to shutdown but it does shutdown cleanly (I
tried this in mvn, java command line and eclipse)
... so I wondering why it takes so long - none of our test cases show
this behaviour - why it takes so long in this case is strange
seem like there is a wait of 1 min somewhere
so a few things I ruled out
1. Its not specific to H2 - I tried MySQL and it also took 1 min
2. Placing the data access code in an extra method @Transactional in
case the app was waiting on a connection to close didn't help either

must be one of the daemon threads that is waiting ... any ideas Rob?

On Oct 18, 5:13 pm, Alex <alxa...@googlemail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Bygrave  
View profile  
 More options Oct 18 2009, 5:44 pm
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Mon, 19 Oct 2009 10:44:42 +1300
Local: Sun, Oct 18 2009 5:44 pm
Subject: Re: [ebean] Re: Shutting down Ebean

I haven't tried this yet.  The code looks fine ... the line
"serverConfig.addClass(Hello.class);" ... should probably be outside that if
statement (you always register the bean even if you don't run the DDL).

You don't (shouldn't) need that explicit call to
ShutdownManager.shutdown();  Ebean registers a shutdown hook ... we should
never need to code that ourselves. I'm pretty sure you added that after you
got this issue.

I think we are running different JVM's (Linux, MacOS and I'm using Windows
mostly).

So yeah, I'll give it a go tonight. A ~1min wait/hang at shutdown ... I'll
probably look to use MySql so as to discount H2 background threads from the
issue.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex  
View profile  
 More options Oct 19 2009, 2:00 am
From: Alex <alxa...@googlemail.com>
Date: Mon, 19 Oct 2009 08:00:41 +0200
Local: Mon, Oct 19 2009 2:00 am
Subject: [ebean] Re: Shutting down Ebean
Hi

> I haven't tried this yet.  The code looks fine ... the line
> "serverConfig.addClass(Hello.class);" ... should probably be outside that if
> statement (you always register the bean even if you don't run the DDL).

ok

> You don't (shouldn't) need that explicit call to
> ShutdownManager.shutdown();  Ebean registers a shutdown hook ... we should
> never need to code that ourselves. I'm pretty sure you added that after you
> got this issue.

yes, that was the reason why I've added that.

> I think we are running different JVM's (Linux, MacOS and I'm using Windows
> mostly).
> So yeah, I'll give it a go tonight. A ~1min wait/hang at shutdown ... I'll
> probably look to use MySql so as to discount H2 background threads from the
> issue.

great, thanks, alx

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Bygrave  
View profile  
 More options Oct 19 2009, 2:38 am
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Mon, 19 Oct 2009 19:38:40 +1300
Local: Mon, Oct 19 2009 2:38 am
Subject: Re: [ebean] Shutting down Ebean

Hmmm. Well, I wasn't able to reproduce... in that it terminated in about 1
second or so.

I wonder if it is specific to a particular JDK/JVM.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Bygrave  
View profile  
 More options Nov 17 2009, 5:44 am
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Tue, 17 Nov 2009 02:44:56 -0800 (PST)
Local: Tues, Nov 17 2009 5:44 am
Subject: Re: Shutting down Ebean

Ok, I reproduced it and found the problem with Ebean not shutting down
in a timely fashion.

Logged as BUG 176 : Shutdown taking 30 secs or so ... should be
immediate

http://www.avaje.org/bugdetail-176.html

The problem was there is optionally a Timer that is used to warm the
Ebean server cache. That Timer was not a daemon ... so effectively
stopped the JVM from shutting down - hence hanging for 30 secs or so.
The fix was to make the Timer a daemon - I also made the thread names
a bit more meaningful.

Fixed in HEAD.

Cheers, Rob.

On Oct 19, 7:38 pm, Rob Bygrave <robin.bygr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex  
View profile  
 More options Nov 26 2009, 2:17 pm
From: Alex <alxa...@googlemail.com>
Date: Thu, 26 Nov 2009 20:17:54 +0100
Local: Thurs, Nov 26 2009 2:17 pm
Subject: Re: [ebean] Re: Shutting down Ebean
Thanks, with ebean 2.2.0 it works fine now. By the way, where can I get
the artifact com.oracle-oracle:10.2.0.2.0 from? I've created a dummy
oracle jdbc in order to compile ebean, but it would be nice if it were
possible to have references of closed source software out of
ebean-core. Maybe an ebean-oracle artifact?

Cheers, alx

2009/11/17 Rob Bygrave <robin.bygr...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Bygrave  
View profile  
 More options Nov 26 2009, 3:26 pm
From: Rob Bygrave <robin.bygr...@gmail.com>
Date: Fri, 27 Nov 2009 09:26:27 +1300
Local: Thurs, Nov 26 2009 3:26 pm
Subject: Re: [ebean] Re: Shutting down Ebean

> where can I get the artifact com.oracle-oracle:10.2.0.2.0 from?

I'm keen to put the non-maven dependencies (aka like the oracle jdbc driver)
into svn so that people don't have to find it. Mario had a mechanism to do
that with maven via 'system dependencies' I believe so I think (if I
understood correctly) so I think we just need to re-instate that.

Yes, at the moment it's a PITA for anyone as they have to track down the
Oracle jdbc drivers to compile from source.

Mario, if you have time you can re-instate that 'system dependency' thing
you did and stick the oracle jdbc jar into svn.

NB: Just as a reminder ... the reason why we have a dependency on the Oracle
jdbc drivers is that they don't fully support JDBC statement batching via
the standard api (PreparedStatement.executeBatch()) - specifically it
doesn't currently return the row counts from the batched statement execution
(which we need for optimistic concurrency control). So for Oracle we need to
use the OraclePreparedStatement - joy.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »