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 <[email protected]> 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. >
