Note that there are some explanatory texts on larger screens.

plurals
  1. POtesting REST web services with arquillian
    primarykey
    data
    text
    <p>We would like to test our REST APIs using arquillian.</p> <p>We use glassfish for production and arquillian.</p> <p>We already have arquillian tests for some JMS queue we expose, and that works fine, so we at least have some basics right. When we started using that setup for REST testing, at the first HTTP GET we sent on the REST URLS, we got the exception: <code>com.sun.jersey.api.container.ContainerException: No WebApplication provider is present. </code></p> <p>Here is our ShrinkWrap setup:</p> <pre><code> public static WebArchive createTestArchive() { return ShrinkWrap.create(WebArchive.class, "test.war") // Create jar .addPackages(true, "&lt;our packages, plus some dependencies&gt;") //, "com.ocpsoft.pretty") .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") // b .setWebXML("WEB-INF/web.xml") .addAsWebInfResource("WEB-INF/faces-config.xml") //.addAsWebInfResource(new StringAsset("&lt;faces-config version=\"2.0\"/&gt;"), "faces-config.xml") .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml"); } </code></pre> <p>I think our web.xml is relevant:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"&gt; &lt;servlet&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt; &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;context-param&gt; &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt; &lt;param-value&gt;.xhtml&lt;/param-value&gt; &lt;/context-param&gt; &lt;!-- Pretty faces config --&gt; &lt;filter&gt; &lt;filter-name&gt;Pretty Filter&lt;/filter-name&gt; &lt;filter-class&gt;com.ocpsoft.pretty.PrettyFilter&lt;/filter-class&gt; &lt;async-supported&gt;true&lt;/async-supported&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;Pretty Filter&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt; &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt; &lt;dispatcher&gt;ERROR&lt;/dispatcher&gt; &lt;dispatcher&gt;ASYNC&lt;/dispatcher&gt; &lt;/filter-mapping&gt; &lt;!-- disable annotation scanning by the PrettyFaces module --&gt; &lt;context-param&gt; &lt;param-name&gt;com.ocpsoft.pretty.BASE_PACKAGES&lt;/param-name&gt; &lt;param-value&gt;none&lt;/param-value&gt; &lt;/context-param&gt; &lt;/web-app&gt; </code></pre> <p><strong>EDIT:</strong> Due to the question, I have now changed to glassfish-embedded 3.1.1, and updated the question based on the new error message. We are using glassfish 3.1.2 for the main operation.</p> <p>Also note that we first get a warning:</p> <pre><code>WARNING: Could not instantiate service class org.glassfish.osgicdi.impl.OSGiServiceExtension java.lang.NoClassDefFoundError: org/osgi/framework/ServiceException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) </code></pre> <p>[..]</p> <pre><code>Caused by: java.lang.ClassNotFoundException: org.osgi.framework.ServiceException at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) </code></pre> <p>(but it seems it's safe to ignore that warning, see this and the bug it links to: <a href="http://www.java.net/forum/topic/glassfish/glassfish/could-not-instantiate-service-class-orgglassfishosgicdiimplosgiserviceextension?force=217" rel="nofollow">http://www.java.net/forum/topic/glassfish/glassfish/could-not-instantiate-service-class-orgglassfishosgicdiimplosgiserviceextension?force=217</a>)</p> <p>Then the error:</p> <pre><code>SEVERE: WebModule[/test]StandardWrapper.Throwable com.sun.jersey.api.container.ContainerException: No WebApplication provider is present at com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69) at com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:391) at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:306) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload