Castor & Tomcat
I can get Castor to work with jdk1.5.0 & Tomcat4.1.24, but not with Tomcat5.5.9. I have included the commons-logging.jar in my context, but to no avail. The behaviour is to exit the try block without completing it, but not entering the catch block. I am using castor0.9.6-xml.jar. Any ideas?
The run() method of the following class works when called within Tomcat4.1.24, but not Tomcat5.5.9.
/*
*@(#)Test.java
* Has the following on the classpath
* castor-0.9.6-xml.jar
* commons-logging.jar;
*/
import java.io.*;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.mapping.MappingException;
import org.exolab.castor.tools.MappingTool;
import org.xml.sax.InputSource;
public class Test
{
private String field1 = "value of field1";
private String field2 = "another value";
public Test()
{
}
public static void run()
{
String mapName = "C:" + File.separator + "TestMap.xml";
Mapping mapping = new Mapping();
try
{
System.out.println("About to create new MappingTool()");
MappingTool mt = new MappingTool();
System.out.println("About to addClass()");
mt.addClass(Test.class, true);
System.out.println("About to write()");
mt.write(new FileWriter(mapName));
}
catch (Exception e)
{
System.out.println("Error writing map file: " + mapName);
}
}
public static void main(String[] args)
{
System.out.println("Pre run()");
run();
System.out.println("post run()");
System.exit(0);
}
public void setField1(String field1)
{
this.field1 = field1;
}
public void setField2(String field2)
{
this.field2 = field2;
}
public String getField1()
{
return (this.field1);
}
public String getField2()
{
return (this.field2);
}
}
|