QUESTION:

I'm having a problem with OJB and Apache Tomcat servlet context reloads. In my simple authentication method, I'm just grabbing a user object out of the DB based on the username (primary key) & then checking out matching passwd's etc. This works great until my servlet context is reloaded... Then I start getting strange messages from the persistence broker & my user objects are not retrieved.

Here's the error:

 [org.apache.ojb.broker.core.PersistenceBrokerImpl] WARN: Candidate object [System User: admin] 
 class [net.dlugosz.core.SystemUser] is not a subtype of [net.dlugosz.core.SystemUser] or
 any type of proxy. NOT INCLUDED in result collection

Anyone have any idea as to what may be causing this, or how I can fix it? If I fully restart Tomcat everything works fine. It's just when the context reloads automatically due to a class being compiled. This shouldn't be an issue in the real world, but it's frustrating in development.

Thanks! - RyanDlugosz

SIMILAR QUESTION:

Using OJB with the JDO API and Apache Tomcat, the source below works fine until the context reloads. My source was retrieving an object from an Extent Iterator:

 Extent allSchools = persistenceManager.getExtent(School.class, true);
 for (Iterator i = allSchools.iterator(); i.hasNext();) {
  School school = (School) i.getNext();  // <-- ClassCastException here (only after context reloads)
  ...

The error that I get is a ClassCastException on the indicated line. Interestingly, if I added a line that dumped the class of the next Object like this:

  Object obj = i.getNext();
  System.out.println("obj class: " + obj.getClass());

It would report that the object was indeed a "School".

The below answer solved my problem as well. Thanks! - mailto:nick@imagenmultimedia.com

ANSWER:

JimCushing was able to help me out with this. His response:

I did as he suggested and all is well. Thanks!

TomcatReloadBreaksOJB (last edited 2009-09-20 22:56:16 by localhost)