Skip to Content

Error when deploying EAR file (restful)

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 29 at 11:23 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 29 at 06:22 AM

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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.