Differences between revisions 1 and 2
Revision 1 as of 2004-02-29 13:49:12
Size: 2242
Editor: m017-173
Comment: Converted from Usemod wiki.
Revision 2 as of 2009-09-20 22:56:16
Size: 2242
Editor: localhost
Comment: converted to 1.6 markup
No differences found!


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


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


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

  • Make sure that you are not including the OBJ JAR files or any of the JAR files that it uses (commons-*.jar, etc.) in the classpath. Instead, include them only in your WEB-INF/lib directory. I've used OJB with Tomcat with no problem, so perhaps this will help.

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

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