Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JAXB Question

0 views
Skip to first unread message

Michael

unread,
Aug 8, 2003, 12:47:53 PM8/8/03
to
Greetings,

I used JAXB to create classes from an XML schema file.

Here is a snippet of code:

JAXBContext jc = JAXBContext.newInstance( "surfTest" );
ObjectFactory objFactory = new ObjectFactory();

UserEnteredProfile uep=
objFactory.createUserEnteredProfile();
uep.setTime("12:00 p.m.");
uep.setProfileName("JAXB_TEST");
uep.setEditFlag("N") ;
uep.setDate("08/08/2003");
uep.setSightLine(new BigDecimal(120.0));
ClassType navoClass = createClassification(objFactory);

// create a Marshaller and marshal to a file
Marshaller m = jc.createMarshaller();
m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT,
Boolean.TRUE );

Whenever the code to create the Marshaller is executed I get the
following error.

java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for
J2EE].naming.ContextClassLoader.defineClass(ContextClassLoader.java:1102)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for
J2EE].naming.ContextClassLoader.findClass(ContextClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for
J2EE].naming.ContextClassLoader.loadClass(ContextClassLoader.java:135)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for
J2EE].naming.ContextClassLoader.defineClass(ContextClassLoader.java:1102)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for
J2EE].naming.ContextClassLoader.findClass(ContextClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for
J2EE].naming.ContextClassLoader.loadClass(ContextClassLoader.java:135)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at surfTest.impl.runtime.DefaultJAXBContextImpl.createMarshaller(DefaultJAXBContextImpl.java:104)


Any ideas/suggestions?


Thanks,

MJ

Roedy Green

unread,
Aug 8, 2003, 2:05:39 PM8/8/03
to
On 8 Aug 2003 09:47:53 -0700, mjohn...@yahoo.com (Michael) wrote or
quoted :

>I used JAXB to create classes from an XML schema file.

I burst out laughing when I ready about JAXB. What is the advantage of
writing that long-winded, complicated, screwy XML to generate trivial
Java class files?

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Christophe Vanfleteren

unread,
Aug 8, 2003, 2:12:10 PM8/8/03
to
Roedy Green wrote:

> On 8 Aug 2003 09:47:53 -0700, mjohn...@yahoo.com (Michael) wrote or
> quoted :
>
>>I used JAXB to create classes from an XML schema file.
>
> I burst out laughing when I ready about JAXB. What is the advantage of
> writing that long-winded, complicated, screwy XML to generate trivial
> Java class files?
>

I think you're missing the point of JAXB.
It's not about creating classes, it's about marshalling instances of classes
to/from XML, in a transparent manner without writing (any) boilerplate
code. Just defining an xml schema is much easier and less work than
creating/parsing the xml from the instances yourself.

--
mvg,
Christophe Vanfleteren

Roedy Green

unread,
Aug 8, 2003, 9:35:07 PM8/8/03
to
On Fri, 08 Aug 2003 18:12:10 GMT, Christophe Vanfleteren
<c.v4nf...@p4nd0r4.b3> wrote or quoted :

>I think you're missing the point of JAXB.
>It's not about creating classes, it's about marshalling instances of classes
>to/from XML, in a transparent manner without writing (any) boilerplate
>code. Just defining an xml schema is much easier and less work than
>creating/parsing the xml from the instances yourself.

but surely feeding the class files to create the marshal/unmarshall
code would be easier than feeding the XML.

Christophe Vanfleteren

unread,
Aug 9, 2003, 4:44:40 AM8/9/03
to
Roedy Green wrote:

> On Fri, 08 Aug 2003 18:12:10 GMT, Christophe Vanfleteren
> <c.v4nf...@p4nd0r4.b3> wrote or quoted :
>
>>I think you're missing the point of JAXB.
>>It's not about creating classes, it's about marshalling instances of
>>classes to/from XML, in a transparent manner without writing (any)
>>boilerplate code. Just defining an xml schema is much easier and less work
>>than creating/parsing the xml from the instances yourself.
>
> but surely feeding the class files to create the marshal/unmarshall
> code would be easier than feeding the XML.
>

It sure is, and that is what frameworks as Castor can do: there is no need
to write a schema in most cases, unless you want more control of the
marshalling process (eg. what should be an element / attribute, ...).

--
mvg,
Christophe Vanfleteren

Michael

unread,
Aug 11, 2003, 10:22:58 AM8/11/03
to
Roedy Green <ro...@mindprod.com> wrote in message news:<pgp7jvcvj1maf15hk...@4ax.com>...

> On 8 Aug 2003 09:47:53 -0700, mjohn...@yahoo.com (Michael) wrote or
> quoted :
>
> >I used JAXB to create classes from an XML schema file.
>
> I burst out laughing when I ready about JAXB. What is the advantage of
> writing that long-winded, complicated, screwy XML to generate trivial
> Java class files?

If you have nothing helpful, why in the hell did you bother posting?

Chris Smith

unread,
Aug 11, 2003, 11:12:12 AM8/11/03
to
Michael wrote:
> If you have nothing helpful, why in the hell did you bother posting?
>

Wow, Michael. You're really adept at ensuring that you'll never get
help from one of the most helpful people in this group. If someone
knows the answer, they'll probably post about it. It doesn't hurt you
for Roedy to post his opinions about the API.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Michael

unread,
Aug 12, 2003, 9:37:47 AM8/12/03
to
Chris Smith <cds...@twu.net> wrote in message news:<MPG.19a16038...@news.altopia.com>...

> Michael wrote:
> > If you have nothing helpful, why in the hell did you bother posting?
> >
>
> Wow, Michael. You're really adept at ensuring that you'll never get
> help from one of the most helpful people in this group. If someone
> knows the answer, they'll probably post about it. It doesn't hurt you
> for Roedy to post his opinions about the API.

You are right, my frustration level with trying to solve this problem
got the best of me.

Chris Smith

unread,
Aug 12, 2003, 9:49:50 AM8/12/03
to
Roedy Green wrote:
> On 8 Aug 2003 09:47:53 -0700, mjohn...@yahoo.com (Michael) wrote or
> quoted :
>
> >I used JAXB to create classes from an XML schema file.
>
> I burst out laughing when I ready about JAXB. What is the advantage of
> writing that long-winded, complicated, screwy XML to generate trivial
> Java class files?

Unless, of course, you've already got XML schemas from an external
source, like a specification that you're trying to implement. Then it's
no work at all to use the existing XML schema and get a Java class to
access it, but it's a considerable job to write your own marshalling and
unmarshalling code for the existing format specification.

Roedy Green

unread,
Aug 14, 2003, 12:48:37 AM8/14/03
to
On 11 Aug 2003 07:22:58 -0700, mjohn...@yahoo.com (Michael) wrote or
quoted :

>


>If you have nothing helpful, why in the hell did you bother posting?

The "helpfulness" was the suggestion that JAXB is an idiotic tool and
should be abandoned.

0 new messages