You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by myerscb <my...@upmc.edu> on 2011/02/01 14:06:16 UTC

Re: IllegalAnnotationExceptions when running Restful Http Binding Demo

Sergey,

I have moved over to using the jax-ws and jax-rs but, i am still getting the
illegalAnnotationException when the soap endpoint starts up.  

here is the method that starts the soap endpoint:

    private static void createSoapService(Object serviceObj) {
        JaxWsServerFactoryBean serviceFactory = new
JaxWsServerFactoryBean();
        serviceFactory.setServiceClass(GoldenKey.class);
        serviceFactory.setAddress("http://localhost:8080/soap");
        serviceFactory.setServiceBean(serviceObj);
        
		serviceFactory.getInInterceptors().add(new LoggingInInterceptor());
		serviceFactory.getOutInterceptors().add(new LoggingOutInterceptor());

        serviceFactory.create();
    }

here is the GoldenKey class:

@WebService(targetNamespace = "http://com.upmc.tdc.server")
@Path("/")
public interface GoldenKey {
	    
    @Get
    @Path("/patients/{dataSourceType}/{id}/{lastName}/{firstName}")
    Patient getPatient(@PathParam("") GetPatient getPatient) throws
PatientNotFoundFault;    

    @Get
    @Path("/patients")
    Patients getPatients();

}

here is GetPatient:

@XmlRootElement(name = "GetPatient")
public class GetPatient {
    private int id;
    private int requestorId;
    private String firstName;
    private String lastName;
    private String dataSourceType;
    
    public String toString() {
		String rtn = "";
		if (id > 0) {
			rtn += "id: " + id + "\n";
		}
		if (!StringUtils.isBlank(lastName)) {
			rtn += "lastName: " + lastName + "\n";
		}
		if (!StringUtils.isBlank(firstName)) {
			rtn += "firstName: " + firstName + "\n";
		}		
		if (!StringUtils.isBlank(dataSourceType)) {
			rtn += "dataSourceType: " + dataSourceType + "\n";
		}
		if (requestorId > 0) {
			rtn += "requestorId: " + requestorId + "\n";
		}
		return rtn;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

	public int getRequestorId() {
		return requestorId;
	}

	public void setRequestorId(int requestorId) {
		this.requestorId = requestorId;
	}

	public String getDataSourceType() {
		return dataSourceType;
	}

	public void setDataSourceType(String dataSourceType) {
		this.dataSourceType = dataSourceType;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

}

The exception is:

INFO: Creating Service {http://com.upmc.tdc.server}GoldenKeyService from
class com.upmc.tdc.server.GoldenKey
Exception in thread "main"
org.apache.cxf.service.factory.ServiceConstructionException
	at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:341)
	at
org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:87)
	at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:445)
	at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:680)
	at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:508)
	at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:245)
	at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
	at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
	at
org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:148)
	at
org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:183)
	at com.upmc.tdc.server.Server.createSoapService(Server.java:75)
	at com.upmc.tdc.server.Server.main(Server.java:35)
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts
of IllegalAnnotationExceptions
Two classes have the same XML type name
"{http://com.upmc.tdc.server}getPatient". Use @XmlType.name and
@XmlType.namespace to assign different names to them.
	this problem is related to the following location:
		at com.upmc.tdc.server.GetPatient
		at private com.upmc.tdc.server.GetPatient
com.upmc.tdc.server.jaxws_asm.GetPatient.arg0
		at com.upmc.tdc.server.jaxws_asm.GetPatient
	this problem is related to the following location:
		at com.upmc.tdc.server.jaxws_asm.GetPatient

	at
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
	at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
	at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
	at
com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
	at
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
	at
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
	at
org.apache.cxf.jaxb.JAXBDataBinding.createContext(JAXBDataBinding.java:557)
	at
org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:497)
	at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
	... 11 more

The jax-rs endpoint is working well.


Thanks for all your help.

Chris

-- 
View this message in context: http://cxf.547215.n5.nabble.com/IllegalAnnotationExceptions-when-running-Restful-Http-Binding-Demo-tp3349642p3366157.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Apache CXF 2.3.1, use jaxb-impl-2.2.1.1.jar

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 01 February 2011 10:25:29 am Nordine Boussedra wrote:
> In the migration guide of CXF 2.3.1 we have to copy in the endorsed lib
> of the JDK the jaxb-api-.2.2.1 but not jaxb-impl-2.2.1.1.jar.
> In our project we need jaxb-impl-2.2.1.1.jar. Is there any impact on CXF
> if we copy jaxb-impl-2.2.1.1.jar, and jaxb-xjc-2.2.1.1.jar too in the
> endorsed lib of the JRE.
> We know its minor versions but you never can tell.

It wouldn't hurt, but not really needed.    The "jaxb-impl" and xjc things 
built into the JDK use a different package name.   They have an "internal" 
subpackage stuck in there.   Thus, the jars don't conflict with built in jdk 
classes like the API jars do.

Dan



> 
> Thanks for the help.
> 
> 
> 
> Ce message est protégé par les règles relatives au secret des
> correspondances. Il est donc établi à destination exclusive de son
> destinataire. Celui-ci peut donc contenir des informations
> confidentielles. La divulgation de ces informations est à ce titre
> rigoureusement interdite. Si vous avez reçu ce message par erreur, merci
> de le renvoyer à l'expéditeur dont l'adresse e-mail figure ci-dessus et de
> détruire le message ainsi que toute pièce jointe.
> 
> This message is protected by the secrecy of correspondence rules.
> Therefore, this message is intended solely for the attention of the
> addressee. This message may contain privileged or confidential
> information, as such the disclosure of these informations is strictly
> forbidden. If, by mistake, you have received this message, please return
> this message to the addressser whose e-mail address is written above and
> destroy this message and all files attached.

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Apache CXF 2.3.1, use jaxb-impl-2.2.1.1.jar

Posted by Nordine Boussedra <ex...@agora.msa.fr>.

In the migration guide of CXF 2.3.1 we have to copy in the endorsed lib 
of the JDK the jaxb-api-.2.2.1 but not jaxb-impl-2.2.1.1.jar.
In our project we need jaxb-impl-2.2.1.1.jar. Is there any impact on CXF 
if we copy jaxb-impl-2.2.1.1.jar, and jaxb-xjc-2.2.1.1.jar too in the 
endorsed lib of the JRE.
We know its minor versions but you never can tell.

Thanks for the help.



Ce message est protégé par les règles relatives au secret des correspondances. Il est donc établi à destination exclusive de son destinataire. Celui-ci peut donc contenir des informations confidentielles. La divulgation de ces informations est à ce titre rigoureusement interdite. Si vous avez reçu ce message par erreur, merci de le renvoyer à l'expéditeur dont l'adresse e-mail figure ci-dessus et de détruire le message ainsi que toute pièce jointe.

This message is protected by the secrecy of correspondence rules. Therefore, this message is intended solely for the attention of the addressee. This message may contain privileged or confidential information, as such the disclosure of these informations is strictly forbidden. If, by mistake, you have received this message, please return this message to the addressser whose e-mail address is written above and destroy this message and all files attached.


Re: IllegalAnnotationExceptions when running Restful Http Binding Demo

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

CXF JAX-WS may be generating its own GetPatient JAXB bean so there could be
a conflict (given that we have a getPatient method name).

Rather than introducing GetPatient I'd consider reusing a Patient bean for
capturing all the @Path template variable values, except those which do not
map to Patient properties. This should allow reusing the same method
signature for both JAX-WS and JAX-RS. One does not even has to use the same
method; there could be two web service methods (JAX-WS and JAX-RS)
delegating to a private helper...

cheers, Sergey

On Tue, Feb 1, 2011 at 1:06 PM, myerscb <my...@upmc.edu> wrote:

>
> Sergey,
>
> I have moved over to using the jax-ws and jax-rs but, i am still getting
> the
> illegalAnnotationException when the soap endpoint starts up.
>
> here is the method that starts the soap endpoint:
>
>    private static void createSoapService(Object serviceObj) {
>        JaxWsServerFactoryBean serviceFactory = new
> JaxWsServerFactoryBean();
>        serviceFactory.setServiceClass(GoldenKey.class);
>        serviceFactory.setAddress("http://localhost:8080/soap");
>        serviceFactory.setServiceBean(serviceObj);
>
>                serviceFactory.getInInterceptors().add(new
> LoggingInInterceptor());
>                serviceFactory.getOutInterceptors().add(new
> LoggingOutInterceptor());
>
>        serviceFactory.create();
>    }
>
> here is the GoldenKey class:
>
> @WebService(targetNamespace = "http://com.upmc.tdc.server")
> @Path("/")
> public interface GoldenKey {
>
>    @Get
>     @Path("/patients/{dataSourceType}/{id}/{lastName}/{firstName}")
>     Patient getPatient(@PathParam("") GetPatient getPatient) throws
> PatientNotFoundFault;
>
>    @Get
>    @Path("/patients")
>    Patients getPatients();
>
> }
>
> here is GetPatient:
>
> @XmlRootElement(name = "GetPatient")
> public class GetPatient {
>    private int id;
>    private int requestorId;
>    private String firstName;
>    private String lastName;
>    private String dataSourceType;
>
>    public String toString() {
>                String rtn = "";
>                if (id > 0) {
>                        rtn += "id: " + id + "\n";
>                }
>                if (!StringUtils.isBlank(lastName)) {
>                        rtn += "lastName: " + lastName + "\n";
>                }
>                if (!StringUtils.isBlank(firstName)) {
>                        rtn += "firstName: " + firstName + "\n";
>                }
>                if (!StringUtils.isBlank(dataSourceType)) {
>                        rtn += "dataSourceType: " + dataSourceType + "\n";
>                }
>                if (requestorId > 0) {
>                        rtn += "requestorId: " + requestorId + "\n";
>                }
>                return rtn;
>    }
>
>    public int getId() {
>        return id;
>    }
>
>    public void setId(int id) {
>        this.id = id;
>    }
>
>        public int getRequestorId() {
>                return requestorId;
>        }
>
>        public void setRequestorId(int requestorId) {
>                this.requestorId = requestorId;
>        }
>
>        public String getDataSourceType() {
>                return dataSourceType;
>        }
>
>        public void setDataSourceType(String dataSourceType) {
>                this.dataSourceType = dataSourceType;
>        }
>
>        public String getFirstName() {
>                return firstName;
>        }
>
>        public void setFirstName(String firstName) {
>                this.firstName = firstName;
>        }
>
>        public String getLastName() {
>                return lastName;
>        }
>
>        public void setLastName(String lastName) {
>                this.lastName = lastName;
>        }
>
> }
>
> The exception is:
>
> INFO: Creating Service {http://com.upmc.tdc.server}GoldenKeyService from
> class com.upmc.tdc.server.GoldenKey
> Exception in thread "main"
> org.apache.cxf.service.factory.ServiceConstructionException
>        at
> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:341)
>        at
>
> org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:87)
>        at
>
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:445)
>        at
>
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:680)
>        at
>
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:508)
>        at
>
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:245)
>        at
>
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
>        at
>
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
>        at
>
> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:148)
>        at
>
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:183)
>        at com.upmc.tdc.server.Server.createSoapService(Server.java:75)
>        at com.upmc.tdc.server.Server.main(Server.java:35)
> Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1
> counts
> of IllegalAnnotationExceptions
> Two classes have the same XML type name
> "{http://com.upmc.tdc.server}getPatient". Use @XmlType.name and
> @XmlType.namespace to assign different names to them.
>        this problem is related to the following location:
>                at com.upmc.tdc.server.GetPatient
>                at private com.upmc.tdc.server.GetPatient
> com.upmc.tdc.server.jaxws_asm.GetPatient.arg0
>                at com.upmc.tdc.server.jaxws_asm.GetPatient
>        this problem is related to the following location:
>                at com.upmc.tdc.server.jaxws_asm.GetPatient
>
>        at
>
> com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
>        at
>
> com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
>        at
>
> com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
>        at
>
> com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
>        at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
>        at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
>        at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
>        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
>        at
> org.apache.cxf.jaxb.JAXBDataBinding.createContext(JAXBDataBinding.java:557)
>        at
>
> org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:497)
>        at
> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
>        ... 11 more
>
> The jax-rs endpoint is working well.
>
>
> Thanks for all your help.
>
> Chris
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/IllegalAnnotationExceptions-when-running-Restful-Http-Binding-Demo-tp3349642p3366157.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>