0
votes

This should be easy, but it's been costing me tons of time. I basically can't get a RESTful web service running under eclipse. I'm sure I'm missing something stupid, but resources seem to be a bit scattered and nothing covers the recent 4.0/EE 7 release.

I have a clean install of Eclipse Kepler (4.3). I try and set up a basic RESTful app using the following steps.

I have Java EE 7 installed

I open eclipse, point it to a fresh workspace and create a new 'Dynamic Web Application'.

Project name doesn't particularly matter, a new Target Runtime is created by downloading the Glassfish extension (New Runtime->Download additional server adapters->Glassfish). This requires restarting eclipse - so just repeat the previous, but select a Glassfish 4.0 runtime after clicking 'New Runtime'. Web Module is 3.1, everything else is default. I click 'Finish' to create my new project.

I then right click and open project properties, then 'Project Facets'. I check of JAX-RS (REST Web Services). Then click 'Further Configuration required...". I then select 'Disable Library Configuration' from the drop down. The fields receive the following values:

JAX-RS servlet name: JAX-RS Servlet

JAX-RS servlet class name: org.glassfish.jersey.servlet.ServletContainer

URL mapping patterns: /jaxrs/*

I then click OK to close all the windows.

Now adding a New->'RESTful Web Service from Pattern' creates a new class, that doesn't seem to ever get picked up by glassfish on deployment. My understanding is that it should auto scan and pick up things with an @path. It doesn't seem to. If I finagle things enough I can seem to access the application.wadl - but doesn't show my resource.

If I go back into properties and take a look at my JAX-RS project facet, I'm presented with an error box saying some of my values are invalid.

In the workspace log I'm greeted with the following exception:

!ENTRY org.eclipse.jst.jee 4 0 2013-07-02 21:54:27.780 !MESSAGE org.eclipse.jst.javaee.web.internal.impl.WebAppImpl cannot be cast to org.eclipse.jst.j2ee.webapplication.WebApp !STACK 0 java.lang.ClassCastException: org.eclipse.jst.javaee.web.internal.impl.WebAppImpl cannot be cast to org.eclipse.jst.j2ee.webapplication.WebApp at org.eclipse.jst.ws.jaxrs.core.internal.project.facet.UpdateWebXMLForJ2EE.run(UpdateWebXMLForJ2EE.java:32) at org.eclipse.jst.jee.model.internal.JEE5ModelProvider.modify(JEE5ModelProvider.java:255) at org.eclipse.jst.jee.model.internal.Web25MergedModelProvider.modify(Web25MergedModelProvider.java:92) at org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSFacetInstallDelegate.createServletAndModifyWebXML(JAXRSFacetInstallDelegate.java:275) at org.eclipse.jst.ws.jaxrs.core.internal.project.facet.JAXRSFacetInstallDelegate.execute(JAXRSFacetInstallDelegate.java:156) at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.callDelegate(FacetedProject.java:1477) at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modifyInternal(FacetedProject.java:441) at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChangesInternal(FacetedProject.java:1181) at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.access$2(FacetedProject.java:1117) at org.eclipse.wst.common.project.facet.core.internal.FacetedProject$5.run(FacetedProject.java:1099) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345) at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChanges(FacetedProject.java:1109) at org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy.commitChanges(FacetedProjectWorkingCopy.java:2020) at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$4.run(FacetsPropertyPage.java:232) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345) at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$5.run(FacetsPropertyPage.java:246) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

Any insight would be so greatly appreciated.

1

1 Answers

0
votes

Try running Eclipse with Java SE. The parts of Java EE that your project needs to compile against can come from Glassfish itself. You might also need to use @Path rather than @path since it matches to a type name and is case sensitive.