Re: AegisDataBinding throwing NullPointer
Benson, Thank you for resolving the issue I logged so quickly. I'm guessing it is available in the trunk? (if not, I can wait till the next snapshot) thanks again! Judes On 4/6/08, Benson Margulies [EMAIL PROTECTED] wrote: Aegis does not support unqualified schema. However, it should have just made up one for you. Please post a JIRA. On Sun, Apr 6, 2008 at 2:40 AM, Judes Tumuhairwe [EMAIL PROTECTED] wrote: Hi, I have an interesting case binding/marshalling complex types using the 2.1 snapshot. A NullPointer is thrown [in NamespaceHelper.getPrefix() ] when I used AegisDataBinding but it works perfectly fine when I use JAXB (see the comment me to use JAXB line in the server client). Question: Do I absolutely have to have a prefix for my namespace? How come it works fine with primitives? [actually I was trying to get the service working with some interfaces abstract classes was running into no write method for property xxx so when I took them out dealt with POJOs, I ran into this NPE.] About the environment: Eclipse Europa, Win XP, Java 1.6 I have 2 beans, the interface and the implementation, the server the client (all in the same package). First, here is the stacktrace: Apr 6, 2008 2:06:05 AM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass INFO: Creating Service {http://education.toorosystems.com/}University http://education.toorosystems.com/%7DUniversityfrom class com.toorosystems.education.University Exception in thread main java.lang.NullPointerException at org.apache.cxf.aegis.util.NamespaceHelper.getPrefix(NamespaceHelper.java:71) at org.apache.cxf.aegis.util.NamespaceHelper.getUniquePrefix(NamespaceHelper.java:57) at org.apache.cxf.aegis.type.basic.BeanType.getNameWithPrefix(BeanType.java:533) at org.apache.cxf.aegis.type.basic.BeanType.writeSchema(BeanType.java:483) at org.apache.cxf.aegis.databinding.AegisDatabinding.createSchemas(AegisDatabinding.java:477) at org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(AegisDatabinding.java:322) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:343) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:392) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:180) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:113) at com.toorosystems.education.Server.main(Server.java:19) The model: *a)* The beans: 1. Course [id (long), name description; their getters and setters, + 2 constructors: (no-arg all-arg)] 2. Teacher [age (int), name, department; their getters/setters, + 2 constructors (no-arg all-arg i.e. Course(int age, String name, String dept)] *b)* The interface: package com.toorosystems.education; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.WebMethod; import javax.jws.WebResult; import javax.jws.WebParam; @WebService(name=University, targetNamespace= http://education.toorosystems.com/;) @SOAPBinding(use=SOAPBinding.Use.LITERAL, style=SOAPBinding.Style.DOCUMENT, parameterStyle=SOAPBinding.ParameterStyle.BARE) public interface University { @WebResult(targetNamespace=http://education.toorosystems.com/;, name=return, partName=return) @WebMethod(operationName=getTeacher, exclude=false) public Teacher getTeacher(@WebParam(targetNamespace= http://education.toorosystems.com/;, name=course, mode= WebParam.Mode.IN) Course course); } *c)* The implementation package com.toorosystems.education; import javax.xml.ws.WebServiceClient; //@WebServiceClient(name=com.toorosystems.education.UniversityImpl, targetNamespace=http://education.toorosystems.com/;) public class UniversityImpl implements University { public UniversityImpl() {} public Teacher getTeacher(Course course) { System.out.println(getTeacher called...); return new Teacher(Mr. Tom, 52, Computer Science + course.getName()); } } *d)* The Server package com.toorosystems.education; import org.apache.cxf.aegis.databinding.AegisDatabinding; import org.apache.cxf.frontend.ServerFactoryBean; public class Server { public static void main(String[] args) { // Create our service implementation System.out.println(Starting server ...); ServerFactoryBean svrFactory = new ServerFactoryBean(); svrFactory.setServiceClass(University.class); svrFactory.setAddress(http://localhost:9090/TV;); svrFactory.setServiceBean(new UniversityImpl
AegisDataBinding throwing NullPointer
Hi, I have an interesting case binding/marshalling complex types using the 2.1 snapshot. A NullPointer is thrown [in NamespaceHelper.getPrefix() ] when I used AegisDataBinding but it works perfectly fine when I use JAXB (see the comment me to use JAXB line in the server client). Question: Do I absolutely have to have a prefix for my namespace? How come it works fine with primitives? [actually I was trying to get the service working with some interfaces abstract classes was running into no write method for property xxx so when I took them out dealt with POJOs, I ran into this NPE.] About the environment: Eclipse Europa, Win XP, Java 1.6 I have 2 beans, the interface and the implementation, the server the client (all in the same package). First, here is the stacktrace: Apr 6, 2008 2:06:05 AM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass INFO: Creating Service {http://education.toorosystems.com/}University from class com.toorosystems.education.University Exception in thread main java.lang.NullPointerException at org.apache.cxf.aegis.util.NamespaceHelper.getPrefix(NamespaceHelper.java:71) at org.apache.cxf.aegis.util.NamespaceHelper.getUniquePrefix(NamespaceHelper.java:57) at org.apache.cxf.aegis.type.basic.BeanType.getNameWithPrefix(BeanType.java:533) at org.apache.cxf.aegis.type.basic.BeanType.writeSchema(BeanType.java:483) at org.apache.cxf.aegis.databinding.AegisDatabinding.createSchemas(AegisDatabinding.java:477) at org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(AegisDatabinding.java:322) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:343) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:392) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:180) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:79) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:113) at com.toorosystems.education.Server.main(Server.java:19) The model: *a)* The beans: 1. Course [id (long), name description; their getters and setters, + 2 constructors: (no-arg all-arg)] 2. Teacher [age (int), name, department; their getters/setters, + 2 constructors (no-arg all-arg i.e. Course(int age, String name, String dept)] *b)* The interface: package com.toorosystems.education; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.WebMethod; import javax.jws.WebResult; import javax.jws.WebParam; @WebService(name=University, targetNamespace= http://education.toorosystems.com/;) @SOAPBinding(use=SOAPBinding.Use.LITERAL, style=SOAPBinding.Style.DOCUMENT, parameterStyle=SOAPBinding.ParameterStyle.BARE) public interface University { @WebResult(targetNamespace=http://education.toorosystems.com/;, name=return, partName=return) @WebMethod(operationName=getTeacher, exclude=false) public Teacher getTeacher(@WebParam(targetNamespace= http://education.toorosystems.com/;, name=course, mode=WebParam.Mode.IN) Course course); } *c)* The implementation package com.toorosystems.education; import javax.xml.ws.WebServiceClient; //@WebServiceClient(name=com.toorosystems.education.UniversityImpl, targetNamespace=http://education.toorosystems.com/;) public class UniversityImpl implements University { public UniversityImpl() {} public Teacher getTeacher(Course course) { System.out.println(getTeacher called...); return new Teacher(Mr. Tom, 52, Computer Science + course.getName()); } } *d)* The Server package com.toorosystems.education; import org.apache.cxf.aegis.databinding.AegisDatabinding; import org.apache.cxf.frontend.ServerFactoryBean; public class Server { public static void main(String[] args) { // Create our service implementation System.out.println(Starting server ...); ServerFactoryBean svrFactory = new ServerFactoryBean(); svrFactory.setServiceClass(University.class); svrFactory.setAddress(http://localhost:9090/TV;); svrFactory.setServiceBean(new UniversityImpl()); // comment me to use JAXB svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding()); svrFactory.create(); System.out.println(Server started!); } } *e)* The client package com.toorosystems.education; import org.apache.cxf.aegis.databinding.AegisDatabinding; import org.apache.cxf.frontend.ClientProxyFactoryBean; public class Client { public static void main(String[] args) { // see http://cwiki.apache.org/CXF20DOC/introduction-to-aegis-21.html ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); // comment me to use JAXB factory.getServiceFactory().setDataBinding(new