Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:31:07+00:00 2026-05-25T19:31:07+00:00

I have a class X which is used in a Service interface of a

  • 0

I have a class X which is used in a Service interface of a Web service built with Apache CXF and JAX-WS. This class X has no default constructor and I would like to avoid this default constructor. I was wondering whether I can use the @XmlJavaTypeAdapter annotation as a solution.

The methods from the ClassXService:

@WebMethod
@XmlJavaTypeAdapter(ClassXAdapter.class)
public void myMethod(ClassX arg0);

@WebMethod
@XmlJavaTypeAdapter(ClassXAdapter.class)
public ClassX myMethod2();

The adapter extends XmlAdapter and defines correctly the marshal and unmarshal methods.

However, with or without using the XmlJavaTypeAdapter annotation, I am always getting the same error:

Exception in thread "main" org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:292)
    at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:438)
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)
    at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
    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:157)
    at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
    at my.package.Main.main(Main.java:35)    
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    my.package.ClassX does not have a no-arg default constructor.
        this problem is related to the following location:
            at my.package.ClassX
            at private my.package.ClassX my.package.jaxws_asm.MyMethod.arg0
            at my.package.jaxws_asm.MyMethod2
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:383)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:594)
at org.apache.cxf.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:258)
at org.apache.cxf.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:167)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:418)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:290)
... 10 more

Is it not possible to use an adapter to avoid to provide a default no-arg constructor? If yes, does someone has an idea why I get an exception even when the XmlJavaTypeAdapter annotation is used?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:31:08+00:00Added an answer on May 25, 2026 at 7:31 pm

    Change it to:

    
       @WebMethod
       public void myMethod(@XmlJavaTypeAdapter(ClassXAdapter.class)   ClassX arg0);
    
       @WebMethod
       @XmlJavaTypeAdapter(ClassXAdapter.class)
       public ClassX myMethod2();
    
    

    The adapter needs to be defined on the parameter, not the method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a library which has a basic class which is used extensively by
I have written a .NET Windows service which has a WCF service built into
I have a singleton class which is being used throughout the app. I am
I have a class which contains a static collection that can be used across
I have a file attachment class (FileAttachment) which is used in several other classes.
Let's say I have a list in a class which will be used in
I have a silly, little class FileSystemSize which can be used both as an
I have class A which extends the Activity class. This class is in package
I have a Customer class which has all the account info.(it does NOT extend
Suppose I have a ASP.NET Web API controller that uses a service, which in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.