AegisDataBinding throws NullPointer with un-prefixed Namespace
--------------------------------------------------------------
Key: CXF-1504
URL: https://issues.apache.org/jira/browse/CXF-1504
Project: CXF
Issue Type: Bug
Components: Aegis Databinding
Affects Versions: 2.1
Environment: Windows XP, Eclipse Europa (3.3), Java 1.6
Reporter: Judes Tumuhairwe
When dealing with Complex types (i.e. non-primitives), AegisDatabinding throws
a NullPointer exception [in NamespaceHelper.getPrefix() ] when I but it works
perfectly fine when I use JAXB (see the "comment me to use JAXB" line in the
server & client). It should default to a prefix e.g. ns0.
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)
To reproduce:
I had 2 beans, the interface and the implementation, the server & the client
(all in the same package).
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 AegisDatabinding());
factory.setServiceClass(University.class);
factory.setAddress("http://localhost:9090/TV");
University client = (University) factory.create();
Teacher tr = client.getTeacher(new Course(40, "Intro to CS",
"Introductory Comp Sci"));
System.out.println("Response is: " + tr.getName() + ", " + tr.getAge()
+ ", " + tr.getDepartment());
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.