Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359388

Summary: [RWT-OSGi Integration]: ServletContext#getRealPath() returns wrong path if deployed in servlet container
Product: [RT] RAP Reporter: Frank Appel <fr.appel>
Component: RWTAssignee: Frank Appel <fr.appel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ans.mail
Version: 1.5   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Frank Appel CLA 2011-09-29 05:50:41 EDT
Use the following snippet in your code:

ServletContext sc = RWT.getRequest().getSession().getServletContext();
System.out.println("<<<>>> RealPath /WEB-INF: " + sc.getRealPath("/WEB-INF")); System.out.println("<<<>>> RealPath /: " + sc.getRealPath("/"));

Deploying a RAP application into a servlet container first using RAP 1.4 then using RAP 1.5:

--> RAP 1.4
<<<>>> RealPath /WEB-INF: ...\tomcat\webapps\test14\WEB-INF
<<<>>> RealPath /:        ...\tomcat\webapps\test14\

--> RAP 1.5 M1
<<<>>> RealPath /WEB-INF: .../tomcat/work/Catalina/localhost/test15/eclipse/workspace/.metadata/.plugins/org.eclipse.rap.ui/context/WEB-INF
<<<>>> RealPath /:        .../tomcat/work/Catalina/localhost/test15/eclipse/workspace/.metadata/.plugins/org.eclipse.rap.ui/context/

RAP 1.5 should provide the same output as RAP 1.4...

(By the way: should we add a new component in Bugzilla for RWT-OSGi integration bugs?)
Comment 1 Frank Appel CLA 2011-09-29 06:22:44 EDT
Resolved in CVS-HEAD.

ServletContextWrapper now uses the underlying getRealPath implementation if this does not return null. This is the case if RAP runs within a servlet container using the servlet bridge. Otherwise the wrapper returns the realpath calculation based on the local storage area of the RWTContext service.

The latter is needed to keep the RWTConfigurationImpl working, which still is a remaining of the old W4Toolkit stuff - also it has been renamed and refactored several times. Maybe we will be able to remove this in the future as providing access to the web application's WEB-INF directories like classes and library IMHO should not be used by RWT. In particular as they do not exist in an OSGi standalone runtime.
Comment 2 RĂ¼diger Herrmann CLA 2011-10-04 06:29:10 EDT
*** Bug 356910 has been marked as a duplicate of this bug. ***