When moving a formerly WebSphere Java EE application to JBoss EAP 6.3, a runtime exception was thrown when invoking the marshall(Object) method of Castor 1.0's org.exolab.castor.xml.Marshaller object:
org.exolab.castor.mapping.MappingException: Nested error: org.exolab.castor.mapping.MappingException: Could not find the class
{fully qualified Java class name}
(The Marshaller is trying to serialize an object to XML.)
I see no obvious class path issues. There is seemingly no reason why this application, which compiles fine using JBoss Developer Studio, would fail at runtime.
The problem occurs with the first Java class described in the mapping.xml file -- not with the class that I'm trying to serialize, unless by coincidence it happens to be the first class in the mapping.xml file.
What might be the problem, and what is a solution?
After scouring Google, I found the solution in this discussion thread from 2002:
https://developer.jboss.org/thread/21611
Per Fred Loney in that discussion thread:
Following the advice recommended in that thread, I changed my code to, rather than use the default constructor of org.exolab.castor.mapping.Mapping, instead use the constructor that accepts a ClassLoader argument, and I used the ClassLoader of the class of the object that I'm trying to serialize.
I hope Fred Loney's tip helps someone. It took me a while to find the problem and solution online!