Java Binding

R

Raghu

Hi,

Here is my problem. I am using Castor for Java Binding. I am getting
the following run-time error when i run my program (Source code
provided).

java.lang.NoClassDefFoundError: org/apache/xml/serialize/XMLSerializer
at org.exolab.castor.xml.Marshaller.initialize(Marshaller.java:393)
at org.exolab.castor.xml.Marshaller.<init>(Marshaller.java:354)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:662)
at XMLJavaBinding.TestBinding.main(TestBinding.java:31)
Exception in thread "main"

Source Code :

package XMLJavaBinding;
import java.io.*;
import org.exolab.castor.xml.*;

public class TestBinding {

public static void main(String[] args) {
FlightBean bean = new FlightBean ();
bean.setCarrier ("Lufthansa");
bean.setNumber (426);
bean.setDepartureTime ("6:30a");
bean.setArrivalTime ("8:45a");

try {
File file = new File ("test.xml");
Writer writer = new FileWriter (file);
Marshaller.marshal (bean, writer);

Reader reader = new FileReader (file);
FlightBean read = (FlightBean) Unmarshaller.unmarshal
(FlightBean.class, reader);
System.out.println ("Flight " + read.getCarrier () + read.getNumber
() + " departing at " +
read.getDepartureTime () + " and arriving at " +
read.getArrivalTime ());
} catch (IOException ex) {
ex.printStackTrace (System.err);
} catch (MarshalException ex) {
ex.printStackTrace (System.err);
} catch (ValidationException ex) {
ex.printStackTrace (System.err);
}
}
}

package XMLJavaBinding;

public class FlightBean {
private String m_carrier;
private int m_number;
private String m_departure;
private String m_arrival;

public FlightBean () {}
public void setCarrier (String carrier) {
m_carrier = carrier;
}

public String getCarrier () {
return m_carrier;
}

public void setNumber (int number) {
m_number = number;
}

public int getNumber () {
return m_number;
}

public void setDepartureTime (String time) {
m_departure = time;
}

public String getDepartureTime () {
return m_departure;
}

public void setArrivalTime (String time) {
m_arrival = time;
}

public String getArrivalTime () {
return m_arrival;
}
}
 
C

Christophe Vanfleteren

Raghu wrote:

<snip exact same code>

Why are you posting the exact same problem again? Have you tried any of the
suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top