-
I guess the problem is that you try to return a json. Spring is converting every response of a @ExtDirectMethod method into json. In this case Spring is converting your json into json. Don't know what the result is of such a conversion. How is the response looks like in Firebug?
To prevent the conversion into json you could try and return an instance of ExtDirectRawJsonStoreResponse. Or create your own class based on ExtDirectRawJsonStoreResponse.
-
1 Attachment(s)
I am not sure what you meant. I am trying to follow the demo class 'ch.ralscha.extdirectspring.demo.simpleapp.UserService' and made the following changes in my files. But I still get that error in the Firefox (406 error)
- I changed my java file as follows
Code:
...
import ch.ralscha.extdirectspring.annotation.ExtDirectMethod;
import ch.ralscha.extdirectspring.annotation.ExtDirectMethodType;
import ch.ralscha.extdirectspring.bean.ExtDirectStoreResponse;
public class ExtjsExamplesController
{
private static int counter = 0;
public static class Task
{
public String task;
public String user;
public String duration;
}
@ExtDirectMethod(value = ExtDirectMethodType.STORE_READ, group = "treeStreams")
public ExtDirectStoreResponse<Task> getTreeStreams1(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
//do something here
// return new ArrayList<Task>();
//return extjsRequest(request, response);
List<Task> list = new ArrayList<Task>();
Task t = new Task();
t.task = "test";
t.user = "jeet";
t.duration = "0.0";
list.add(t);
return new ExtDirectStoreResponse<Task>(list);
}
}
- changed my store as follows:
Code:
Ext.require([
'Ext.data.*',
'Ext.direct.*',
'RS.model.Task' //This is like import and it does not work if this is not there
]);
Ext.define('RS.store.StreamStore', {
extend : 'Ext.data.TreeStore',
model: 'RS.model.Task',//also, this has to be full name as it does not work if you just put Task
//proxy: {
//type: 'ajax',
//url: 'data/treegrid.json' //the store will get the content from the .json file
//url : '/resolve/service/example/wiki/extjs'
//type:'direct',
//directFn : extjsExamplesController.getTreeStreams1
//},
autoLoad : true, //will query the data on stores load, this will only be READONLY, so its a good idea
autoSync : true,//for Ext Direct
folderSort: false
});
- changed my model as follows:
Code:
Ext.define('RS.model.Task', {
extend: 'Ext.data.Model',
fields: [
{name: 'task', type: 'string'},
{name: 'user', type: 'string'},
{name: 'duration', type: 'string'}
],
proxy : {
type: 'direct',
api : {
read : extjsExamplesController.getTreeStreams1
//create : userService.create,
//update : userService.update,
//destroy : userService.destroy
},
reader : {
root : 'records'
}
}
});
Still get the same exception on the Firefox. Here is the image of it.
Attachment 28996
Please advise.
Thanks,
Jeet
-
Very strange error message. Do you have a project I can download and try it on my computer?
-
to create a project will take me a long time as we are using GXT/GWT setup also. I can provide you with the individual files (like web.xml, spring conf, java files, js file, etc) or I can show it to you on skype. My handle is jeetmarwah on skype. It will be great to talk to you.
Please let me know what is your preference.
Thanks,
Jeet
-
I'm especially interested in the WEB-INF/libs directory. What libraries are in there?. Or is this a maven project?
-
1 Attachment(s)
Here is the list of jar files in the WEB-INF/lib folder.
Attachment 28998
Thanks for all your support.
Jeet
-
some more findings.
My base url for tomcat is set to http://localhost:8080/resolve/ and NOT http://localhost:8080/.
I made a change in web.xml file. Here is the complete web.xml file. I think there is some mismatch going on with the response as now I am getting Error 404 Not found.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<!-- LOG4J PROPERTIES -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log.cfg</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- APPLICATION CONTEXT -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/resolve-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- SPRING SERVLET -->
<servlet>
<servlet-name>resolve</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Configure velocity -->
<!-- WE HAVE CONFIGURES IT IN THE RESOLVE-SERVLET.XML file i.e. in SPRING
<servlet>
<servlet-name>velocity</servlet-name>
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
</init-param>
<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
-->
<!-- for testing only -->
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>com.resolve.wiki.TestServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<!--<init-param>-->
<!--<param-name>axis2.xml.path</param-name>-->
<!--<param-value>/WEB-INF/conf/axis2.xml</param-value>-->
<!--<param-name>axis2.xml.url</param-name>-->
<!--<param-value>http://localhost/myrepo/axis2.xml</param-value>-->
<!--<param-name>axis2.repository.path</param-name>-->
<!--<param-value>/WEB-INF</param-value>-->
<!--<param-name>axis2.repository.url</param-name>-->
<!--<param-value>http://localhost/myrepo</param-value>-->
<!--</init-param>-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<!-- end of test servlet -->
<servlet-mapping>
<servlet-name>resolve</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>resolve</servlet-name>
<url-pattern>*.rpc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>resolve</servlet-name>
<url-pattern>/api-debug.js</url-pattern>
</servlet-mapping>
<!-- STATIC CONTENT
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
-->
<!-- FILES -->
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
<!-- SECURITY FILTER -->
<filter>
<filter-name>SecurityFilter</filter-name>
<display-name>Security Filter</display-name>
<description>Security Filter</description>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>/service/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>*.rpc</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<taglib>
<taglib-uri>/WEB-INF/rssutils.tld</taglib-uri>
<taglib-location>/WEB-INF/rssutils.tld</taglib-location>
</taglib>
</web-app>
- changed the index.html as follows:
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title id="page-title">Resolve Social</title>
<link rel="stylesheet" type="text/css" href="../js/extjs4/resources/css/ext-all.css">
<style type="text/css">
</style>
<script type="text/javascript" src="../js/extjs4/ext-debug.js"></script>
<!-- the base url is http://localhost:8080/resolve . So to make it work without the complete url, you have to go back and reach the file-->
<!-- <script src="http://localhost:8080/resolve/extjsspring/api-debug.js"></script> -->
<!-- <script src="/../resolve/extjsspring/api-debug.js"></script> -->
<script src="/../resolve/api-debug.js"></script>
<script type="text/javascript" >
Ext.require([
'Ext.direct.*'
]);
Ext.onReady(function()
{
Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
});
</script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
</body>
</html>
The request reaches the server and the response is NOT interpreted by the client. It throws me this error
Code:
POST http://localhost:8080/resolve/router 404 Not Found
What is this router and how can I make sure that it is conf correctly?
Please advise.
Thanks,
Jeet.
-
The problem is the new mapping for api-debug.js in web.xml. The library tries to find the path to router based on the api-debug.js path. Because api-debug.js is requested with http://localhost:8080/resolve/api-debug.js the router url is
http://localhost:8080/resolve/router
Simple solution is just add another mapping for the router
<servlet-mapping>
<servlet-name>resolve</servlet-name>
<url-pattern>router</servlet-name>
</servlet-mapping>
But my advice would be to delete the mapping for api-debug.js in web.xml and only use the /service/* mapping.
Then change the script src in index.html to
<script src="service/api-debug.js">
Another advice is don't hardcode the Tomcat context path in the application. Imagine what happens if you deploy the war file to another context. There could also be a problem with urls like this ../js/extjs4/ext-debug.js
if you decide to deploy the webapplication to the root context (/)
-
2 Attachment(s)
Thanks for your valuable suggestions.
After the suggested changes, I am getting the Error 406 again. How can I test if the router is working fine (similar to the api-debug.js file)? Note the error indicates something @ headers. also, is it a POST or GET or both?
Here are the things I modified:
- web.xml
Code:
....
<servlet-mapping>
<servlet-name>resolve</servlet-name>
<url-pattern>/api-debug.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>resolve</servlet-name>
<url-pattern>/router</url-pattern>
</servlet-mapping>
....
- index.html
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title id="page-title">Resolve Social</title>
<link rel="stylesheet" type="text/css" href="../js/extjs4/resources/css/ext-all.css">
<style type="text/css">
</style>
<script type="text/javascript" src="../js/extjs4/ext-debug.js"></script>
<!-- the base url is http://localhost:8080/resolve . So to make it work without the complete url, you have to go back and reach the file-->
<!-- <script src="http://localhost:8080/resolve/extjsspring/api-debug.js"></script> -->
<!-- <script src="/../resolve/extjsspring/api-debug.js"></script> -->
<script src="/../resolve/api-debug.js"></script>
<script type="text/javascript" >
Ext.require([
'Ext.direct.*'
]);
Ext.onReady(function()
{
Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
});
</script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
</body>
</html>
- Here is the error that I get.
Attachment 29008
Attachment 29009
Any ideas? Please advise.
Thanks,
Jeet
-
Sorry. I don't have a clue what's wrong. I have to setup a project and try to reproduce the error.
My guess is that there is a jar file or a combination of jar files in your classpath that causes the problem.
Can you put the contents of the web-inf/lib directory on a ftp-server/dropbox/... where I can download it.