Tuto jaxrs [SOLVED]


Problem solved: check answer


Hello,

i am following the tutorial for jaxrs in order to make a webengine application. But, for the moment, i experiment a crash after having following the nuxeo tutorial for jaxrs: https://doc.nuxeo.com/810/nxdoc/webengine-jax-rs/

i get an error 500 after trying the test url: {"entity-type":"exception","code":"com.sun.jersey.api.NotFoundException","status":500,"message":"null for uri: http://localhost:8080/nuxeo/site/mysite"} EDIT> This error was because the bundle with jaxrs was not déclared in another bundle used for compiling. But, now, there is another error, see next answer to this post.

The tomcat Log show that:

WARNING: A HTTP GET method, public java.lang.String org.nuxeo.elasticsearch.http.readonly.Main.searchWithPayload(java.lang.String,javax.ws.rs.core.UriInfo,javax.ws.rs.core.MultivaluedMap) throws java.io.IOException,org.json.JSONException, should not consume any entity.

I show you my files: MyWebApp.java

import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

public class MyWebApp extends Application { 
   @Override    
   public Set<Class<?>> getClasses() {
        HashSet<Class<?>> result = new HashSet<Class<?>>(); 
       result.add(MyWebAppRoot.class);        
    return result;    }}

MyWebAppRoot.java

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("mysite")
public class MyWebAppRoot {
    @GET    
    public Object doGet() {       
     return "Hello World!";   
 }
}

MANIFEST.MF

Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Manifest-Version: 1.0
Bundle-ManifestVersion: 8.10
Bundle-Name: xxx.webengine
Bundle-SymbolicName: xxx.webengine;singleton:=true
Nuxeo-WebModule: xxx.webengine.MyWebApp

pom.xml of the bundle

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    
<parent> 
 <artifactId>xxx</artifactId>
  <groupId>fr.xxxxxx.xxxc</groupId>       
  <version>2.0.0-SNAPSHOT</version>
  <relativePath>../pom.xml</relativePath>
</parent>   
<modelVersion>4.0.0</modelVersion>    
<artifactId>fr.xxxxx.xxxx.webengine</artifactId>
<name>webengine test</name>
<dependencies> 
    <!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api 
    EDIT>>> The use of this dependency was a bad idea... check answer...-->
    <dependency>  
      <groupId>javax.ws.rs</groupId>  
      <artifactId>javax.ws.rs-api</artifactId>  
      <version>2.1</version> 
    </dependency>      
    <!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util -->  
    <dependency>  
      <groupId>org.eclipse.jetty</groupId> 
      <artifactId>jetty-util</artifactId>  
      <version>9.4.11.v20180605</version> 
    </dependency> 
    <dependency>          
      <groupId>org.nuxeo.ecm.webengine</groupId> 
      <artifactId>nuxeo-webengine-core</artifactId> 
    </dependency>        
    <dependency>  
      <groupId>org.jboss.seam</groupId> 
      <artifactId>jboss-seam</artifactId> 
    </dependency>  
</dependencies>
</project>

One mistake could be on the maven declaration of the bundle i have created. As i am beginner with maven, i have to improve my level. In the meanwhile,

if you have a project with a webengine /jaxrs, it could helps me.

thanks

0 votes

2 answers

2975 views

ANSWER



it's weird: on a nuxeo project compliant (made by CLI), webengine is ok. But in the project i m working on, nothing happened with webengine. The problem is probably the deployment of the application and module (a pack war)

EDIT> Yeah, it was a deployment problem. A jar was not include in the final package. A build instruction in the bundle POM was forgotten because of the use of the CLI.

0 votes



i try to touch on maven pom to declare my bundle in another bundle used for compiling project bundle and the error is now:

  • On browser page localhost:8080/nuxeo/site/mysite: # Etat HTTP 500 - org.apache.jasper.JasperException: An exception occurred processing JSP page /nuxeo_error.jsp at line 120
  • Server.log: ERROR [http-apr-8080-exec-1] [org.nuxeo.ecm.platform.web.common.exceptionhandling.DefaultNuxeoExceptionHandler] javax.servlet.ServletException: On requestURL: http://localhost:8080/nuxeo/site/mysite
    On requestURL: http://localhost:8080/nuxeo/site/mysite
    at org.nuxeo.ecm.platform.ui.web.rest.FancyURLFilter.doFilter(FancyURLFilter.java:140)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.nuxeo.ecm.platform.web.common.requestcontroller.filter.NuxeoRequestControllerFilter.doFilter(NuxeoRequestControllerFilter.java:146)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    
2018-07-09 11:34:03,865 ERROR [http-apr-8080-exec-1] [nuxeo-error-log] 
Request Attributes:

    NuxeoExceptionHandlerMarker : true
    org.nuxeo.ecm.login.context : javax.security.auth.login.LoginContext@6a77657
    messageBundle : java.util.PropertyResourceBundle@8a88c34
    nuxeo.disable.redirect.wrapper : true
    user_message : An unexpected error occurred. Click on the following links to get more information or go back to the application.
    com.sun.faces.context.ExternalContextFactoryImpl_KEY : com.sun.faces.context.ExternalContextImpl@14535fdd
    exception_message : javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
    securityError : false

for now, i think i am in a dead-end (cul-de-sac) for the project i m working on.

I could try the same addon jaxrs on a training project more nuxeo compliant with its architecture. Don't know where is the problem. Maybe the manifest.MF.

I investigate a new led: i quite sure the pom of the bundle need some dependency to make ok this jaxrs hello world. i ve added:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.1</version>
</dependency>

but it doesn't work and i have verified that without this dependency, the webengine on this url nuxeo/site is ok but the url nuxeo/site/mysite made a 404. As soon as i add this dependency, all webengine page go down with error i have showed before.

EDIT> NEVER import the javax.ws.rs for the Webengine. Use instead com.sun.jersey.

0 votes