2 Replies Latest reply on Oct 20, 2002 4:56 AM by Fred Loney

    castor version in jboss3.0.2 / MappingException: cannot find

    tek1 Newbie

      [castor version in jboss3.0.2]

      does anyone know what version of castor is being used in jboss3.0.2?

      [MappingException: cannot find class]

      when running castor locally (i.e. on some junit tests), i had no problem using castor.

      however, i packaged up my persistence-related classes and castor-specific configuration files (database.xml and mapping.xml) into a persistence.jar, put that into a .war (with servlets that use the persistence.jar and other supporting .jars), and then into an .ear (had to specify some info in application.xml).

      i deployed the .ear to jboss3.0.2's server/default/deploy directory, but when my code in persistence.jar reached JDO.getDatabase(), at which it reads the mapping.xml and tries to load the classes specified there, i get the error message:

      14:20:00,154 ERROR [PersistenceMgr] Nested error: org.exolab.castor.mapping.MappingException: Could not find the class persistence.entity.User.

      the User class is in the persistence.jar, but for some reason the User class can't be found. i even tried putting the User class in its proper package/folder hierarchy in the /server/default/lib directory, but didn't work...

      i searched the castor mailing list and found that someone else had a similar problem, but with a different app server:

      any suggestions?

      thank you.

        • 1. Re: castor version in jboss3.0.2 / MappingException: cannot
          tek1 Newbie

          i found the problem, but it's very strange. jboss has a version (not sure which) of castor in [JBOSS]/server/default/lib, and i was also including the latest version of castor in my .war inside the .ear. i deleted the jboss version from the lib directory and it worked. if it was a conflict with the castor versions, i would have expected a different error than not being able to find one of my domain classes... maybe this could be a future feature of java or jboss (detecting if 2 of the same exact classes are in the classpath at runtime and somehow displaying an alert)...

          • 2. Re: castor version in jboss3.0.2 / MappingException: cannot
            Fred Loney Newbie

            This problem is due to the classloader hierarchy and is not a castor version problem. The jboss lib castor.jar resides in a classloader that is a parent of your webapp classloader. Castor relies on introspection and attempts to resolve the mapped classes using its classloader context, not the webapp or thread context. Your mapped application classes are therefore not found.

            You can supply a classloader argument to the Mapping constructor. That might solve your problem. Castor should use the current thread context classloader by default but it doesn't. This is a failing common to other open source middleware projects that rely on introspection, e.g. cactus.