>at main.main(main.java:51)
那一行是什么?你debug一下看你的stacktrace,好像是marshall回xml的时候出的问题

解决方案 »

  1.   

    下面是main.java的源代码:
    import org.exolab.castor.mapping.Mapping;
    import org.exolab.castor.mapping.MappingException;import org.exolab.castor.xml.Unmarshaller;
    import org.exolab.castor.xml.Marshaller;import java.io.IOException;
    import java.io.FileReader;
    import java.io.OutputStreamWriter;import org.xml.sax.InputSource;public class main {    public static void main(String args[]) {        Mapping      mapping = new Mapping();        try {
                // 1. Load the mapping information from the file
                mapping.loadMapping( "mapping.xml" );            // 2. Unmarshal the data
                Unmarshaller unmar = new Unmarshaller(mapping);
                MyOrder order = (MyOrder)unmar.unmarshal(new InputSource(new FileReader("order.xml")));            // 3. Do some processing on the data
                float total = order.getTotalPrice();
                System.out.println("Order total price = " + total);
                order.setTotal(total);            // 4. marshal the data with the total price back and print the XML in the console
                Marshaller marshaller = new Marshaller(new OutputStreamWriter(System.out));
                marshaller.setMapping(mapping);
                marshaller.marshal(order);//line51
    //上面这行有问题,只是不知改怎么改        } catch (Exception e) {
                System.out.println(e);
                return;
            }
        }
    }
      

  2.   

    我唯一改动的地方就是把捕捉异常部分改了:
    } catch (Exception e) {
              e.printStackTrace();
              return;
            }
      

  3.   

    我用的包: castor-0.9.4.1.jar, castor-0.9.4.1-xml.jar
    例子也是castor-0.9.4.1的doc中的例子
      

  4.   

    不好意思,可能是我搞混了,我的信箱里面有一封来自[email protected]的email,是你的吗?email里面的例子和你的一样,也有一些错误,我修改以后可以运行了,如果你需要我把jbuilder 项目目录打包发给你。
      

  5.   

    我的email地址:[email protected],非常感谢!
      

  6.   

    问题解决了,原来是jbuilder的原因,我把require libraries中不需要用到的包去掉就ok了, chenyuan_tongji(codeguru),谢谢你的帮助!买单了!