Results 1 to 5 of 5

Thread: Problem deploying Spring 3 app to Oracle Application Server - ClassCastException

  1. #1

    Default Problem deploying Spring 3 app to Oracle Application Server - ClassCastException

    Has anyone succeeded in running a Spring 3.x webapp under pre-Weblogic Oracle Application Server or OC4J? Unfortunately our customer is using pre-Weblogic Oracle Application Server, so we have to test our Spring app on a similar setup. We are testing under OC4J 10.1.3.5.

    Here is an excerpt of the stack trace we get upon any attempt to access the database. We do not get this error or other DB issues when running the same Spring app under Tomcat 6.x.
    Code:
    java.lang.ClassCastException: com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.FileRequestDispatcher
    	at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.EvermindHttpServletRequest.getAttribute(EvermindHttpServletRequest.java:3308)
    	at javax.servlet.ServletRequestWrapper.getAttribute(ServletRequestWrapper.java:127)
    	at javax.servlet.ServletRequestWrapper.getAttribute(ServletRequestWrapper.java:127)
    	at org.springframework.web.util.WebUtils.exposeRequestAttributeIfNotPresent(WebUtils.java:437)
    	at org.springframework.web.util.WebUtils.exposeForwardRequestAttributes(WebUtils.java:398)
    	at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:115)
    	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    This is the current Oracle datasource configuration in applicationContext.xml:

    Code:
    <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
       		<property name="connectionCachingEnabled" value="true" />
       		<property name="URL" value="${database.url}"/>
            <property name="user" value="${database.username}"/>
            <property name="password" value="${database.password}"/>
       		<property name="connectionCacheProperties">
          		<props merge="default">
             		<prop key="MinLimit">3</prop>
             		<prop key="MaxLimit">20</prop>
          		</props>
       		</property>
    	</bean>

  2. #2

    Default

    The exception stack trace is generated when the server tries to compile the Spring 3.x MVC framework/JSPX code from JSPX to HTML. Currently, it compiles the following

    Code:
    <form:form commandName="myDeliveryPackage">
        	<table>
    			<tr>
    				<td>
    						<table>
    							<tr>
    								<td><input type="submit" value="New"/></td>
    								<td> or </td>
    								<td><form:input path="packageNumber" /><input type="submit" value="Enter package number to edit" size="30"/></td>
    							</tr>
    						</table>
    				</td>
    			</tr>
    		</table>	
    	</form:form>
    into the following under OC4J:

    Code:
    <form id="myDeliveryPackage" action="/IDS/WEB-INF/layouts/ids-default.jspx?form=t" method="post"><table><tr><td><table><tr><td><input type="submit" value="New"/></td><td> or </td><td><input id="packageNumber" name="packageNumber" type="text" value=""/><input type="submit" value="Enter package number to edit" size="30"/></td></tr></table></td></tr></table></form>
    Under Tomcat 6.0, the Spring/JSPX code compiles into this, which is correct:

    Code:
    <form id="incidentPackage" action="/IDS/myDeliveryPackages?form=t" method="post"><table><tr><td><table><tr><td><input value="New" type="submit"/></td><td> or </td><td><input id="packageNumber" name="packageNumber" type="text" value=""/><input size="30" value="Enter package number to edit" type="submit"/></td></tr></table></td></tr></table></form>
    I am at a loss as to why this is happening. I just know that the exception has something to do with the inability to find a certain attribute to generate the correct action URL.

  3. #3

    Default

    bump for today

  4. #4

    Default

    I forgot to include some config files:

    webmvc-config.xml
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    				
    	<!-- The controllers are autodetected POJOs labeled with the @Controller annotation. -->
    	<context:component-scan base-package="gov.epa.prism.ids" use-default-filters="false">
    		<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
    	</context:component-scan>
    	
    	<!-- Turns on support for mapping requests to Spring MVC @Controller methods
    	     Also registers default Formatters and Validators for use across all @Controllers -->
    	<mvc:annotation-driven/>
    	
    	<!-- selects a static view for rendering without the need for an explicit controller -->
    	<mvc:view-controller path="/login"/>
        <mvc:view-controller path="/index"/>
    	<mvc:view-controller path="/uncaughtException"/>
    	<mvc:view-controller path="/resourceNotFound"/>
    	<mvc:view-controller path="/dataAccessFailure"/>
    
    	<!-- Resolves localized messages*.properties and application.properties files in the application to	allow for internationalization. 
    		The messages*.properties files translate Roo generated messages which are part of the admin interface, the application.properties
    		resource bundle localizes all application specific messages such as entity names and menu items. -->
    	<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false"/>
    
    	<!-- This bean resolves specific types of exceptions to corresponding logical - view names for error views. 
    	     The default behaviour of DispatcherServlet - is to propagate all exceptions to the servlet container: 
    	     this will happen - here with all other types of exceptions. -->
    	<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:defaultErrorView="uncaughtException">
    		<property name="exceptionMappings">
    			<props>
    				<prop key=".DataAccessException">dataAccessFailure</prop>
    				<prop key=".NoSuchRequestHandlingMethodException">resourceNotFound</prop>
    				<prop key=".TypeMismatchException">resourceNotFound</prop>
    				<prop key=".MissingServletRequestParameterException">resourceNotFound</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<!-- allows for integration of file upload functionality -->
    	<bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" id="multipartResolver"/>
    	
    	<bean class="org.springframework.js.ajax.AjaxUrlBasedViewResolver" id="tilesViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
        </bean>
        
        <bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" id="tilesConfigurer">
            <property name="definitions">
                <list>
                    <value>/WEB-INF/layouts/layouts.xml</value>
                    <!-- Scan views directory for Tiles configurations -->
                    <value>/WEB-INF/views/**/views.xml</value>
                </list>
            </property>
        </bean>
        
    </beans>
    Bolded line above is the one not being converted by Oracle Application Server to the proper URL under WEB-INF/views.

    Here is the web.xml:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
        
        <display-name>IDS</display-name>
        
        
        <!-- Enable escaping of form submission contents -->
        <context-param>
            <param-name>defaultHtmlEscape</param-name>
            <param-value>true</param-value>
        </context-param>
        
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
        </context-param>
        
        
        
        <filter>
            <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
            <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
        </filter>
        
        <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>
        
        <filter>
            <filter-name>CharacterEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
            <init-param>
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
        
        <filter>
            <filter-name>HttpMethodFilter</filter-name>
            <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
        </filter>
        
        <filter>
            <filter-name>AppUrlRewriteFilter</filter-name>
            <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
            <init-param>
                <param-name>logLevel</param-name>
                <param-value>log4j</param-value>
            </init-param>
    		<init-param>
                <param-name>confPath</param-name>
                <param-value>/WEB-INF/app-urlrewrite.xml</param-value>
            </init-param>        
        </filter>
    
        <filter>
            <filter-name>StaticUrlRewriteFilter</filter-name>
            <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
            <init-param>
                <param-name>logLevel</param-name>
                <param-value>log4j</param-value>
            </init-param>
    		<init-param>
                <param-name>confPath</param-name>
                <param-value>/WEB-INF/static-urlrewrite.xml</param-value>
            </init-param>        
        </filter>
        
        <filter-mapping>
            <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <filter-mapping>
            <filter-name>CharacterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <filter-mapping>
            <filter-name>HttpMethodFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>    
        
        <filter-mapping>
            <filter-name>StaticUrlRewriteFilter</filter-name>
            <url-pattern>/static/*</url-pattern>
        </filter-mapping>
    
        <filter-mapping>
            <filter-name>AppUrlRewriteFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        
        <!-- Creates the Spring Container shared by all Servlets and Filters -->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        
        
        
        <!-- Handles Spring requests -->
        <servlet>
            <servlet-name>IDS</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/spring/webmvc-config.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        
        <servlet>
            <servlet-name>Resource Servlet</servlet-name>
            <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
            <load-on-startup>0</load-on-startup>
        </servlet>
        
        <servlet-mapping>
            <servlet-name>Resource Servlet</servlet-name>
            <url-pattern>/resources/*</url-pattern>
        </servlet-mapping>
        
        <servlet-mapping>
            <servlet-name>IDS</servlet-name>
            <url-pattern>/app/*</url-pattern>
        </servlet-mapping>
        
        <session-config>
            <session-timeout>60</session-timeout>
        </session-config>
        
        <welcome-file-list>
            <welcome-file>index.html</welcome-file>
        </welcome-file-list>
        
        <error-page>
            <exception-type>java.lang.Exception</exception-type>
            <location>/app/uncaughtException</location>
        </error-page>
        
        <error-page>
            <error-code>404</error-code>
            <location>/app/resourceNotFound</location>
        </error-page>
    </web-app>

  5. #5

    Default

    The customer is now insisting that this issue be resolved, even though the overall operation of the web application is not affected by these ClassCastExceptions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •