Announcement Announcement Module
Collapse
No announcement yet.
Error while loading application context XML Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error while loading application context XML

    Hello,

    I am trying to create a web service using spring with cxf and I am encountering the following error when I try to load the application context:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sendMYDataService': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:380)
    at org.springframework.test.AbstractSingleSpringConte xtTests.createApplicationContext(AbstractSingleSpr ingContextTests.java:213)
    at org.springframework.test.AbstractSingleSpringConte xtTests.loadContextLocations(AbstractSingleSpringC ontextTests.java:189)
    at org.springframework.test.AbstractSingleSpringConte xtTests.loadContext(AbstractSingleSpringContextTes ts.java:169)
    at org.springframework.test.AbstractSpringContextTest s.getContext(AbstractSpringContextTests.java:140)
    at org.springframework.test.AbstractSingleSpringConte xtTests.setUp(AbstractSingleSpringContextTests.jav a:98)
    at org.springframework.test.ConditionalTestCase.runBa re(ConditionalTestCase.java:76)
    at com.intellij.rt.execution.junit.JUnitStarter.main( JUnitStarter.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at com.intellij.rt.execution.application.AppMain.main (AppMain.java:90)
    Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
    at org.apache.cxf.transport.servlet.ServletTransportF actory.getDestination(ServletTransportFactory.java :102)
    at org.apache.cxf.endpoint.ServerImpl.initDestination (ServerImpl.java:90)
    at org.apache.cxf.endpoint.ServerImpl.<init>(ServerIm pl.java:69)
    at org.apache.cxf.frontend.ServerFactoryBean.create(S erverFactoryBean.java:118)
    at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create (JaxWsServerFactoryBean.java:168)
    at org.apache.cxf.jaxws.EndpointImpl.getServer(Endpoi ntImpl.java:339)
    at org.apache.cxf.jaxws.EndpointImpl.doPublish(Endpoi ntImpl.java:252)
    at org.apache.cxf.jaxws.EndpointImpl.publish(Endpoint Impl.java:202)
    at org.apache.cxf.jaxws.EndpointImpl.publish(Endpoint Impl.java:397)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeCustomInitMethod( AbstractAutowireCapableBeanFactory.java:1414)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1375)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1335)
    ... 34 more


    Process finished with exit code -1

    My ApplicationContext.xml is like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/oxm http://www.springframework.org/schem...ng-oxm-1.5.xsd
    http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

    <bean id="sendMYDataEndpoint"
    class="my.com.malaya.amrt.jrs.endpoint.SendMYDataE ndpoint">
    <description>
    This endpoint handles the MY Data related Web Service messages.
    </description>
    </bean>

    <jaxws:endpoint id="sendMYDataService"
    implementor="#sendMYDataEndpoint"
    wsdlLocation="./amrt-ws/src/main/webapp/WEB-INF/wsdl/SendMYDataService.wsdl"
    xmlns:s="http://amrt.malaya.com.my/ws/definitions"
    serviceName="s:SendServiceOrder"
    endpointName="s:SOAPEventSource"
    address="/SendMYDataService"/>
    </beans>

    Error is encountered when I run this code:
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"my/com/malaya/amrt/jrs/applicationContext-jrs-ws.xml"});

    Any idea what's causing this? I am new to Spring and CXF. Please help. Thanks in advance!

  • #2
    please help

    hi i'm struggling with same problem, can some one help to resolve this.

    smx@root:osgi> Exception in thread "SpringOsgiExtenderThread-78" org.springframework.beans.factory.BeanCre
    ationException: Error creating bean with name 'HTTPEndpoint': Invocation of init method failed; nested exc
    eption is javax.xml.ws.WebServiceException: java.lang.NullPointerException

    Comment


    • #3
      Hi

      i think that your problem is missing dependency.

      Class javax/servlet/ServletOutputStream is part of geronimo-servlet_2.5_spec-1.2.jar

      Here is a list of dependencies for CXF.


      Code:
      commons-logging-1.1.jar
      geronimo-activation_1.1_spec-1.0-M1.jar (or Sun's Activation jar)
      geronimo-annotation_1.0_spec-1.1.jar (JSR 250)
      geronimo-javamail_1.4_spec-1.0-M1.jar (or Sun's JavaMail jar)
      geronimo-servlet_2.5_spec-1.1-M1.jar (or Sun's Servlet jar)
      geronimo-ws-metadata_2.0_spec-1.1.1.jar (JSR 181)
      geronimo-jaxws_2.1_spec-1.0.jar (or Sun's jaxws-api-2.1.jar)
      geronimo-stax-api_1.0_spec-1.0.1.jar (or other stax-api jar)
      jaxb-api-2.1.jar
      jaxb-impl-2.1.9.jar
      jetty-6.1.5.jar
      jetty-util-6.1.5.jar
      neethi-2.0.3.jar
      saaj-api-1.3.jar
      saaj-impl-1.3.jar
      wsdl4j-1.6.2.jar
      wstx-asl-3.2.1.jar
      XmlSchema-1.4.3.jar
      xml-resolver-1.2.jar

      Comment


      • #4
        Error while loading application context XML

        You mean something like this?

        Code:file = "officedata.xml";xml=simplexml_load_filefile;forea ch xml->xpath//userid="2"/lastname as desc dom=dom_import_simplexmldesc;dom->nodeValue = "Penner"; file_put_contentsfile, xml->asXML;Which works like a charm...Thanks

        Comment

        Working...
        X