1 Reply Latest reply on Nov 24, 2012 7:38 PM by sannsims

    Rest Server - Access to the specified resource () has been forbidden.

    sannsims

      Hello and thanks for reading my post.

       

      I'm working on an Infinispan Cache demo using Rest as my server (from the modules Infinispan 5.1).  I have two projects in Eclipse.  My application as one project using the above below and the infinispan-rest-server as another project.  Both are running in Eclipse Helios release 2, but when I try to execute the code below, theres an access issue.  I doubt running them both in Eclipse is the issue, but thought I would mention it just in case.

       

      I'm getting an access error, when I read the stream back from the HttpPut response, I get the following HTML error:

       

      HTTP Status 403 -


      type Status report

      message

      description Access to the specified resource () has been forbidden.


      JBoss Web/2.1.3.GA

       

      Here's the code (most of it) which produces the Access error:

       

      boolean isSuccessful = true;HttpClient client = 
      new DefaultHttpClient();String cacheName = 
      "_defaultcache";String key = 
      "hello";String url = 
      "http://localhost:8080/infinispan-rest-server/rest/" + cacheName + "/" + key;
      HttpPut put = 
      new HttpPut(url);put.setHeader( 
      "Content-type", "text/plain" );
      InputStream isPut = 
      null;
      try {
      StringEntity putEntity = 
      new StringEntity( "world" );put.setEntity( putEntity );
      HttpResponse r = client.execute( put );
      isPut = r.getEntity().getContent();
      String putHtml = streamToString( isPut );
      System.
      out.println( " HTTP PUT status " + putHtml );
      if( putHtml.contains( "Error report" ) ){
      isSuccessful = 
      false;}
      EntityUtils.consume( putEntity );
      } 
      
      catch (UnsupportedEncodingException e) {
      isSuccessful = 
      false;System.
      out.println( "Test Rest Server Error - PUT UnsupportedEncodingException" );e.printStackTrace();
      } 
      
      catch (ClientProtocolException e) {
      isSuccessful = 
      false;System.
      out.println( "Test Rest Server Error - PUT ClientProtocolException" );e.printStackTrace();
      } 
      
      catch (IOException e) {
      isSuccessful = 
      false;System.
      out.println( "Test Rest Server Error - PUT IOException" );e.printStackTrace();
      }
      

       

      Thanks!