Why do I get class loading errors from JSPs or servlets when the EJB Container is running in-process?
Why do I get class loading errors from JSPs or servlets when the EJB Container is running in-process? |
The problem has to do with class loaders. As you may already know, your JSPs, Servlets, and your EJBs run in custom class loaders. This is what allows you to dynamically install a new Servlet or EJB to a running VM and have this new code run dynamically. Unfortunately, writing code which can run correctly in a class-loaded environment is a little different than writing normal code. However, the good news is that, if you write code which can run in a class loader, then this code will also run in a normal environment. There is basically one rule to follow, when running in a class loader: always load your classes with respect to another class-loaded class. Simply put, this means you cannot do the following:
Also, problems can occur with the use of the MetaData. Here, we are returning instances of classes, where it may not be the case that these classes are the right ones with respect to your Servlet's class loader. To avoid this problem, you could try:
|
Article originally contributed by Borland Developer Support