XPM returns 404 when updating, oData.svc does not seem available - tridion

I've been configuring XPM (Tridion 2012 UI Update) on a JSP development site. It's an all-in-one package, with Content Manager, Databases and Staging on the same server for development purposes.
I've made the following configurations:
Defined Staging Web App (called JSPStaging and set to a host header of jspstaging.project.dev), which receives content and places this content in its own folder from the HTTPUpload Web App, which is defined in the Publication Target in the CME
I've added the Java Session Preview Webservice (called cd_preview_webservice)
Currently my sites are being run by Tomcat 7, and IIS 7.5 is used for routing requests to port 8080 (Tomcat) which handles jspstaging.project.dev.
I know this is hardly an ideal situation, but I have to make do.
The problem at hand:
I've currently successfully implemented XPM (or at least, the dashboard, the ability to edit components and save those)
However, as soon as you want to update the page, it sometimes refreshes and it sometimes returns an error:
The remote server returned an error: (404) Not Found.
This is an (orange) Tridion Message. I'm not entirely sure the 404 error described above is the same as the one documented on the SDL Live Content.
This is the error in the Event Viewer on the server:
Unable to update the changes using OData Service. The remote server returned an error: (404) Not Found. Component: Tridion.SiteEdit.FastTrackPublishing Errorcode: 1003 User: NT AUTHORITY\NETWORK SERVICE
As such, I'm following this downright amazing blogpost Albert Romkes wrote, and at point 2 in his article he mentions navigating to odata.svc. I cannot seem to find the file anywhere on my staging or session preview web apps. I've installed .NET applications of Tridion before, and while the .NET app on the installation media (among other files) has an acces_token and a odata.svc file, I noticed that the JAVA install of the webservice of session preview does not have these files. However, later in the install guide you need those files to set up publishing.
When I follow the JSP site part and fill in the fields on the Session Preview Tab of the Publication Target, I cannot navigate to this odata url on the server itself, which is now
http://localhost:8080/cd_preview_webservice/cdws/odata.svc/
The Tridion Logging does not say something is wrong, for staging AND for session preview web app, as well as the Tomcat logs. They even say OData is working just fine, as far as I can tell...
If I cannot navigate to the url posted above, does this mean something is wrong, or that the 404 error is because of that?
EDIT
my web.xml of staging:
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
Content Delivery Web service
<jsp-config>
<taglib>
<taglib-uri>cd_tags</taglib-uri>
<taglib-location>/WEB-INF/lib/cd_tags.tld</taglib-location>
</taglib>
</jsp-config>
<listener>
<listener-class>
com.tridion.storage.persistence.session.SessionManagementContextListener
</listener-class>
</listener>
<!--
OData and linking Web service
-->
<servlet>
<servlet-name>Content Delivery Web service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.classnames</param-name>
<param-value>com.tridion.webservices.odata.ODataWebservice;com.tridion.webservices.linking.LinkingService;com.tridion.webservices.odata.JAXBContextResolver</param-value>
</init-param>
</servlet>
<filter>
<filter-name>Ambient Data Framework</filter-name>
<filter-class>com.tridion.ambientdata.web.AmbientDataServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Ambient Data Framework</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>Content Delivery Web service</servlet-name>
<url-pattern>/cdws/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Page Content Filter</filter-name>
<filter-class>com.tridion.preview.web.PageContentFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Page Content Filter</filter-name>
<url-pattern>/cdws/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.tridion.webservices.odata.ODataContextListener</listener-class>
</listener>
<filter>
<filter-name>Binary Content Filter</filter-name>
<filter-class>com.tridion.preview.web.BinaryContentFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Binary Content Filter</filter-name>
<url-pattern>/Images/*</url-pattern>
</filter-mapping>

You mentioned that you've added the cd_preview_webservice, however, the error message dictates that it's not working. On the Java side, you won't see the odata.svc file as this url is handled by one of the classes within the jars, so don't worry about that.
In your Tomcat console, does it show that the app has been deployed/started without error?
Also the URL that you mention "/cd_preview_webservice/cdws/odata.svc/" has a "/cdws/" in it. This seems a bit irregular. Typically the url is "/cd_preview_webservice/odata.svc". What is does your web.xml look like?

Related

Spring MVC 4 File Upload Failing Silently

I'm using Spring MVC (Version 4.1) on Tomcat 8, and am desperately trying to make the file upload functionality work. Currently, I have a controller configured like this:
#RequestMapping(value={"/TestCase/Upload"}, method=RequestMethod.POST)
#ResponseBody
public ResponseEntity<String> uploadFile(HttpServletRequest request,
#RequestParam("file") MultipartFile file) {
System.out.println("Hit this location.");
return new ResponseEntity("Success");
}
My web.xml has the appropriate server configuration:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
<!-- Configuration for file upload (configuring Multipart file) -->
<multipart-config>
<location>/tmp</location>
<max-file-size>500000</max-file-size>
<max-request-size>505000</max-request-size>
<file-size-threshold>10485</file-size-threshold>
</multipart-config>
</servlet>
And finally, my Spring xml configuration file has the necessary resolver specified:
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="500000" />
</bean>
The Apache commons-fileupload JAR is on the classpath.
I have used this approach successfully in the past on non-Tomcat servers, but now the application isn't working - but it's failing quietly. The response has a status code of 200, but nothing inside of the file upload controller method is executed. There are no exceptions thrown in the server logs, and the only way I can get the controller method to print anything out is if I remove the "Multipart" parameter entirely. At first I thought that the controller method wasn't being hit at all, but if I change the URL mapping, then the calling code throws a 404 - so it is definitely hitting the correct mapping/method - it's just that nothing inside of the method is executing (with no exceptions thrown!)
What am I doing wrong?
It turns out Spring MVC will hide noClassDef's from the console when booting itself up. The issue was that apache-commons-io.jar was missing on the classpath. Including that JAR caused everything to work properly.
So in the future if Spring is quietly misbehaving - check to ensure all necessary libraries are explicitly included, because it certainly won't tell you!

Skipping view files/pages without going through Dispatcher Servlet?

I am using Spring MVC framework for writing a web application. The first step is to modify the web.xml to make entry for the dispatcher servlet.
The snippet of the web.xml which has this change:
<servlet>
<servlet-name>MediumScaleProject</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<servlet-mapping>
<servlet-name>MediumScaleProject</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
I have following questions:
1) Does this mean anything with respect to context root has to go through this servlet mapping? (assume context root for this web application is /contextroot)
2) I want to capture user details in userDetails.html; with the above arrangement it is not working, that is if I access like this: /contextroot/userDetails.html; it is giving HTTP 404 error. What is the best strategy for handling these kind of scenarios?
If you want to make a project with the use of Spring MVC framework, you will need the Model, View and Controller.
yes everything will pass through
you better start to implement the MVC-idea

deploying felix webconsole in spring mvc over felix http bridge

I've Spring MVC webapplication which starts osgi container using ServletContextListener (osgi http bridge). I am trying to deploy felix webconsole along with other bundles, bundle gets started, but I am not able to access it.
In my web.xml
Spring DispatherServlet is configured for URL '/'
Felix ProxyServlet is configured for URL '/ext/*'
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>extension</servlet-name>
<url-pattern>/ext/*</url-pattern>
</servlet-mapping>
I tried to access webconsole using "http://localhost:8080/my-app/ext/system/console" (results 503) and "http://localhost:8080/my-app/system/console" (results 404) with no luck.
Upon debugging I see that for 'ext/system/console' URL, org.apache.felix.http.proxy.DispatcherTracker.DispatcherTracker#getDispatcher() method call in ProxyServlet#service() method returns NULL.
Can anybody point me, what I am missing here ?

tomcat 6 webapp deployment

I wrote a little servlet that I need to deploy with tomcat. My server is tomcat 6. I first tried just dragging the war file and it unpacked, put I can't access the url (404 error). Then I even deleted the deploy and tried using the tomcat manager. When I click deploy is says 'OK' but doesn't show up in the list of applications deployed.
I used Eclipse (ganymede) to create the war file. The unpacked directory structure looks good. I am running on localhost:8080. Here is my web.xml. Perhaps there is something wrong here?
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>Auth</servlet-name>
<servlet-class>serv.Authenticate</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Auth</servlet-name>
<url-pattern>/authenticate</url-pattern>
</servlet-mapping>
</web-app>
I've read that maybe I need to do something to server.xml. But I looked around in there and there are no entries for any of tomcat's default web apps. How do I register my app so that tomcat serves it up like the others?
The web.xml look good but it is impossible to know why you are getting a 404 without knowing more about your environment.
The problem might be that the servlet is not loaded or if it is being loaded, that the servlet cannot find the URL.
To see if your servlet is being loaded add a log statement (System.out will do) to the init method of the servlet. Add the following line to your servlet element as well so that the servlet will not load on demand but at startup:
<load-on-startup>0</load-on-startup>
Then you can check that the servlet is being recognized and loaded.
Then add a log statement to the doGet/doPost etc methods to output the .getPathInfo of the request object. It might help to add a wildcard to the servlet mapping as well just to test:
<url-pattern>/authenticate/*</url-pattern>

Setup a Filter that will set the Response Header to only Image File(s)

I am having a caching problem based on the discussion that I have in this link
But I am not sure how to go about with the suggestion on setting the response headers on my Spring MVC.
Does anybody know how to setup a some sort of a filter that will add add a response header only on image files?
I currently am not an expert on J2EE web development with SPring MVC.
Any idea?
Spring comes with a Resources Servlet.
<!-- Serves static resource content from .jar files such as blartoch.jar -->
<servlet>
<servlet-name>Resources Servlet</servlet-name>
<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
<load-on-startup>50</load-on-startup>
</servlet>
<!-- Map all /resources requests to the Resource Servlet for handling -->
<servlet-mapping>
<servlet-name>Resources Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
We are using an ear file and all of my resources are in a jar in the ear. If you are only deploying a WAR file (perhaps to tomcat), then try putting your resources in a jar and putting the jar in your WAR file's /WEB-INF/lib directory.
If you store your resources (inside the jar) in the following directory:
/META-INF/common/images
requests for your resources will look something like this:
<img src="<c:url value="/resources/common/images/cuteKitten.jpg"/>"/>

Resources