Re: svn commit: r1534404 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1534404 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java

Adrian Crum-3
The problem is you are trying to cast a javax.servlet.ServletContext to
a javax.servlet.http.HttpServletRequest. Try changing the cast to
(ServletContext).

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 10/21/2013 3:48 PM, [hidden email] wrote:

> Author: jleroux
> Date: Mon Oct 21 22:48:29 2013
> New Revision: 1534404
>
> URL: http://svn.apache.org/r1534404
> Log:
> No functional change, fixes this message in Eclipse "The method getContextPath() is undefined for the type ServletContext" which does not prevent to compile though. Compiled with Oracle JVM 1.6.0.45"
> As reported by Adrian in dev ML this commit breaks the embedded Catalina startup.
>
>   java.lang.ClassCastException: org.apache.catalina.core.ApplicationContextFacade cannot be cast to javax.servlet.http.HttpServletRequest
>
> Before Oracle JVM 1.6.0.45 you could not even compile, interesting... I wonder what will happen when we will jump in Java 8, which we will need to do a day or another anyway...
>
> Modified:
>      ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
>
> Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=1534404&r1=1534403&r2=1534404&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original)
> +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Mon Oct 21 22:48:29 2013
> @@ -70,7 +70,7 @@ public class ControlServlet extends Http
>       @Override
>       public void init(ServletConfig config) throws ServletException {
>           super.init(config);
> -        if (Debug.infoOn()) Debug.logInfo("LOADING WEBAPP [" + ((HttpServletRequest) config.getServletContext()).getContextPath().substring(1) + "] " + config.getServletContext().getServletContextName() + ", located at " + config.getServletContext().getRealPath("/"), module);
> +        if (Debug.infoOn()) Debug.logInfo("LOADING WEBAPP [" + config.getServletContext().getContextPath().substring(1) + "] " + config.getServletContext().getServletContextName() + ", located at " + config.getServletContext().getRealPath("/"), module);
>
>           // configure custom BSF engines
>           configureBsf();
>
>
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1534404 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.j ava

Jacques Le Roux
Administrator
Yes actually it works without.

It's just Eclipse which keeps telling me I should use HttpServletRequest and says "The method getContextPath() is undefined for the type ServletContext" despite https://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#getContextPath%28%29

I tried to put a @SuppressWarnings("cast") which is also supported by Eclipse http://stackoverflow.com/questions/1205995/what-is-the-list-of-valid-suppresswarnings-warning-names-in-java
But no ways, I gave up and just put a comment there at r1534591

Jacques

Adrian Crum wrote:

> The problem is you are trying to cast a javax.servlet.ServletContext to
> a javax.servlet.http.HttpServletRequest. Try changing the cast to
> (ServletContext).
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
> On 10/21/2013 3:48 PM, [hidden email] wrote:
>> Author: jleroux
>> Date: Mon Oct 21 22:48:29 2013
>> New Revision: 1534404
>>
>> URL: http://svn.apache.org/r1534404
>> Log:
>> No functional change, fixes this message in Eclipse "The method getContextPath() is undefined for the type ServletContext" which
>> does not prevent to compile though. Compiled with Oracle JVM 1.6.0.45"
>> As reported by Adrian in dev ML this commit breaks the embedded Catalina startup.
>>
>>   java.lang.ClassCastException: org.apache.catalina.core.ApplicationContextFacade cannot be cast to
>> javax.servlet.http.HttpServletRequest
>>
>> Before Oracle JVM 1.6.0.45 you could not even compile, interesting... I wonder what will happen when we will jump in Java 8,
>> which we will need to do a day or another anyway...
>>
>> Modified:
>>      ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
>>
>> Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=1534404&r1=1534403&r2=1534404&view=diff
>> ============================================================================== ---
>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original) +++
>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Mon Oct 21 22:48:29 2013 @@ -70,7 +70,7 @@ public
>>       class ControlServlet extends Http @Override
>>       public void init(ServletConfig config) throws ServletException {
>>           super.init(config);
>> -        if (Debug.infoOn()) Debug.logInfo("LOADING WEBAPP [" + ((HttpServletRequest)
>> config.getServletContext()).getContextPath().substring(1) + "] " + config.getServletContext().getServletContextName() + ",
>> located at " + config.getServletContext().getRealPath("/"), module); +        if (Debug.infoOn()) Debug.logInfo("LOADING WEBAPP
>> [" + config.getServletContext().getContextPath().substring(1) + "] " + config.getServletContext().getServletContextName() + ",
>> located at " + config.getServletContext().getRealPath("/"), module);  
>>
>>           // configure custom BSF engines
>>           configureBsf();