Skip to Content
0

Error when deploying EAR file (restful)

Jan 22 at 06:25 PM

129

avatar image

Hi experts,

I am getting the following error when deploying an EAR file: "CSN component of deployment item is not available".

That is all the message.

The application is about restful service.

I am doing the exact tutorial from this link: Put SOAP to REST using CE

I have no idea what is missing.

Maybe an reference target in the application-j2ee-engine.xml ?

Can someone help?

Thanks.

Regards.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
David Raven Jan 29 at 11:23 AM
0

It finally works!!!!

I also added cxf-core-3.2.1.jar file in EAR project as Deployment Assembly.

Thanks Richard for your precious help. You put me on the way.

So I would like to sum up.

1) Create a class in a package.

2) Configure web.xml as Richard wrote.

3) Add the cxf-core-3.2.1.jar (and all the jars that we mentioned in this page).

Best Regards.


untitled.png (55.8 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi, David,I am so glad that you've solved this issue.

0
Richard Zhao
Jan 29 at 06:22 AM
3

Hello, David, I would like to know that whether this message is just a warning message or not?


1517206919156.jpg (33.0 kB)
Show 8 Share
10 |10000 characters needed characters left characters exceeded

Hi Richard,

Yes it is a warning. But the ear file is still in the deploy view. I tried to access the restful service via the URL in browser but nothing returns from the GET method.

Am I missing something ?

N.B: I did not make any change to the application-j2ee-engine.xml or application.xml files.

Here is the code: 
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;


@WebService(targetNamespace = "http://default_package/", portName = "HelloPort", serviceName = "HelloService")
@Path("/hello")
public class Hello {
	@WebMethod(operationName = "sayPlainTextHello", action = "urn:SayPlainTextHello")
	@GET
	  @Produces(MediaType.TEXT_PLAIN)
	  public String sayPlainTextHello() {
	    return "Hello Jersey";
	  }
	
	 // This method is called if XML is request
	  @WebMethod(operationName = "sayXMLHello", action = "urn:SayXMLHello")
	@GET
	  @Produces(MediaType.TEXT_XML)
	  public String sayXMLHello() {
	    return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
	  }


	// This method is called if HTML is request
	  @WebMethod(operationName = "sayHtmlHello", action = "urn:SayHtmlHello")
	@GET
	  @Produces(MediaType.TEXT_HTML)
	  public String sayHtmlHello() {
	    return "<html> " + "<title>" + "Hello Jersey" + "</title>"
	        + "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";
	  }
}

This is the Java Build Path:

Thank you.

untitled.png (67.3 kB)
0

I think your class is correct. Could you provide the URL you are using to call the restful service, please? It is possible that the URL is not correct? Besides, I suggest that you should remove @WebMethod annotation which is used for SOAP because you are just want to create restful web service.

0

Hi,

I removed the @WebMethod annotation.

I did not mentionbut I added jars to the lib folder in WEB project:

jackson-core-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-xc-1.9.2.jar
jersey-client-1.19.1.jar
jersey-core-1.19.1.jar
jersey-json-1.19.1.jar
jersey-server-1.19.1.jar
jersey-servlet-1.19.1.jar
jettison-1.1.jar
jsr311-api-1.1.1.jar

This is the URL: http://server/KM30_WEB/Get

I even created a simple servlet and did not succeed to access it via the URL. If I remove the restful stuf, I can access the servlet.

I entered the log file and maybe the following can help.

Global [startApp] operation of application [JavaEE/KM30_EAR] failed with errors on server process [907678850].
0

The URL is not correct. The @path value is "/hello". and please notice that the jersey servlet URL-pattern should be included in your restful URL. So the URL should look like http://server/KM30_WEB/rest/hello

1517218988394.jpg (164.7 kB)
1

Hi,

I configure the web.xml as you wrote. I get the same message at deploy.

I tried to access it via the new URL you gave me but got nothing.

The new thing is that I can access the servlet which is in the same WEB project.

Do I have to configure something in application-j2ee-engine.xml file ?

This is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>KM30_WEB</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>MyServlet</display-name>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>MyServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/MyServlet</url-pattern>
  </servlet-mapping>
  
  
  
    <servlet>
    <servlet-name>jersey-serlvet</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value></param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>jersey-serlvet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
  
</web-app>

0

And this is the new class after you helped me removing the WebMethod annotation.

I kept the class very simple.

Thank you.

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;


@Path("/hello")
public class Hello {
	@GET
	  @Produces(MediaType.TEXT_PLAIN)
	  public String sayPlainTextHello() {
	    return "Hello Jersey";
	  }
	
	 // This method is called if XML is request
	@GET
	  @Produces(MediaType.TEXT_XML)
	  public String sayXMLHello() {
	    return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
	  }


	// This method is called if HTML is request
	@GET
	  @Produces(MediaType.TEXT_HTML)
	  public String sayHtmlHello() {
	    return "<html> " + "<title>" + "Hello Jersey" + "</title>"
	        + "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";
	  }
}



0

This is the log, it may help.

Cannot process an HTTP request to servlet [jersey-serlvet] in [KM30_WEB] web application.

500 Internal Server Error is returned for HTTP request [http://server/KM30_WEB/rest/hello]:
  component [jersey-serlvet],
  web module [KM30_WEB],
  application [JavaEE/KM30_EAR],
  DC name [JavaEE/KM30_EAR],
  CSN component[],
  problem categorization [com.sap.ASJ.web.000137],
  internal categorization [-160808738].

[EXCEPTION]
java.lang.IllegalArgumentException: com.sun.jersey.config.property.packages contains no packages
	at com.sun.jersey.api.core.PackagesResourceConfig.getPackages(PackagesResourceConfig.java:115)
	at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
	at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:696)
	at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:674)
	at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:205)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
	at javax.servlet.GenericServlet.init(GenericServlet.java:270)
.
.
.

I posted a lot of log. It can help us find the problem and help others that may be stucked with same issue.

0

Hopefully there is an improvement.

I do not get the CSN message error anymore.

The thing is to put the class in a package. Without package, you get the CSN error message.

So now, my web.xml looks like this.

  <servlet>
    <servlet-name>jersey-serlvet</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>com.test</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>jersey-serlvet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>


<br>

The class looks like this.

package com.test;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/hello2")
public class Hello2 {
	@GET
	  @Produces(MediaType.TEXT_PLAIN)
	  public String sayPlainTextHello() {
	    return "Hello Jersey";
	  }
	
	 // This method is called if XML is request
	@GET
	  @Produces(MediaType.TEXT_XML)
	  public String sayXMLHello() {
	    return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
	  }


	// This method is called if HTML is request
	@GET
	  @Produces(MediaType.TEXT_HTML)
	  public String sayHtmlHello() {
	    return "<html> " + "<title>" + "Hello Jersey" + "</title>"
	        + "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";
	  }
}


<br>

I created a new class named Hello2.

Now everything is deployed without warning but still cannot call the restful class via http://server/KM30_WEB/rest/hello2.

In log file, I have new error which is tje following.

[EXCEPTION]
java.lang.NoSuchMethodError: org.apache.cxf.common.util.UrlUtils.urlEncode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
	at org.apache.cxf.jaxrs.utils.HttpUtils.urlEncode(HttpUtils.java:155)
	at org.apache.cxf.jaxrs.utils.HttpUtils.urlEncode(HttpUtils.java:150)
	at org.apache.cxf.jaxrs.utils.HttpUtils.componentEncode(HttpUtils.java:137)
	at org.apache.cxf.jaxrs.utils.HttpUtils.pathEncode(HttpUtils.java:160)
	at org.apache.cxf.jaxrs.utils.HttpUtils.encodePartiallyEncoded(HttpUtils.java:198)
	at org.apache.cxf.jaxrs.model.URITemplate.<init>(URITemplate.java:70)
	at org.apache.cxf.jaxrs.model.URITemplate.createExactTemplate(URITemplate.java:345)
	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.buildPath(UriBuilderImpl.java:665)
	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuildUriParts(UriBuilderImpl.java:119)
	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuild(UriBuilderImpl.java:101)
	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.build(UriBuilderImpl.java:83)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:721)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
....

I hope I did not make too much mess here. I try to keep things clear.

Thanks again.

0