Announcement Announcement Module
Collapse
No announcement yet.
java.lang.NoSuchMethodError: javax/xml/bind/JAXBContext.newInstance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.NoSuchMethodError: javax/xml/bind/JAXBContext.newInstance

    Hi,

    I am using Jaxb2 marshaller for my web service. I could run the sample web service with this without any problems.
    But now its giving errror while creating bean "marshaller" and the error is:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'bookDeliverySlotsdEndPoint' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Cannot resolve reference to bean 'marshaller' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/xml/bind/JAXBContext.newInstance([Ljava/lang/ClassLjavax/xml/bind/JAXBContext;
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/xml/bind/JAXBContext.newInstance([Ljava/lang/ClassLjavax/xml/bind/JAXBContext;
    Caused by: java.lang.NoSuchMethodError: javax/xml/bind/JAXBContext.newInstance([Ljava/lang/ClassLjavax/xml/bind/JAXBContext;
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.creat eJaxbContextFromClasses(Jaxb2Marshaller.java:306)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.creat eJaxbContext(Jaxb2Marshaller.java:280)
    at org.springframework.oxm.jaxb.AbstractJaxbMarshalle r.afterPropertiesSet(AbstractJaxbMarshaller.java:1 25)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1057)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1024)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:421)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:140)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:248)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:128)
    at org.springframework.beans.factory.support.Construc torResolver.resolveConstructorArguments(Constructo rResolver.java:329)
    The only diff is my xsd file & DTOs generated by it with date type as:

    <element name="BookDeliverySlotsRequest">
    <complexType>
    <sequence>
    <element name="deliveryDate" type="dateTime"/>
    <element name="startTime" type="dateTime"/>
    <element name="endTime" type="dateTime"/>
    <element name="addressLine1" type="string"/>
    <element name="addressLine2" type="string"/>
    <element name="addressLine3" type="string"/>
    <element name="postcode" type="string"/>
    <element name="totalWeight" type="double"/>
    <element name="totalTimeInMins" type="long"/>
    <element name="deliveryCenter" type="string"/>
    </sequence>
    </complexType>
    </element>

    <element name="BookDeliverySlotsResponse" type="tns:Booking"/>
    Does anyone has idea what can be causing the error?
    Does this javax/xml/bind/JAXBContext.newInstance() method expect java 1.6 version??

    I am using java 1.5 & WAS6.1.

    Any pointers will be helpful.

    Thanks,
    Sulabha

  • #2
    Same issue like yours

    ...did you get to the bottom of it? Is the the version of Java or SAAJ that's the problem?

    Regards,
    Igor

    Comment


    • #3
      Fixed it...

      The problem was in the JAXB library included with Spring - I think it was missing the implementation. I downloaded a fresh library from their project website and everything's working.

      Comment


      • #4
        Well, Spring-WS ships with two versions of JAXB: 1 and 2. When using the Jaxb2Marshaller, you have to make sure that the JAXB1 jar is not on the classpath.

        Comment


        • #5
          It would be nice if...

          Hello Arjen,

          without being too critical of the doco (who likes to write the detailed doco these days), it would be nice if there was a troubleshooting section in the Spring Web Services doco - where common issues are documented - I am not the first person who has come across this one.

          The other "beauty" was the generated classes (by JAXB) - if you're the first time user and if you don't know anything about package-info.java class and don't include it in your build you get a strange error (namespace expected should be X and your namespace is Y). It took me several days to work out that this class is actually important (no one said so on JAXB XJC website )

          But it's all good now.

          A question on a different topic - are there any examples on how to use arrays with Spring Web Services (without wrapping an array property within a class please). Any examples on this one - this is one of the first things people would like to try with their Hello World samples.

          Regards,
          Igor

          Comment

          Working...
          X