cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Judes Tumuhairwe (JIRA)" <>
Subject [jira] Created: (CXF-1504) AegisDataBinding throws NullPointer with un-prefixed Namespace
Date Sun, 06 Apr 2008 17:37:24 GMT
AegisDataBinding throws NullPointer with un-prefixed Namespace

                 Key: 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 {}University from class
Exception in thread "main" java.lang.NullPointerException
    at org.apache.cxf.aegis.util.NamespaceHelper.getPrefix(
    at org.apache.cxf.aegis.util.NamespaceHelper.getUniquePrefix(
    at org.apache.cxf.aegis.type.basic.BeanType.getNameWithPrefix(
    at org.apache.cxf.aegis.type.basic.BeanType.writeSchema(
    at org.apache.cxf.aegis.databinding.AegisDatabinding.createSchemas(
    at org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(
    at org.apache.cxf.frontend.ServerFactoryBean.create(

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:

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="")
@SOAPBinding(use=SOAPBinding.Use.LITERAL, style=SOAPBinding.Style.DOCUMENT, parameterStyle=SOAPBinding.ParameterStyle.BARE)
public interface University {

    @WebResult(targetNamespace="", name="return", partName="return")
    @WebMethod(operationName="getTeacher", exclude=false)
    public Teacher getTeacher(@WebParam(targetNamespace="",
name="course", mode=WebParam.Mode.IN)
    Course course);

c) The implementation


//@WebServiceClient(name="", targetNamespace="")
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

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.setServiceBean(new UniversityImpl());
        // comment me to use JAXB
        svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
        System.out.println("Server started!");

e) The client

import org.apache.cxf.aegis.databinding.AegisDatabinding;
import org.apache.cxf.frontend.ClientProxyFactoryBean;

public class Client {

    public static void main(String[] args) {
        // see
        ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
        // comment me to use JAXB
        factory.getServiceFactory().setDataBinding(new AegisDatabinding());
        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.

View raw message