Results 1 to 2 of 2
Thread: how to marshal complex object
- 11-16-2011, 04:23 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 3
- Rep Power
- 0
how to marshal complex object
Hello All,
I am trying JAXB for the first time. I have been reading tutorials and how to all over. I got as far as this:
@XmlRootElement
public class MyClass{
private Object1 obj1;
private List<Object2> obj2;
public MyClass() {
}
public MyClass(Object1 obj1, List<Object2> obj2) {
this.obj1 = obj1;
this.obj2 = obj2;
}
}
Everything is working and happy. But now I want to extend it further by wrapping it in another object. This is where it's not working and I need to understand why. Below is the code:
(@XmlRootElement is removed from MyClass)
@XmlRootElement
public class AllClass{
private List<MyClass> classes;
public AllClass() {
}
public AllClass(List<MyClass> classes) {
this.classes= classes;
}
}
This is the error I got: javax.xml.bind.JAXBException: nor any of its super class is known to this context.
Can someone please explain to me why it works for MyClass with List<Object2> but not in AllClass. I even tried to remove "List" and still the same error.
Thanks in advance
btran
- 11-16-2011, 05:12 PM #2
Member
- Join Date
- Mar 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
marshal/unmarshal java object
By cpk in forum XMLReplies: 0Last Post: 08-14-2011, 12:07 PM -
How complex is too complex for a single class?
By manji51 in forum AWT / SwingReplies: 7Last Post: 07-08-2011, 07:20 PM -
Assigning null to Complex Type object in the context of memory in java
By sagngh8 in forum Advanced JavaReplies: 2Last Post: 06-01-2011, 09:44 AM -
Complex Factory with @AssistedInjection
By veronique in forum Advanced JavaReplies: 5Last Post: 05-18-2011, 09:45 AM -
Complex file input
By JMaste in forum Advanced JavaReplies: 4Last Post: 12-08-2010, 03:55 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks