[OTDev] Creation of a new feature - Tomcat

chung chvng at mail.ntua.gr
Fri Dec 25 15:11:07 CET 2009


Hi Nina and Merry Christmas,
 It's weird that exactly the same request sometimes results in a status
200 response while some other times the server
 responds with a 400 status code. I attach the html that is returned
including the message "Nothing to write!
http://ambit.uni-plovdiv.bg:8080/ambit2".
 The corresponding request and response headers are:

REQUEST:
+ POST /ambit2/feature/ HTTP/1.1
+ User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7
OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15 libssh2/1.2.1
+ Host: ambit.uni-plovdiv.bg:8080
+ Accept: */*
+ Content-type:application/rdf+xml
+ Content-Length: 1413
+ Expect: 100-continue
+ 

RESPONSE:
- HTTP/1.1 100 Continue
- HTTP/1.1 400 Bad Request
- Server: Apache-Coyote/1.1
- Date: Sat, 26 Dec 2009 14:01:03 GMT
- Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
- Accept-Ranges: bytes
- Server: Noelios-Restlet/2.0m3
- Content-Type: text/html;charset=ISO-8859-1
- Content-Length: 4394
- Connection: close

An example of a successful request/response is:

+ POST /ambit2/feature/ HTTP/1.1
+ User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7
OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15 libssh2/1.2.1
+ Host: ambit.uni-plovdiv.bg:8080
+ Accept: */*
+ Content-type:application/rdf+xml
+ Content-Length: 1413
+ Expect: 100-continue
+ 
- HTTP/1.1 100 Continue
- HTTP/1.1 200 OK
- Server: Apache-Coyote/1.1
- Date: Sat, 26 Dec 2009 14:02:51 GMT
- Location: http://ambit.uni-plovdiv.bg:8080/ambit2/feature/13174
- Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
- Accept-Ranges: bytes
- Server: Noelios-Restlet/2.0m3
- Content-Type: text/html;charset=ISO-8859-1
- Content-Length: 53
- 
* Connection #0 to host ambit.uni-plovdiv.bg left intact
* Closing connection #0
http://ambit.uni-plovdiv.bg:8080/ambit2/feature/13174



Best wishes,
Pantelis
 

On Fri, 2009-12-25 at 14:51 +0200, Nina Jeliazkova wrote:

> Hi Pantelis,
> 
> Your RDF is fine, and in fact the feature is created successfully (and
> was also accessible under
> http://ambit.uni-plovdiv.bg:8080/ambit2/feature/13149 ). 
> 
> The problem turns out to be a Tomcat 6 peculiarity when handling
> URLs , containing encoded slashes, like the one below
> 
> 
>         http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%
>         2Fother.com%2Ffeature%2F200Default 
> 
> 
> Restlet handles these kind of URLs fine, junit tests for this also run
> fine , but once the code is deployed under tomcat, it fails to
> retrieve the feature under URL above and instead returns "HTTP/1.x 400
> Invalid URI: noSlash". The Tomcat 6 behaviour for handling URLs with
> encoded slashes is controlled via a Java system property , as
> described in [1] and [2]. 
>       * org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH: true|
>         false 
> Setting the property to "true" fixes the issue you've encountered, but
> is considered a security threat (under specific settings).   (The
> security threat could also be valid for other servers as well, not
> only for Tomcat).
> 
> To summarize, now we have set the above setting to true and the
> problem should be resolved. But in general we should avoid including
> encoded slashes in URLs (I will be changing the code sending feature
> URLs upon creation).  
> 
> On another note, avoiding slashes in URIs makes impossible using
> InChIs  as compound ID as in e.g. /compound/InChI%3D1%2FCH2O%2Fc1-2%
> 2Fh1H2 , so it would be better if specified as query parameters, e.g.
> http://ambit.uni-plovdiv.bg:8080/ambit2/compound/?search=InChI%3D1%
> 2FCH2O%2Fc1-2%2Fh1H2
> 
> [1]
> http://old.nabble.com/HTTP-1.x-400-Invalid-URI:-noSlash-td15005787.html 
> [2] http://tomcat.apache.org/security-6.html
> 
> Best regards,
> Nina
> 
> chung wrote: 
> 
> > Hi Nina,
> >  According to the API, one can post an rdf representation of a feature
> > to a feature service to have a new Feature created. So I made an
> > experiment using the following curl command:
> > 
> > curl -X POST -H 'Content-type:application/rdf+xml' --data-binary
> > @/path/to/feature.rdf http://ambit.uni-plovdiv.bg:8080/ambit2/feature
> > 
> > The content of feature RDF is:
> > 
> > <rdf:RDF
> >     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> >     xmlns:ot="http://www.opentox.org/api/1.1#"
> >     xmlns:owl="http://www.w3.org/2002/07/owl#"
> >     xmlns:dc="http://purl.org/dc/elements/1.1/"
> >     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
> >     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > 
> >   <rdf:Description rdf:about="http://purl.org/dc/elements/1.1/creator">
> >     <rdf:type
> > rdf:resource="http://www.w3.org/2002/07/owl#AnnotationProperty"/>
> >   </rdf:Description>
> >   <rdf:Description rdf:nodeID="A0">
> >     <owl:sameAs rdf:resource="http://other.com/feature/200"/>
> >     <dc:creator
> > rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://opentox.ntua.gr</dc:creator>
> >     <rdf:type rdf:resource="http://www.opentox.org/api/1.1#Feature"/>
> >   </rdf:Description>
> >   <rdf:Description rdf:about="http://other.com/feature/200">
> >     <rdf:type rdf:resource="http://www.opentox.org/api/1.1#Feature"/>
> >   </rdf:Description>
> >   <rdf:Description rdf:about="http://www.opentox.org/api/1.1#Feature">
> >     <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
> >   </rdf:Description>
> > </rdf:RDF>
> > 
> > This RDF was generated using the following code:
> > 
> > 
> > 
> > OntModel featureModel = OT.createModel();
> >         Individual feature =
> > featureModel.createIndividual(featureModel.getOntClass(OT.Class.Dataset.getURI()));
> > 
> > feature.addRDFType(OT.Class.Feature.createProperty(featureModel));
> > 
> > feature.addProperty(featureModel.createAnnotationProperty(DC.creator.getURI()), featureModel.createTypedLiteral("http://opentox.ntua.gr"));
> > 
> > feature.setSameAs(featureModel.createResource("http://other.com/feature/200", OT.Class.Feature.getResource()));
> >         OT.Class.Feature.createOntClass(featureModel);
> > 
> > *** The operation is successful (the server responds with a status code
> > 200-OK), a URI is returned for the generated feature which is
> > http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%2Fother.com%
> > 2Ffeature%2F200Default , but the result of the following request: 
> > 
> > curl -v -H 'Accept:application/rdf+xml'
> > http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%2Fother.com%
> > 2Ffeature%2F200Default 
> > 
> > returns an empty representation and a status code 400 - Bad Request. 
> > 
> > 
> > 
> > Is there a problem with the RDF I posted? Could you provide an example
> > of how can one create a new Feature?
> >   
> 
> 
> 
> > Best Regards,
> > Pantelis
> >   
> 
> 


-------------- next part --------------

   <

   [1]Home [2]Login

   [3]FastTox [4]TTC [5]Depiction [6]Datasets [7]Chemical compounds [8]Si
   milarity [9]Substructure [10]Algorithms [11]References [12]Features [1
   3]Templates [14]Models [15]Ontology [16]RDF playground [17]Help

                                                            [18]AMBIT
   ______________________________________________________________________
   Search
   This site and AMBIT REST services are under development!
     _________________________________________________________________

   Nothing to write! http://ambit.uni-plovdiv.bg:8080/ambit2

   [19][logocefic.png]  [20] [logolri.png]  [21] [logo.png] 
   Developed by Ideaconsult Ltd. (2005-2009) [22]Valid HTML 4.01
   Transitional   [23]Valid CSS 

References

   1. http://ambit.uni-plovdiv.bg:8080/ambit2
   2. http://ambit.uni-plovdiv.bg:8080/ambit2/user/login
   3. http://ambit.uni-plovdiv.bg:8080/ambit2/fasttox?text=50-00-0&search=C%3DO
   4. http://ambit.uni-plovdiv.bg:8080/ambit2/ttc?text=50-00-0&search=C%3DO
   5. http://ambit.uni-plovdiv.bg:8080/ambit2/depict?search=c1ccccc1
   6. http://ambit.uni-plovdiv.bg:8080/ambit2/dataset
   7. http://ambit.uni-plovdiv.bg:8080/ambit2/compound
   8. http://ambit.uni-plovdiv.bg:8080/ambit2/query/similarity?search=c1ccccc1Oc2ccccc2&threshold=0.9
   9. http://ambit.uni-plovdiv.bg:8080/ambit2/query/smarts?text=""
  10. http://ambit.uni-plovdiv.bg:8080/ambit2/algorithm
  11. http://ambit.uni-plovdiv.bg:8080/ambit2/reference
  12. http://ambit.uni-plovdiv.bg:8080/ambit2/feature
  13. http://ambit.uni-plovdiv.bg:8080/ambit2/template/Taxonomy
  14. http://ambit.uni-plovdiv.bg:8080/ambit2/model
  15. http://ambit.uni-plovdiv.bg:8080/ambit2/ontology
  16. http://ambit.uni-plovdiv.bg:8080/ambit2/ontology/test
  17. http://ambit.uni-plovdiv.bg:8080/ambit2/help
  18. http://ambit.sourceforge.net/intro.html
  19. http://www.cefic.be/
  20. http://www.cefic-lri.org/
  21. http://www.opentox.org/
  22. http://validator.w3.org/check?uri=referer
  23. http://jigsaw.w3.org/css-validator/check/referer


More information about the Development mailing list