Tomáš Hubálek Blog: Bavte se přiměřeně

Reklama

Čtvrtek, 08.11.07

hibernate.hbm2ddl.auto - What do values create, create-drop, update and validate mean?

I was looking into documentation for Hibernate for the meaning of these options. Unfortunately it is not written there.

I found explanation on Eyal Lupu's blog... :-)

Enjoy...

Čtvrtek, 13.09.07

Java: How to display incomplete stacktrace?

A few days ago we met some issue and there was huge stacktrace finishing with ... 20 more.

We was disappointed that we cannot see real cause of the exception because we thought that Java is hiding most important exception details.

But in fact, there is nothing hidden, it is just misunderstanding of the stack trace.

Lets look at following java snippet:

01 public class Test {
02 
03    private static void a() {
04       try {
05          b();
06       catch (Exception e) {
07          throw new RuntimeException("Error occured in method a()", e);
08       }
09    }
10 
11    private static void b() {
12       try {
13          c();
14       catch (Exception e) {
15          throw new RuntimeException("Error occured in method b()", e);
16       }
17    }
18 
19    private static void c() {
20       throw new RuntimeException();
21    }
22 
23    public static void main(String a[]) throws Exception {
24      Test.a();
25    }
26 
27 }

Java2html

This code display following stack trace:

Exception in thread "main" java.lang.RuntimeException: Error occured in method a()
        at Test.a(Test.java:7)
        at Test.main(Test.java:24)
Caused by: java.lang.RuntimeException: Error occured in method b()
        at Test.b(Test.java:15)
        at Test.a(Test.java:5)
        ... 1 more
Caused by: java.lang.RuntimeException
        at Test.c(Test.java:20)
        at Test.b(Test.java:13)
        ... 2 more

and you can see complete stack trace although there is text .. 2 more and the real cause you can see at the top of the last exception.

For more info see description of the "bug" number 4775147 (Incomplete stack trace printed by Throwable.printStackTrace in JDK 1.4+) in Sun's bug parade.

Úterý, 20.02.07

NetBeans 6.0: I want it, I want it, I want it...

Here is an exciting demo of new features that will be available in NetBeans 6.0. I was amazed and I'm really looking forward some working beta version of NetBeans 6.0.
Tomáš Hubálek - pencil 15:08:30 - Java (in English) - pencil permalink - - Komentáře: 4 [22.02.07 19:39]

Úterý, 30.01.07

How to execute long running tasks in NetBeans platform...

We work on J2EE project based on NetBeans platform and we solve typical tasks. My first problem was execution of long running tasks.

Here is a solution:

private void jbExecuteActionPerformed(java.awt.event.ActionEvent evt) {                                          
    
  // start thread
  RequestProcessor.getDefault().post(new Runnable() {
     public void run() {
        ProgressHandle progress =
               ProgressHandleFactory.createHandle("Loading data...");
                
        progress.start(10);
                
        try {
          for (int i = 1; i < 10; i++) {
            try { 
              Thread.sleep(2000);
            } catch (InterruptedException ex) { }
             progress.progress(i);
          }
        } finally {
          progress.finish();
        }
     }
  });
}        

The trick is in RequestProcessor.getDefault().post(new Runnable(){...}).

Inside new Runnable(){...} you may optionally use NetBeans Progress API

Pátek, 12.01.07

NetBeans module and web services made easy...

I looked at Roumen's presentation regarding NetBeans Plaftorm and Web Services and I was impressed. It really looks very easy.

Older articles:

08.12.2006

30.10.2006