This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 179216 - Rest Services with Spring framework doesn't work
Summary: Rest Services with Spring framework doesn't work
Status: RESOLVED WONTFIX
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Milan Kuchtiak
URL:
Keywords:
: 201386 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-05 04:05 UTC by Milan Kuchtiak
Modified: 2016-07-07 09:54 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kuchtiak 2010-01-05 04:05:33 UTC
When a REST Service is created in a web application with Spring Framework enabled the exception is thrown during deployment :

SEVERE: Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.

(Tested with Java EE 6 web application and GlassFish V3)
Comment 1 Milan Kuchtiak 2010-01-05 05:56:55 UTC
Note: the exception is thrown even when issue 177679 (compilation problem) is fixed. That exception is caused by missing jersey-spring.jar on classpath.

The entire workaround for this issue of several actions:

1. case: Simple REST Resources (no REST resources from entity classes)
- if rest configuration is based on web.xml, the ServletAdaptor must contain init params:

    <servlet>
        <servlet-name>ServletAdaptor</servlet-name>
        <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>org.mypackage.rest.services</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

2. case: REST resources from entity classes
- rest configuration must be based on web.xml, the ServletAdaptor must contain init params (see above)

- persistence.xml must contain provider element :

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="RestApplication3PU" transaction-type="JTA">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <jta-data-source>jdbc/sample</jta-data-source>
    <properties/>
  </persistence-unit>
</persistence>

- persistence.xml doesn't work with version="2.0"

Action Item 1: resolve how to run REST services with Spring with Persistence 2.0

Action Item 2: resolve how to run REST services with Spring without web.xml
Comment 2 Quality Engineering 2010-01-06 23:39:41 UTC
Integrated into 'main-golden', will be available in build *201001070200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ac6f7f763ab9
User: mkuchtiak@netbeans.org
Log: #179216: fixing first part of the issue
Comment 3 Denis Anisimov 2011-09-01 06:20:29 UTC
*** Bug 201386 has been marked as a duplicate of this bug. ***
Comment 4 Denis Anisimov 2011-10-07 06:41:24 UTC
Known problem with persistence with version 2.0.
Postpone to the next release.
Comment 5 Martin Balin 2016-07-07 09:54:22 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss