You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Craig Tataryn <cr...@tataryn.net> on 2012/08/31 21:51:16 UTC

XMLGregorianCalendar problems

Hello, whilst trying to deploy my webapp to WAS v8.0, I'm running into an
issue where a component the webapp depends on uses CXF and has a few model
objects annotated with JAXWS annotations, I get the following error:

Caused by: com.ibm.jtc.jax.xml.bind.v2.runtime.IllegalAnnotationsException:
2 counts of IllegalAnnotationExceptions
@XmlAttribute/@XmlValue need to reference a Java type that maps to text in XML.
        this problem is related to the following location:
                at protected javax.xml.datatype.XMLGregorianCalendar
corp.iam.spml2.suspend.SuspendRequestType.effectiveDate


The model object itself looks like this:

package corp.iam.spml2.suspend;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
//...

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SuspendRequestType", namespace =
"urn:oasis:names:tc:SPML:2:0:suspend", propOrder = {
    "psoID"
})
public class SuspendRequestType
    extends RequestType
{

    @XmlElement(namespace = "urn:oasis:names:tc:SPML:2:0:suspend",
required = true)
    protected PSOIdentifierType psoID;
    @XmlAttribute(name = "effectiveDate")
    @XmlSchemaType(name = "dateTime")
    protected XMLGregorianCalendar effectiveDate;

//Plain old getter/setters make-up the rest of the class
//...
}


Has anyone else run into the problem?

Again, running Webshpere v8.0 with the following JVM:

java version "1.6.0"
Java(TM) SE Runtime Environment (build pap6460_26fp1-20110419_01)
IBM J9 VM (build 2.6, JRE 1.6.0 AIX ppc64-64 20110418_80450 (JIT enabled,
AOT enabled)
J9VM - R26_Java626_GA_FP1_20110418_1915_B80450
JIT  - r11_20110215_18645ifx8
GC   - R26_Java626_GA_FP1_20110418_1915_B80450
J9CL - 20110418_80450)
JCL  - 20110401_01

I've gone through all the usual "convince WAS to let us use CXF" steps
(short of creating a shared library), but can't get past this error.  I've
even tried adding a "type=javax.xml.datatype.XMLGregorianCalendar.class" to
the "@XmlSchemaType" for the effectiveDate field, but to no avail.

I've attached a directory listing of my WEB-INF/lib folder as well.

Any help would be greatly appreciated.

Craig.

-- 
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger

Re: XMLGregorianCalendar problems

Posted by martin <sk...@gmail.com>.
I don't know if you fixed this yet? But i had what i think was a similar
problem with java.sql.timestamp. The problem is that JAXB doesn't know how
to unmarshal the object. The solution for me was to annotate the class so
JAXB only read the public fields, and then store the timestamp as a string
value. I could then use the getter and setter methods to get and set
timestamps, but JAXB only had to deal with a string. Maybe you can do
something similar, although a gregoriancalender is a somewhat harder nut to
crack.
Here is one of the classes. Note timecreated, a string that has getter and
setter methods as a timestamp. This is accepted by JAXB, that troublesome
drama queen:)

import java.sql.Timestamp;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import orgserver.common.StatementLoader;
import orgserver.common.exceptions.NoSuchStatementException;
import orgserver.services.interfaces.SystemNotificationInterface;
@XmlAccessorType(XmlAccessType.FIELD) //JAXB only handle fields
/**
 *
 * @author martin
 */
public class SystemNotification implements SystemNotificationInterface{
    @XmlElement(name = "NotificationId", nillable = true, required = false)
    long notificationid;
    @XmlElement(name = "NotificationTargetId", nillable = true, required =
false)
    long notificationtargetid;
    @XmlElement(name = "NotificationTargetUserId", nillable = true, required
= false)
    int targetuserid;
    @XmlElement(name = "NotificationTargetText", nillable = true, required =
false)
    String notificationtarget;
    @XmlElement(name = "NotificationActionText", nillable = true, required =
false)
    String notificationaction;
    @XmlElement(name = "NotificationObjectText", nillable = true, required =
false)
    String notificationobject;
    @XmlElement(name = "NotificationTimeCreated", nillable = true, required
= false)
    String timecreated; //Actually a timestamp value in tostring form
    @XmlElement(name = "NotificationRead", nillable = true, required =
false)
    boolean readbyowner;
    @XmlElement(name = "NotificationTargetType", nillable = true, required =
false)
    Integer notificationtargettype;

    public SystemNotification() {
    }

    public SystemNotification(long notificationid, long
notificationtargetid, int targetuserid, String notificationtarget, String
notificationaction, String notificationobject, Timestamp timecreated,
boolean readbyowner, Integer notificationtargettype) {
        this.notificationid = notificationid;
        this.notificationtargetid = notificationtargetid;
        this.targetuserid = targetuserid;
        this.notificationtarget = notificationtarget;
        this.notificationaction = notificationaction;
        this.notificationobject = notificationobject;
        this.timecreated = timecreated.toString();
        this.readbyowner = readbyowner;
        this.notificationtargettype = notificationtargettype;
    }

    public String getNotificationaction() {
        return notificationaction;
    }

    public void setNotificationaction(String notificationaction) {
        this.notificationaction = notificationaction;
    }

    public String getNotificationobject() {
        return notificationobject;
    }

    public void setNotificationobject(String notificationobject) {
        this.notificationobject = notificationobject;
    }

    public String getNotificationtarget() {
        return notificationtarget;
    }

    public void setNotificationtarget(String notificationtarget) {
        this.notificationtarget = notificationtarget;
    }

    public long getNotificationtargetid() {
        return notificationtargetid;
    }

    public void setNotificationtargetid(long notificationtargetid) {
        this.notificationtargetid = notificationtargetid;
    }

    public boolean isReadbyowner() {
        return readbyowner;
    }

    public void setReadbyowner(boolean readbyowner) {
        this.readbyowner = readbyowner;
    }

    public int getTargetuserid() {
        return targetuserid;
    }

    public void setTargetuserid(int targetuserid) {
        this.targetuserid = targetuserid;
    }

    public Timestamp getTimecreated() { //Create timestamp from string and
return (Watch out for null values)
        if(timecreated == null) return null;
        return Timestamp.valueOf(timecreated);
    }

    public void setTimecreated(Timestamp timecreated) { //Save as string
        this.timecreated = timecreated.toString();
    }

    public Integer getNotificationtargettype() {
        return notificationtargettype;
    }

    public void setNotificationtargettype(Integer notificationtargettype) {
        this.notificationtargettype = notificationtargettype;
    }


    public Integer getNotificationType() {
        return notificationtargettype;
    }

    public long getNotificationId() {
        return notificationid;
    }

    public void setNotificationid(long notificationid) {
        this.notificationid = notificationid;
    }

    public String toString(){
        return getClass().getSimpleName()+" id: "+getNotificationId()+"
target: "+this.getNotificationtargetid()+" user: "+this.getTargetuserid()+"
targettype "+this.getNotificationtargettype()+"
"+this.getNotificationtarget()+" "+this.getNotificationaction()+"
"+this.getNotificationobject()+" "+this.getTimecreated()+" read:
"+this.isReadbyowner();
    }

   
 


}



--
View this message in context: http://cxf.547215.n5.nabble.com/XMLGregorianCalendar-problems-tp5713419p5713700.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: XMLGregorianCalendar problems

Posted by Craig Tataryn <cr...@tataryn.net>.
I'll give those a shot.  Luckily I have the source for the component that's
causing the problem.  The thing is... this works great under
Tomcat/OracleJDK :S

/me shakes fist at IBM

Craig.

On Fri, Aug 31, 2012 at 3:31 PM, Glen Mazza <gm...@talend.com> wrote:

> Unsure, but I don't think the problem is related to your webapp not
> reading in the CXF JARs, it looks like a standard JAXB configuration issue
> (further testing might show:  does the app work with Tomcat, or same error?
> if you change the data type from XMLGregorianCalendar to String, does the
> error go away?)  That particular error "@XmlAttribute/@XmlValue need to
> reference a Java type that maps to text in XML", when googled, returns
> about 1500 hits, probably with many different solutions (here is one:
> http://stackoverflow.com/**questions/8807296/jaxb-**generic-xmlvalue<http://stackoverflow.com/questions/8807296/jaxb-generic-xmlvalue>
> )
>
> You might want to try switching to java.util.Date instead of
> XMLGregorianCalendar, you'll need a JAXB binding file for that:
> http://cxf.apache.org/docs/**wsdl-to-java.html#WSDLtoJava-**
> JAXWSCustomization<http://cxf.apache.org/docs/wsdl-to-java.html#WSDLtoJava-JAXWSCustomization>.
> Note it has parseMethod and printMethod settings that could be another
> solution causing that error to go away.  If that works, see if plugging in
> XMLGregorianCalendar into that config will also work for you, then you're
> set.
>
> HTH,
> Glen
>
>
>
> On 08/31/2012 03:51 PM, Craig Tataryn wrote:
>
>> Hello, whilst trying to deploy my webapp to WAS v8.0, I'm running into an
>> issue where a component the webapp depends on uses CXF and has a few model
>> objects annotated with JAXWS annotations, I get the following error:
>>
>> Caused by: com.ibm.jtc.jax.xml.bind.v2.**runtime.**IllegalAnnotationsException:
>> 2 counts of IllegalAnnotationExceptions
>> @XmlAttribute/@XmlValue need to reference a Java type that maps to text
>> in XML.
>>
>>         this problem is related to the following location:
>>                 at protected javax.xml.datatype.**XMLGregorianCalendar
>> corp.iam.spml2.suspend.**SuspendRequestType.**effectiveDate
>>
>> The model object itself looks like this:
>>
>> package corp.iam.spml2.suspend;
>>
>> import javax.xml.bind.annotation.**XmlAccessType;
>>
>> import javax.xml.bind.annotation.**XmlAccessorType;
>>
>> import javax.xml.bind.annotation.**XmlAttribute;
>>
>> import javax.xml.bind.annotation.**XmlElement;
>>
>> import javax.xml.bind.annotation.**XmlSchemaType;
>>
>> import javax.xml.bind.annotation.**XmlType;
>>
>> import javax.xml.datatype.**XMLGregorianCalendar;
>>
>> //...
>> @XmlAccessorType(**XmlAccessType.FIELD)
>>
>> @XmlType(name = "SuspendRequestType", namespace =
>> "urn:oasis:names:tc:SPML:2:0:**suspend", propOrder = {
>>
>> "psoID"
>> })
>> public class SuspendRequestType
>>
>> extends RequestType
>>
>> {
>> @XmlElement(namespace = "urn:oasis:names:tc:SPML:2:0:**suspend",
>> required = true)
>>
>> protected PSOIdentifierType psoID;
>>
>> @XmlAttribute(name = "effectiveDate")
>>
>> @XmlSchemaType(name = "dateTime")
>>
>> protected XMLGregorianCalendar effectiveDate;
>>
>> //Plain old getter/setters make-up the rest of the class
>> //...
>> }
>>
>> Has anyone else run into the problem?
>>
>> Again, running Webshpere v8.0 with the following JVM:
>>
>> java version "1.6.0"
>> Java(TM) SE Runtime Environment (build pap6460_26fp1-20110419_01)
>> IBM J9 VM (build 2.6, JRE 1.6.0 AIX ppc64-64 20110418_80450 (JIT enabled,
>> AOT enabled)
>> J9VM - R26_Java626_GA_FP1_20110418_**1915_B80450
>> JIT  - r11_20110215_18645ifx8
>> GC   - R26_Java626_GA_FP1_20110418_**1915_B80450
>> J9CL - 20110418_80450)
>> JCL  - 20110401_01
>>
>> I've gone through all the usual "convince WAS to let us use CXF" steps
>> (short of creating a shared library), but can't get past this error.  I've
>> even tried adding a "type=javax.xml.datatype.**XMLGregorianCalendar.class"
>> to the "@XmlSchemaType" for the effectiveDate field, but to no avail.
>>
>> I've attached a directory listing of my WEB-INF/lib folder as well.
>>
>> Any help would be greatly appreciated.
>>
>> Craig.
>>
>> --
>> Craig Tataryn
>> site: http://www.basementcoders.com/
>> podcast:http://feeds.**feedburner.com/**TheBasementCoders<http://feeds.feedburner.com/TheBasementCoders>
>> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
>> twitter: craiger
>>
>
>
> --
> Glen Mazza
> Talend Community Coders - coders.talend.com
> blog: www.jroller.com/gmazza
>
>


-- 
Craig Tataryn
site: http://www.basementcoders.com/
podcast:http://feeds.feedburner.com/TheBasementCoders
irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
twitter: craiger

Re: XMLGregorianCalendar problems

Posted by Glen Mazza <gm...@talend.com>.
Unsure, but I don't think the problem is related to your webapp not 
reading in the CXF JARs, it looks like a standard JAXB configuration 
issue (further testing might show:  does the app work with Tomcat, or 
same error? if you change the data type from XMLGregorianCalendar to 
String, does the error go away?)  That particular error 
"@XmlAttribute/@XmlValue need to reference a Java type that maps to text 
in XML", when googled, returns about 1500 hits, probably with many 
different solutions (here is one: 
http://stackoverflow.com/questions/8807296/jaxb-generic-xmlvalue)

You might want to try switching to java.util.Date instead of 
XMLGregorianCalendar, you'll need a JAXB binding file for that: 
http://cxf.apache.org/docs/wsdl-to-java.html#WSDLtoJava-JAXWSCustomization. 
Note it has parseMethod and printMethod settings that could be another 
solution causing that error to go away.  If that works, see if plugging 
in XMLGregorianCalendar into that config will also work for you, then 
you're set.

HTH,
Glen


On 08/31/2012 03:51 PM, Craig Tataryn wrote:
> Hello, whilst trying to deploy my webapp to WAS v8.0, I'm running into 
> an issue where a component the webapp depends on uses CXF and has a 
> few model objects annotated with JAXWS annotations, I get the 
> following error:
>
> Caused by: 
> com.ibm.jtc.jax.xml.bind.v2.runtime.IllegalAnnotationsException: 2 
> counts of IllegalAnnotationExceptions
> @XmlAttribute/@XmlValue need to reference a Java type that maps to 
> text in XML.
>
>         this problem is related to the following location:
>                 at protected javax.xml.datatype.XMLGregorianCalendar 
> corp.iam.spml2.suspend.SuspendRequestType.effectiveDate
>
> The model object itself looks like this:
>
> package corp.iam.spml2.suspend;
>
> import javax.xml.bind.annotation.XmlAccessType;
>
> import javax.xml.bind.annotation.XmlAccessorType;
>
> import javax.xml.bind.annotation.XmlAttribute;
>
> import javax.xml.bind.annotation.XmlElement;
>
> import javax.xml.bind.annotation.XmlSchemaType;
>
> import javax.xml.bind.annotation.XmlType;
>
> import javax.xml.datatype.XMLGregorianCalendar;
>
> //...
> @XmlAccessorType(XmlAccessType.FIELD)
>
> @XmlType(name = "SuspendRequestType", namespace = 
> "urn:oasis:names:tc:SPML:2:0:suspend", propOrder = {
>
> "psoID"
> })
> public class SuspendRequestType
>
> extends RequestType
>
> {
> @XmlElement(namespace = "urn:oasis:names:tc:SPML:2:0:suspend", 
> required = true)
>
> protected PSOIdentifierType psoID;
>
> @XmlAttribute(name = "effectiveDate")
>
> @XmlSchemaType(name = "dateTime")
>
> protected XMLGregorianCalendar effectiveDate;
>
> //Plain old getter/setters make-up the rest of the class
> //...
> }
>
> Has anyone else run into the problem?
>
> Again, running Webshpere v8.0 with the following JVM:
>
> java version "1.6.0"
> Java(TM) SE Runtime Environment (build pap6460_26fp1-20110419_01)
> IBM J9 VM (build 2.6, JRE 1.6.0 AIX ppc64-64 20110418_80450 (JIT 
> enabled, AOT enabled)
> J9VM - R26_Java626_GA_FP1_20110418_1915_B80450
> JIT  - r11_20110215_18645ifx8
> GC   - R26_Java626_GA_FP1_20110418_1915_B80450
> J9CL - 20110418_80450)
> JCL  - 20110401_01
>
> I've gone through all the usual "convince WAS to let us use CXF" steps 
> (short of creating a shared library), but can't get past this error. 
>  I've even tried adding a 
> "type=javax.xml.datatype.XMLGregorianCalendar.class" to the 
> "@XmlSchemaType" for the effectiveDate field, but to no avail.
>
> I've attached a directory listing of my WEB-INF/lib folder as well.
>
> Any help would be greatly appreciated.
>
> Craig.
>
> -- 
> Craig Tataryn
> site: http://www.basementcoders.com/
> podcast:http://feeds.feedburner.com/TheBasementCoders
> irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin
> twitter: craiger


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza