You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by hanasaki jiji <ha...@gmail.com> on 2009/03/10 08:44:48 UTC

JAX-RS adding bean ID in context throws null pointer

Deployment is a WAR file.  For some reason the context is throwing a
null pointer when the restful resource bean is setup with an ID.  Any
ideas why and resolution?    The only thing that comes to mind is that
the Impl class is not found in the classpath however it has been
validated to exist under
WEB-INF/classes/com/service/impl/ServiceUserManagerImplRS  Setting the
class impl to a class name that is known not to exist does correctly
throw "java.lang.ClassNotFoundException" instead of a NPE.

Thank you.

web.xml loads the context
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/SpringCore/applicationContext.xml

This file contains:
    <import resource="classpath:/SpringApplications/**/applicationContext.xml"
/>
    <import resource="classpath:/SpringApplications/**/*ApplicationContext.xml"
/>
    <import resource="classpath:/SpringApplications/*/*Bean.xml" />

The WAR has a WEB-INF/classes/SpringApplications/cxf/application.xml
which is read from the above during the scan.

The below error is thrown from when the bean ID is attempted to be
setup / instantiated
<?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:jaxrs="http://cxf.apache.org/jaxrs"
    xmlns:cxf="http://cxf.apache.org/core"
    xsi:schemaLocation="
        http://cxf.apache.org/jaxrs
        http://cxf.apache.org/schemas/jaxrs.xsd
        http://cxf.apache.org/core
        http://cxf.apache.org/schemas/core.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        "
        default-lazy-init="false">

    <!--import resource="classpath:WEB-INF/SpringApplications/cxf/cxf.xml" />
    <import resource="classpath:WEB-INF/SpringApplications/cxf/cxf-extension-jaxrs-binding.xml"
/>
    <import resource="classpath:WEB-INF/SpringApplications/cxf/cxf-servlet.xml"
/-->

    <!-- Enable message logging using the CXF logging feature -->
    <cxf:bus>
        <cxf:features>
            <cxf:logging/>
        </cxf:features>
    </cxf:bus>

    <bean id="serviceUserManagerImplRS"
class="com.service.impl.ServiceUserManagerImplRS" />
  ...
...



== from Tomcat ==
Mar 10, 2009 1:43:40 AM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NullPointerException
	at org.apache.cxf.transport.servlet.CXFServlet.updateContext(CXFServlet.java:125)
	at org.apache.cxf.transport.servlet.CXFServlet.loadSpringBus(CXFServlet.java:101)
	at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:70)
	at org.apache.cxf.transport.servlet.AbstractCXFServlet.init(AbstractCXFServlet.java:79)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)