Posts

Showing posts from July, 2008

Remotely debugging JBoss

When working with JBoss sometimes it's needed to debug your code while running instead of running your application in a lightweight servlet container like Jetty or Tomcat. This can be done by adding the following line to your run.bat or run.sh: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 You need to add this to your JAVA_OPTS variable so it will be used when JBoss starts up. When starting up now you can attach a debugger i.e. in Eclipse to the port you specified. :-)

Hibernate LazyInitializationException

People who use Hibernate will surely come across this irritating exception. In my whole career I have encountered this several times. Actually this problem is quite easily to fix. Let's start with when this exception can occur... Most of the time it has to do with a collection that is mapped to some objects that are lazily loaded. Lazy loading is used when you don't need the collection every time you retrieve the specific object. So i.e. you have an object called Person that can have multiple PhoneNumber objects. The objects will look something like this: public class Person { private String name; private Integer age; private Set phoneNumbers; ..... } public class PhoneNumber { private String areaCode; Publish Post private String number; private Person person; ..... } Having mapped the collection as lazy (Hibernate3 defaults to lazy) the call to the collection will cause an LazyInitializationException when you ...