Hi Peter,
The NullPointerException occurs when you're marshalling a structure
that's missing an object required by your binding. It doesn't look like
you're doing any initialization of your Customer instance in your code,
so if there are any required fields in the binding you'll get the
NullPointerException when JiBX tries to marshal one of these fields. See
http://jibx.sourceforge.net/faq.html#npe
- Dennis
Dennis M. Sosnoski
SOA, Web Services, and XML
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-296-6194 - Wellington, NZ +64-4-298-6117
Peter Solc wrote:
I am new to the jibx and I am having problem to marshall object. I
modified given example from jibx tutorial because all of them showed
only how to marshall from object which uses input file in xml form. I
am trying to create xml file from the object without any input file. I
am creating instance of my object which I am trying to marshall to get
xml.
I am getting this error:
check-runtime:
run:
[echo] Running the sample application...
[java] Exception in thread "main" java.lang.NullPointerException
[java] at
org.jibx.starter.Customer.JiBX_starter_binding_marshal_1_0(Customer.java)
[java] at
org.jibx.starter.JiBX_starter_bindingCustomer_access.marshal()
[java] at org.jibx.starter.Customer.marshal(Customer.java)
[java] at
org.jibx.runtime.impl.MarshallingContext.marshalRoot(Unknown Source)
[java] at
org.jibx.runtime.impl.MarshallingContext.marshalDocument(Unknown Source)
[java] at org.jibx.starter.Test.main(Test.java:58)
BUILD FAILED
C:\local\jibx\starter\build.xml:125: Java returned: 1
The code is here:
IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
Customer customer = new Customer();
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
FileWriter fileWriter = new FileWriter("output.xml", true);
mctx.setOutput(fileWriter);
mctx.marshalDocument(customer);
It is creating error that marshalDocument has Unknown Source. I tried
to create object before the IBindingFactory but that makes no
difference. Any idea what is missing in my code? I am completely new
to it.
Thanks.
Peter S.
------------------------------------------------------------------------
Get MSN Messenger with FREE Video Conversation - the next best thing
to being there! <http://g.msn.com/8HMBENUS/2746??PS=47575>
------------------------------------------------------- Using Tomcat
but need to do more? Need to support web services, security? Get stuff
done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ jibx-users mailing
list [email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users