Absent Code attribute in method that is not native

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Absent Code attribute in method that is not native

Felipe Gaúcho
I created a set of types annotated both as JAXB elements and JPA
entities.. I can marshall the XML from the classes but I can't
unmarshall the XML back due to the following error:

java.lang.ClassFormatError: Absent Code attribute in method that is
not native or abstract in class file javax/persistence/FetchType
        at java.lang.ClassLoader.defineClass1(Native Method)

Any clue ?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Absent Code attribute in method that is not native

Paul Sandoz
Administrator

On Apr 14, 2009, at 1:16 PM, Felipe Gaúcho wrote:

> I created a set of types annotated both as JAXB elements and JPA
> entities.. I can marshall the XML from the classes but I can't
> unmarshall the XML back due to the following error:
>
> java.lang.ClassFormatError: Absent Code attribute in method that is
> not native or abstract in class file javax/persistence/FetchType
> at java.lang.ClassLoader.defineClass1(Native Method)
>
> Any clue ?
>

I think that is because you are depending on stubbed javaee jar.

http://forums.java.net/jive/message.jspa?messageID=226931

Paul.

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Absent Code attribute in method that is not native

Felipe Gaúcho
unfortunately not ... but I mapped the problem symptom :

the JPA annotation @GeneratedValue
causes problems with JAXB ..

If I remove this annotation, everything works... but if I include I
have the following exception:

java.lang.ClassFormatError: Absent Code attribute in method that is
not native or abstract in class file javax/persistence/GenerationType
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        ....

This is a sample of class where the problem happens:

@XmlType(namespace = "http://footprint.dev.java.net/service/entity")
@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
@XmlAccessorType(XmlAccessType.FIELD)
@MappedSuperclass
public abstract class AbstractFootprintEntity implements Serializable {
        @XmlElement
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO) // here :(
        private long id;

        ......
}

apparently the annotation GenerationType is not serializable by the
JAXB  framework....

if one of you know a trick or workaround, please ...

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Absent Code attribute in method that is not native

Felipe Gaúcho
also the @Temporal  causes problems:

        @XmlElement
        @Column(nullable = true)
        @Temporal(TemporalType.DATE)
        private Date expireDate;

if I remove this @Temporal, jaxb marshall the type without problems..

may I use an adapter or something like that to fix the problem or JAXB
and JPA annotations are incompatibles ?



2009/4/14 Felipe Gaúcho <[hidden email]>:

> unfortunately not ... but I mapped the problem symptom :
>
> the JPA annotation      @GeneratedValue
> causes problems with JAXB ..
>
> If I remove this annotation, everything works... but if I include I
> have the following exception:
>
> java.lang.ClassFormatError: Absent Code attribute in method that is
> not native or abstract in class file javax/persistence/GenerationType
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>        ....
>
> This is a sample of class where the problem happens:
>
> @XmlType(namespace = "http://footprint.dev.java.net/service/entity")
> @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
> @XmlAccessorType(XmlAccessType.FIELD)
> @MappedSuperclass
> public abstract class AbstractFootprintEntity implements Serializable {
>        @XmlElement
>        @Id
>        @GeneratedValue(strategy = GenerationType.AUTO) // here :(
>        private long id;
>
>        ......
> }
>
> apparently the annotation GenerationType is not serializable by the
> JAXB  framework....
>
> if one of you know a trick or workaround, please ...
>



--

Please help to test this application:
http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Absent Code attribute in method that is not native

Paul Sandoz
Administrator
Hi,

Does any JPA annotation cause the same issue?

What jar are you using for the JPA annotations?

The class loading error is very low-level.

I do not know enough about JAXB with JPA to be of much help :-( i know  
that there are frameworks like HyperJAXB that work with both.

Paul.

On Apr 14, 2009, at 7:16 PM, Felipe Gaúcho wrote:

> also the @Temporal  causes problems:
>
> @XmlElement
> @Column(nullable = true)
> @Temporal(TemporalType.DATE)
> private Date expireDate;
>
> if I remove this @Temporal, jaxb marshall the type without problems..
>
> may I use an adapter or something like that to fix the problem or JAXB
> and JPA annotations are incompatibles ?
>
>
>
> 2009/4/14 Felipe Gaúcho <[hidden email]>:
>> unfortunately not ... but I mapped the problem symptom :
>>
>> the JPA annotation      @GeneratedValue
>> causes problems with JAXB ..
>>
>> If I remove this annotation, everything works... but if I include I
>> have the following exception:
>>
>> java.lang.ClassFormatError: Absent Code attribute in method that is
>> not native or abstract in class file javax/persistence/GenerationType
>>        at java.lang.ClassLoader.defineClass1(Native Method)
>>        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>>        ....
>>
>> This is a sample of class where the problem happens:
>>
>> @XmlType(namespace = "http://footprint.dev.java.net/service/entity")
>> @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
>> @XmlAccessorType(XmlAccessType.FIELD)
>> @MappedSuperclass
>> public abstract class AbstractFootprintEntity implements  
>> Serializable {
>>        @XmlElement
>>        @Id
>>        @GeneratedValue(strategy = GenerationType.AUTO) // here :(
>>        private long id;
>>
>>        ......
>> }
>>
>> apparently the annotation GenerationType is not serializable by the
>> JAXB  framework....
>>
>> if one of you know a trick or workaround, please ...
>>
>
>
>
> --
>
> Please help to test this application:
> http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Absent Code attribute in method that is not native

Paul Sandoz
Administrator
In reply to this post by Felipe Gaúcho
Hi,

I cannot reproduce.

I modified the jabx sample distributed with Jersey (see attached) so  
that a JAXB bean is as follows:

@XmlRootElement
public class JAXBXmlRootElement {

     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     public String value;


that bean is marshalled and unmarshalled by the unit tests without any  
failures.

Paul.






On Apr 14, 2009, at 7:10 PM, Felipe Gaúcho wrote:

> unfortunately not ... but I mapped the problem symptom :
>
> the JPA annotation @GeneratedValue
> causes problems with JAXB ..
>
> If I remove this annotation, everything works... but if I include I
> have the following exception:
>
> java.lang.ClassFormatError: Absent Code attribute in method that is
> not native or abstract in class file javax/persistence/GenerationType
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>        ....
>
> This is a sample of class where the problem happens:
>
> @XmlType(namespace = "http://footprint.dev.java.net/service/entity")
> @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
> @XmlAccessorType(XmlAccessType.FIELD)
> @MappedSuperclass
> public abstract class AbstractFootprintEntity implements  
> Serializable {
> @XmlElement
> @Id
> @GeneratedValue(strategy = GenerationType.AUTO) // here :(
> private long id;
>
>        ......
> }
>
> apparently the annotation GenerationType is not serializable by the
> JAXB  framework....
>
> if one of you know a trick or workaround, please ...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

jaxb.zip (19K) Download Attachment
Loading...