cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot invoke share webscript externally, HTTP status 500

andym
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to call a webscript within the Share tier from an external source.
If I call the script from a browser (i.e http://localhost:8080/share/service/components/dashlets/my-create-projects)
the script works fine, however if I try to call it from curl or a java program I get HTTP 500 status.

Here are the details :

All files are stored in:

Alfresco/tomcat/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/dashlets


my-create-projects.get.desc.xml

<webscript>
   <shortname>My Projects</shortname>
   <description>Component used to list projects</description>
   <url>/components/dashlets/my-create-projects</url>
</webscript>
my-create-projects.get.html.ftl

<h1>CALLED</h1>
${requestcontent}
<#list headers?keys as header>
[${header}=${headers[header]}]
<p>
</#list>

my-create-projects.get.js

function main()
{
   logger.log("Called my-create-project.get.js");
   //Dump the headers
   for each (header in headers){
     logger.log(header);}
     model.requestcontent = requestbody.content;     
}
main();

When I call the script from firefox or safari or from the script index page I get the correct response, i.e:

[size=150]CALLED[/size]
[accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]
[accept-charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7]
[accept-encoding=gzip,deflate]
[accept-language=en-us,en;q=0.5]
[cache-control=max-age=0]
[connection=keep-alive]
[cookie=alfLogin=1273725679; alfUsername2="bWFubmluZ2E="; JSESSIONID=313460B69DE66D9D323F3F57E84D69FB]
[host=localhost:8080]
[keep-alive=115]
[user-agent=Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2]

If I call the script from "REST client for firefox" I get the following error:

<html><head><title>Apache Tomcat/6.0.18 - Error report</title><style><!–H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}–></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
</pre></p><p><b>root cause</b> <pre>java.lang.NullPointerException
   org.apache.catalina.util.CharsetMapper.getCharset(CharsetMapper.java:106)
   org.apache.catalina.connector.Response.setLocale(Response.java:829)
   org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:323)
   org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1035)
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.18</h3></body></html>
If I call the script using CURL I same error get the error:

AM-MacBook:Alfresco manninga$ curl "http://localhost:8080/share/page/components/dashlets/my-create-projects"
<html><head><title>Apache Tomcat/6.0.18 - Error report</title><style><!–H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}–></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
</pre></p><p><b>root cause</b> <pre>java.lang.NullPointerException
   org.apache.catalina.util.CharsetMapper.getCharset(CharsetMapper.java:106)
   org.apache.catalina.connector.Response.setLocale(Response.java:829)
   org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:323)
   org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1035)
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.18</h3></body></html>
I've build a java client using Jersey and HttpClient and both return the same status. Could it be that the browser (firefox and safari) adds "something" to the header that curl and the other clients are not?

If it helps I'm using CE 3.3 on a Macbook, installed from the Alfresco Stack for OS X.

I've tried appending headers in RESTClient and Jersey but still have no joy.

Please help, I've spent 2 days trying to figure it out!!

AndyM
3 REPLIES 3

andym
Champ in-the-making
Champ in-the-making
Thanks to Mike Hatfield for solving this!

Mike Hatfield commented on ALF-2808:
————————————
It's a "feature" of Spring 3 - make sure you pass accept-charset and accept-language when using curl.
–header "Accept-Charset:ISO-8859-1,utf-8" –header "Accept-Language:en"

sandhya25186
Champ in-the-making
Champ in-the-making
Ive added the header in my java program still i am not able to run my share webscript


String url = "http://localhost:8080/share/page/modules/custom-site?sitePreset=site-dashboard&shortName=test17";
HttpGet httpGet = new HttpGet(url);
         httpGet.setHeader("Accept-Charset","utf-8");
         httpGet.setHeader("Accept-Language","en");
         HttpResponse response = httpClient.execute(httpGet);

which gives the error :-
<html><head><title>Apache Tomcat/6.0.26 - Error report</title><style><!–H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}–></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:67)
</pre></p><p><b>root cause</b> <pre>java.lang.NullPointerException
   org.apache.catalina.util.CharsetMapper.getCharset(CharsetMapper.java:106)
   org.apache.catalina.connector.Response.setLocale(Response.java:851)
   org.apache.catalina.connector.ResponseFacade.setLocale(ResponseFacade.java:323)
   org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1035)
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:67)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.26</h3></body></html>

What else to do…some body help Smiley Sad

cszamudio
Champ on-the-rise
Champ on-the-rise
Hi,
Just in case anyone discovers this thread in relation to the failure of accessing RSS feeds in 3.3g from an application, the suggestions described above for setting the properties in an HttpURLConnection:

urlConnection.setRequestProperty("Accept-Charset","utf-8");
urlConnection.setRequestProperty("Accept-Language","en");

did the trick for me.  I spent a good amount of time trying to track this down in my code until I realized the Tomcat log would give me the clue. (-:

Carlos