java.lang.NoClassDefFoundError and the bootstrap classloader

May 26, 2009 – 3:51 pm by Alessio SOLDANO
Share

Seasoned java developers know that the infamous java.lang.NoClassDefFoundError you can get at runtime might be due to a lot of different issues, the most trivial being libraries missing in classpath.

Of course tracking down the real problem might result quite more complex when multiple classloaders are involed. Things get even more subtle when the bootstrap classloader comes into play ;-)

I usually deal with a project requiring a couple of libraries to be installed to and loaded from a location specified when providing the virtual machine with the endorsed dir parameter (-Dendorsed.dirs=my_endorsed_dir). I’m not spending a lot of words on the reason for doing so, it should be enought to know I need to overwrite some classes already shipped with the JDK.

As you know the classes in libraries added to the endorsed dirs are loaded by the bootstrap classloader, before the system classloaders do their job with the other classes.

Yesterday I was adding a new API (interfaces only) to another module (ModuleB) of my project. After that I implemented the interfaces in my ModuleA, which builds to a jar that goes to endorsed dir. Compile phase all green, but NoClassDefFoundError at runtime.

Exception in thread “main” java.lang.NoClassDefFoundError: it/javalinux/blog/Foo
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:891)
at java.lang.ClassLoader.loadClass(ClassLoader.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

The classpath is OK. The libraries contain all the classes, including the Foo class. What’s happening then?

Well, I definitely did a mistake, ie. I put the Foo class in ModuleA while it implements FooInterface from ModuleB. Nothing dangerous in that besides *only one* of them is loaded by the bootclassloader, hence the NoClassDefFoundError.The Foo class is indeed available, but it’s loaded by another classloader.

So, aways think about the way your project classes are loaded and… look carefully at the exception dump, even in the java.lang.Classloader package section ;-)

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

WS-Trust presentation

May 5, 2009 – 6:57 pm by Alessio SOLDANO
Share

These days I’ve been looking at WS-Trust. The starting point when dealing with WS-* is of course reading the right specification(s), but often examples are useful too to simply get a basic understanding of the tech while leaving the deep-in-details analisys for later in the learning process.

Well, I was googling on WS-Trust last week and found out a really nice video presentation on this topic and more generally on means of achieving message integrity and confidentiality using web services. I’m quite busy recently but I admit I looked at the whole presentation (almost 1h) even if I actually knew most of the contents… that remembered me my early approaches to webservices and message security at the university (perhaps that’s because of the italian accent of the speaker ;-) ). I think developers beginning with WS and security might found this a nice clip, good to get an idea of how low level cryptography is used as the building block for higher level specs like WS-Trust.

http://channel9.msdn.com/shows/Going+Deep/Vittorio-Bertocci-WS-Trust-Under-the-Hood/

P.S. despite being on a msdn host, there’s almost nothing specific to Microsoft there ;-)

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

Java Application Server Day 2009

April 23, 2009 – 1:19 pm by Alessio SOLDANO
Share

This post is to let you know a really interesting event that’s taking place soon in Genoa (Italy): the Java Application Server Day 2009.

As you can read on www.serverday.org, the event will be open to the entire Italian Java Community; international experts, developers and students will discuss the state of the art
and the future of Java Application Servers, with a focus on the innovations of
the recently released JBoss 5.0, Spring dm Server, GlassFish 3.0 & Oracle/WebLogic.

I’ve been asked to be there on behalf of JBoss / Red Hat, so I’ll present the recent changes in JBoss AS 5.

Hope you can join the event on May, 21st. Stay tuned for further updates.

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

Analyze what personality is behind your blog

March 31, 2009 – 2:55 pm by Stefano MAESTRI
Share

According to this analyzer I’m  The Duty Fulfillers

The responsible and hardworking type. They are especially attuned to the details of life and are careful about getting the facts right. Conservative by nature they are often reluctant to take any risks whatsoever.
The Duty Fulfillers are happy to be let alone and to be able to work int heir own pace. They know what they have to do and how to do it.

It doesn’t perfectly fit on my personality, but for sure it isn’t too far.

Thanks to Mark Little for the link

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio

JBossWS and Apache CXF collaboration

March 26, 2009 – 12:13 pm by Alessio SOLDANO
Share

I’ve just pubblished a post on the JBosWS blog regarding the JBossWS involvement in the Apache CXF project. In few words, the JBossWS team is increasing its collaboration with the CXF developers, the target being to improve both projects.

It’s not that simple to achieve an active bi-directional collaboration, with both parties’ needs being considered, but this is working quite well now. For instance, read what Daniel Kulp (CXF lead) writes about the collaboration. Needless to say I like this, that’s a nice example of what open source can make possible.

 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • Technorati
  • YahooMyWeb
  • LinkedIn
  • StumbleUpon
  • TwitThis
  • Wikio