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 3394562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:11:06+00:00 2026-05-18T04:11:06+00:00

I’m running embedded jetty inside of a spring ioc container. The spring ioc contains

  • 0

I’m running embedded jetty inside of a spring ioc container. The spring ioc contains also an embedded hsqldb which makes the whole configuration a nice and complete web application development environment (on a single JVM). Now I’m trying to add apache CXF to this environment to make the jetty host not only servlets but also web services.

Unfortunately I’m getting NullPointerException when attempting to access http://127.0.0.1:8080/cxf/* (servlets and static content are served ok). Any idea what’s wrong?

2010-09-17 15:37:20,099 [btpool0-1 - /cxf/] DEBUG org.mortbay.log - REQUEST /cxf/ on org.mortbay.jetty.HttpConnection@2d14d18f
2010-09-17 15:37:20,100 [btpool0-1 - /cxf/] DEBUG org.mortbay.log - servlet=cxf-servlet-holder
2010-09-17 15:37:20,100 [btpool0-1 - /cxf/] DEBUG org.mortbay.log - chain=null
2010-09-17 15:37:20,100 [btpool0-1 - /cxf/] DEBUG org.mortbay.log - servelet holder=cxf-servlet-holder
2010-09-17 15:37:20,101 [btpool0-1 - /cxf/] ERROR org.mortbay.log - /cxf/
java.lang.NullPointerException
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:108)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
    at org.mortbay.jetty.Server.handle(Server.java:281)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:821)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:368)
    at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

I’m initializing spring with:

public static void main(String[] args) throws Exception {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] { "jetty-beans.xml" , "cxf-beans.xml" });
    applicationContext.getBean("web-server", Server.class).join();
}

jetty-beans.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean name="web-server" class="org.mortbay.jetty.Server"
        init-method="start">
        <property name="connectors">
            <list>
                <bean class="org.mortbay.jetty.nio.SelectChannelConnector">
                    <property name="host" value="localhost" />
                    <property name="port" value="8080" />
                </bean>
            </list>
        </property>
        <property name="handlers">
            <list>
                <ref bean="web-server-context-static" />
                <ref bean="web-server-context-servlet" />
                <ref bean="web-server-context-cxf" />
            </list>
        </property>
    </bean>

    <bean name="web-server-context-static" class="org.mortbay.jetty.servlet.Context">
        <property name="contextPath" value="/static" />
        <property name="handler">
            <bean class="org.mortbay.jetty.handler.ResourceHandler">
                <property name="resourceBase" value="static" />
            </bean>
        </property>
    </bean>

    <bean name="web-server-context-servlet" class="org.mortbay.jetty.servlet.Context">
        <property name="contextPath" value="/servlet" />
        <property name="handler">
            <bean class="org.mortbay.jetty.servlet.ServletHandler">
                <property name="servlets">
                    <list>
                        <bean class="org.mortbay.jetty.servlet.ServletHolder">
                            <property name="name" value="servlet-holder" />
                            <property name="servlet">
                                <bean class="test.TestServlet" />
                            </property>
                        </bean>
                    </list>
                </property>
                <property name="servletMappings">
                    <list>
                        <bean class="org.mortbay.jetty.servlet.ServletMapping">
                            <property name="servletName" value="servlet-holder" />
                            <property name="pathSpec" value="/*" />
                        </bean>
                    </list>
                </property>
            </bean>
        </property>
    </bean>

    <bean name="web-server-context-cxf" class="org.mortbay.jetty.servlet.Context">
        <property name="contextPath" value="/cxf" />
        <property name="handler">
            <bean class="org.mortbay.jetty.servlet.ServletHandler">
                <property name="servlets">
                    <list>
                        <bean class="org.mortbay.jetty.servlet.ServletHolder">
                            <property name="name" value="cxf-servlet-holder" />
                            <property name="servlet">
                                <bean class="org.apache.cxf.transport.servlet.CXFServlet">
                                </bean>
                            </property>
                        </bean>
                    </list>
                </property>
                <property name="servletMappings">
                    <list>
                        <bean class="org.mortbay.jetty.servlet.ServletMapping">
                            <property name="servletName" value="cxf-servlet-holder" />
                            <property name="pathSpec" value="/*" />
                        </bean>
                    </list>
                </property>
            </bean>
        </property>
    </bean>

</beans>

cxf-beans.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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="test-ws-impl" class="test.TestWSImpl" />

    <jaxws:endpoint id="test-ws-endpoint" implementor="#test-ws-impl"
        address="/testWS" />

</beans>

classpath:

activation-1.1.jar
commons-logging-1.1.1.jar
cxf-2.2.10.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.13.jar
jcl-over-slf4j-1.6.1.jar
jetty-6.1.3.jar
jetty-annotations-6.1.3.jar
jetty-util-6.1.3.jar
log4j-1.2.16.jar
neethi-2.0.4.jar
org.springframework.aop-3.0.3.RELEASE.jar
org.springframework.asm-3.0.3.RELEASE.jar
org.springframework.beans-3.0.3.RELEASE.jar
org.springframework.context-3.0.3.RELEASE.jar
org.springframework.context.support-3.0.3.RELEASE.jar
org.springframework.core-3.0.3.RELEASE.jar
org.springframework.expression-3.0.3.RELEASE.jar
servlet-api-2.5-6.1.3.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.5.jar

TestWSImpl.java:

package test;

import javax.jws.WebService;

@WebService(endpointInterface = "test.TestWSInterface")
public class TestWSImpl implements TestWSInterface {

    @Override
    public String doTest(String testSubject) {
        return "successfully tested:" + testSubject;
    }

}

TestWSInterface.java

package test;

import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public interface TestWSInterface {

    String doTest(@WebParam String testSubject);

}
  • 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-18T04:11:06+00:00Added an answer on May 18, 2026 at 4:11 am

    I’ve found out that the above configuration was wrong:

    I did not use any WebApplicationContext with has to be initialized prior to the CXFServlet. The simple solution is to use the non-spring version of CXFServlet – it does not require any ApplicationContext (I don’t want to create a separate ApplicationContext for the Web Services since I need to have shared DataSource between them) but it has too be initialized (Web Services must be published in the code).

    After solving the Context issue I’ve found out that jetty 6.1 does not initialize the servlet context in proper way, everything works fine after updating to 7.x.

    After writing custom WebApplicationContext I was able to use the main/root ApplicationContext as the WebApplicationContext allowing me to use the spring version of CXFServlet with about 6 lines of glue code.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from

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.