jLuger.de - Blog

How to catch unhandled exceptions
2011-02-24

When you've got uncaught exceptions that terminate your application you've got a bug. And a bug has to be fixed. Things change a little bit when you have to maintain a five year old application and the developers reveal more bugs than the tester. Especially when the bugs terminate the application without a notice. Then you would like to have a second line of defense that warns the user that something nasty has happened.
more


How to connect to an embedded derby via DataSource
2011-02-12

Here are some code samples on how to connect to an embedded derby instance via DataSource.
more


@Override and Interfaces in Java 6
2011-02-11

Today I've checked out a colleagues modules and got right away a compile error. It was complaining that a method was not overriding a method in any superclass. First I thought this error was caused due to some changes in the library the class was based on. But the colleague told me that he had checked in the latest version of the code and the used libraries. While I was at his workplace to ask him some details about his module he showed me the code in the IDE and there were no error markers but it was the absolutely same code that I had.
more


Refactor anonymous inner class to toplevel class in Eclipse
2011-01-14

When I need to provide Interface implementations or specialized classes I often create anonymous inner classes. When the class stays small and the isn't need at several places I keep the class where it is but when not I want to move it to a top level class that has its own file. Of course I can do copy&paste but with all the refactoring possibilities that Eclipse offers this seems to be a little bit lame. So I've searched a little bit and found a solution with Eclipse 3.6.1.
more


Replace connection properties in persistence.xml with ant
2010-11-29

When developing a JPA based application you may want to have different database settings for unit testing and production. The easy way is to have two persistence.xml files and let the ant task select which one to copy to your build artifacts. This approach gets very painful in the long run. You always have to remember to make changes in both files. And when you require a third connection you need to maintain three files. Wouldn't it be better when there is one persistence.xml and the different parts are in templates? Well I think so and the good news is that you can do this completely with ant.
more


Schemaexport with JPA 2.0
2010-11-12

Hibernates Schemaexport class is a great way to programmatically populate a database with the current schema of your application. Of course the class can't guess the database and other relevant options. So a configuration is needed. With org.hibernate.cfg.AnnotationConfiguration there is a class that reads in a hibernate.cfg.xml and takes all needed properties from there. But what to do when using JPA and there is only a persistence.xml? AnnotationConfiguration won't take this xml file. Luckily org.hibernate.ejb.Ejb3Configuration will. See the following code:
more


Run code without libs
2010-09-25

Run code without libs? What? Why? I had a utility class with references to hibernate jars. This class should also be executed at the client who doesn't have hibernate jars in its classpath. Why should it work? Well, the utility class is determining the runtime environment. For that it asks for the presence of "META-INF/persistence.xml". When there is none, it assumes that it runs in the client. When there is one, it checks the transaction type. Is it RESOURCE_LOCAL then it is executing the local unit tests and when it is JTA it is executed on the ApplicationServer. For checking the transaction type hibernate classes are used.
more


Exception when running wlappc from eclipse
2010-09-18

Recently I wanted to reorganize the jars imported from the weblogic to our Java EE project. For this I've changed the path and the kind of included jars. When I had found the minimal set of jars where the compiler was running without errors I wanted to create a ear file. Starting the build from eclipse I didn't get an ear file but the following exception:
more


Google App Innovator (beta)
2010-09-14

There are two magazines that I'm reading regularly:  Javamagazin and c't. The first one focuses on professional developers and project manager that are working on java based projects while the second one targets advanced computer users. Both have this month an article about Google App Innovator. A tool were you should be able to create programs for the Android platform via drag&drop of building blogs. These building blogs remind of colored pieces of a puzzle. If you want to know more about it you can read Googles homepage. The interesting part about the articles is their conclusion.
more


Custom primary key generator and JPA
2010-09-10

As you may know from other posts I'm currently at the beginning of a migration project from EJB 2.1 to EJB 3.0. So until recently we hadn't much code to deploy. But as we had made some progress I wanted to create a test deployment. Javac had compiled the code and some first unit tests were all green. Everything OK? Wlappc didn't thought so. Weblogics ejb compiler throw the following exception:
more



PreviousNewer