users@glassfish.java.net

Problems using _at_UsesJAXBContext on GF 3.0.1 and GF 3.1

From: Steven Siebert <smsiebe_at_gmail.com>
Date: Fri, 15 Apr 2011 08:48:52 -0400

Good morning,

I'm having problems getting @UsesJAXBContext working on GF 3.0.1 and GF
3.1. It doesn't appear that the createJaxbContext() method is even called
on the JAXBContextFactory I register with that annotation.

As you can see from my demo below, I attempted to use @XmlSeeAlso to solve
my problem at first, but I commented this out with @UsesJAXBContext. For
more context on my situation, you can see my stackoverflow question (
http://stackoverflow.com/q/5627173/429621) , where I posted my original
problem.


@WebService(name = "SOS", targetNamespace = "http://www.opengis.net/sos/1.0
")
@UsesJAXBContext(value = SosServices.SosJaxbContext.class)
//_at_XmlSeeAlso({net.opengis.sos.v_1_0_0.filter.v_1_1_0.ObjectFactory.class,
net.opengis.sensorml.v_1_0_1.ObjectFactory.class})
public class SosServices {

    @WebMethod(operationName = "GetResult")
    public GetResultResponse getResult(GetResult request) {
        //do some stuff
    }


    public static class SosJaxbContext implements JAXBContextFactory {

        @Override
        public JAXBRIContext createJAXBContext(SEIModel sei,
                List<Class> classesToBind, List<TypeReference>
typeReferences)
                throws JAXBException {

            System.out.println("*******************Using server's custom
JAXBContext**********************************************"); //i never get
this in my console in NB/server log

            // Adding Toyota.class to our JAXBRIContext
            List<Class> classList = new ArrayList<Class>();
            classList.addAll(classesToBind);
            classList.add(TemporalOpsType.class);

            List<TypeReference> refList = new ArrayList<TypeReference>();
            refList.addAll(typeReferences);
            refList.add(new TypeReference(new QName("
http://www.opengis.net/ogc", "temporalOps"), TemporalOpsType.class));

            return JAXBRIContext.newInstance(classList.toArray(new
Class[classList.size()]),
                    refList, null, sei.getTargetNamespace(), false, null);
        }
    }
}


Any help would be greatly appreciated!

Thanks,

S