Results 1 to 8 of 8

Thread: Initializing Dispatcher Servlet from web.xml

  1. #1

    Default Initializing Dispatcher Servlet from web.xml

    Hi,

    actually I am new to spring and redesigning a project from struts to spring, and I got the following error while deploying the project using JBOSS,

    and I am interested to use jspx files as views rather than jsp, so I used only viewresolver in dispatche-servlet.xml,

    can any one suggest me how to remove this error and any changes in dispather-servlet.xml file.

    here is the error code:

    [org.springframework.web.servlet.DispatcherServlet] (main) FrameworkServlet 'dispatcher': initialization started
    2010-05-03 14:24:34,125 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/adminSpring]] (main) StandardWrapper.Throwable
    java.lang.IllegalStateException: Context attribute is not of type WebApplicationContext: org.springframework.web.context.support.XmlWebAppl icationContext@123c4a: display name [Root WebApplicationContext]; startup date [Mon May 03 14:24:31 CEST 2010]; root of context hierarchy
    at org.springframework.web.context.support.WebApplica tionContextUtils.getWebApplicationContext(WebAppli cationContextUtils.java:113)
    at org.springframework.web.context.support.WebApplica tionContextUtils.getWebApplicationContext(WebAppli cationContextUtils.java:86)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:314 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:282)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:126)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1048)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:950)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4122)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4421)
    at org.jboss.web.tomcat.service.deployers.TomcatDeplo yment.performDeployInternal(TomcatDeployment.java: 310)
    at org.jboss.web.tomcat.service.deployers.TomcatDeplo yment.performDeploy(TomcatDeployment.java:142)
    at org.jboss.web.deployers.AbstractWarDeployment.star t(AbstractWarDeployment.java:461)
    at org.jboss.web.deployers.WebModule.startModule(WebM odule.java:118)
    at org.jboss.web.deployers.WebModule.start(WebModule. java:97)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invok e(ReflectedDispatcher.java:157)
    at org.jboss.mx.server.Invocation.dispatch(Invocation .java:96)
    at org.jboss.mx.server.Invocation.invoke(Invocation.j ava:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(Ab stractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanSe rverImpl.java:668)
    at org.jboss.system.microcontainer.ServiceProxy.invok e(ServiceProxy.java:206)
    at $Proxy38.start(Unknown Source)
    at org.jboss.system.microcontainer.StartStopLifecycle Action.installAction(StartStopLifecycleAction.java :42)
    at org.jboss.system.microcontainer.StartStopLifecycle Action.installAction(StartStopLifecycleAction.java :37)
    at org.jboss.dependency.plugins.action.SimpleControll erContextAction.simpleInstallAction(SimpleControll erContextAction.java:62)
    at org.jboss.dependency.plugins.action.AccessControll erContextAction.install(AccessControllerContextAct ion.java:71)
    at org.jboss.dependency.plugins.AbstractControllerCon textActions.install(AbstractControllerContextActio ns.java:51)
    at org.jboss.dependency.plugins.AbstractControllerCon text.install(AbstractControllerContext.java:348)
    at org.jboss.system.microcontainer.ServiceControllerC ontext.install(ServiceControllerContext.java:286)
    at org.jboss.dependency.plugins.AbstractController.in stall(AbstractController.java:1631)
    at org.jboss.dependency.plugins.AbstractController.in crementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:553)
    at org.jboss.system.ServiceController.doChange(Servic eController.java:688)
    at org.jboss.system.ServiceController.start(ServiceCo ntroller.java:460)
    at org.jboss.system.deployers.ServiceDeployer.start(S erviceDeployer.java:163)
    at org.jboss.system.deployers.ServiceDeployer.deploy( ServiceDeployer.java:99)
    at org.jboss.system.deployers.ServiceDeployer.deploy( ServiceDeployer.java:46)
    at org.jboss.deployers.spi.deployer.helpers.AbstractS impleRealDeployer.internalDeploy(AbstractSimpleRea lDeployer.java:62)
    at org.jboss.deployers.spi.deployer.helpers.AbstractR ealDeployer.deploy(AbstractRealDeployer.java:50)
    at org.jboss.deployers.plugins.deployers.DeployerWrap per.deploy(DeployerWrapper.java:171)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doDeploy(DeployersImpl.java:1439)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doInstallParentFirst(DeployersImpl.java:1157)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doInstallParentFirst(DeployersImpl.java:1178)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.doInstallParentFirst(DeployersImpl.java:1210)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.install(DeployersImpl.java:1098)
    at org.jboss.dependency.plugins.AbstractControllerCon text.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.in stall(AbstractController.java:1631)
    at org.jboss.dependency.plugins.AbstractController.in crementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:553)
    at org.jboss.deployers.plugins.deployers.DeployersImp l.process(DeployersImpl.java:781)
    at org.jboss.deployers.plugins.main.MainDeployerImpl. process(MainDeployerImpl.java:702)
    at org.jboss.system.server.profileservice.repository. MainDeployerAdapter.process(MainDeployerAdapter.ja va:117)
    at org.jboss.system.server.profileservice.repository. ProfileDeployAction.install(ProfileDeployAction.ja va:70)
    at org.jboss.system.server.profileservice.repository. AbstractProfileAction.install(AbstractProfileActio n.java:53)
    at org.jboss.system.server.profileservice.repository. AbstractProfileService.install(AbstractProfileServ ice.java:361)
    at org.jboss.dependency.plugins.AbstractControllerCon text.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.in stall(AbstractController.java:1631)
    at org.jboss.dependency.plugins.AbstractController.in crementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.re solveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.ch ange(AbstractController.java:553)
    at org.jboss.system.server.profileservice.repository. AbstractProfileService.activateProfile(AbstractPro fileService.java:306)
    at org.jboss.system.server.profileservice.ProfileServ iceBootstrap.start(ProfileServiceBootstrap.java:27 1)
    at org.jboss.bootstrap.AbstractServerImpl.start(Abstr actServerImpl.java:461)
    at org.jboss.Main.boot(Main.java:221)
    at org.jboss.Main$1.run(Main.java:556)
    at java.lang.Thread.run(Thread.java:619)
    2010-05-03 14:24:34,140 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/adminSpring]] (main) Servlet /adminSpring threw load() exception
    java.lang.IllegalStateException: Context attribute is not of type WebApplicationContext: org.springframework.web.context.support.XmlWebAppl icationContext@123c4a: display name [Root WebApplicationContext]; startup date [Mon May 03 14:24:31 CEST 2010]; root of context hierarchy
    at org.springframework.web.context.support.WebApplica tionContextUtils.getWebApplicationContext(WebAppli cationContextUtils.java:113)
    at

  2. #2

    Default

    this is my web.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

    <display-name>admin</display-name>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Admin</web-resource-name>
    <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>admin</role-name>
    </auth-constraint>
    </security-constraint>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>CSS</web-resource-name>
    <url-pattern>/style.css</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>support</role-name>
    </auth-constraint>
    </security-constraint>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Show SubscriptionTicket</web-resource-name>
    <url-pattern>/show/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>support</role-name>
    </auth-constraint>
    </security-constraint>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Find MSISDN</web-resource-name>
    <url-pattern>/find/consumer/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>support</role-name>
    </auth-constraint>
    </security-constraint>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Cancel MSISDN</web-resource-name>
    <url-pattern>/cancel/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>support</role-name>
    </auth-constraint>
    </security-constraint>

    <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>other</realm-name>
    </login-config>


    </web-app>
    this is my dispatcher-servlet.xml file

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">


    <beans>

    <!-- ========================= VIEW DEFINITIONS ========================= -->

    <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlVi ew"/>
    <property name="prefix" value="/WEB-INF/jspx/"/>
    <property name="suffix" value=".jspx"/>
    </bean>
    </beans>

    this is my applicationContext.xml file

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/jee
    http://www.springframework.org/schem...ng-jee-2.5.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schem...ontext-2.5.xsd
    http://www.springframework.org/schema/util
    http://www.springframework.org/schem...g-util-2.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schem...ing-tx-2.5.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

    <!-- ========================= DEFINITIONS OF PUBLIC CONTROLLERS ========================= -->

    <utilroperties id="jndiProps" location="classpath:jndi.properties"/>

    <bean name="revenue" class="de.quickpay.carmunity.admin.controllers.Rev enueController">
    <property name="baseModel" ref="baseModelClass"/>
    </bean>

    <bean name="list" class="de.quickpay.carmunity.admin.controllers.Gen ericController">
    <property name="baseModel" ref="baseModelClass"/>
    </bean>

    <bean name="show" class="de.quickpay.carmunity.admin.controllers.Gen ericController">
    <property name="baseModel" ref="baseModelClass"/>
    </bean>

    <bean name="find" class="de.quickpay.carmunity.admin.controllers.Sea rchController">
    <property name="baseModel" ref="baseModelClass"/>
    </bean>

    <bean name="cancel" class="de.quickpay.carmunity.admin.controllers.Can celController">
    <property name="baseModel" ref="baseModelClass"/>
    </bean>

    <bean id="baseModelClass" class="de.quickpay.carmunity.admin.models.BaseMode l">
    <property name="countryBean">
    <bean class="de.carmunity.quickpay.core.impl.ejb.country .CountryBean"/>
    </property>
    <property name="extChargeSubServiceBean">
    <bean class="de.carmunity.quickpay.extsubscribe.impl.ejb .services.ExtChargeSubServiceBean"/>
    </property>
    <property name="revenueBean">
    <bean class="de.carmunity.quickpay.api.impl.ejb.revenue. RevenueBean"/>
    </property>
    <property name="extSubscriptionTicketServiceBean">
    <bean class="de.carmunity.quickpay.extsubscribe.impl.ejb .services.ExtSubscriptionTicketServiceBean"/>
    </property>
    <property name="subscriptionBean">
    <bean class="de.carmunity.quickpay.api.impl.ejb.subscrip tion.SubscriptionBean"/>
    </property>
    <property name="persistenceBean">
    <bean class="de.carmunity.quickpay.core.impl.ejb.persist ence.PersistenceBean"/>
    </property>
    <property name="chargingPlanBean">
    <bean class="de.carmunity.quickpay.api.impl.ejb.charging .ChargingPlanBean"/>
    </property>
    <property name="subscriptionTicketDetailsBean">
    <bean class="de.carmunity.quickpay.api.impl.ejb.subscrip tion.SubscriptionTicketDetailsBean"/>
    </property>
    <property name="subscriptionSchedulerBean">
    <bean class="de.carmunity.quickpay.api.impl.ejb.scheduli ng.SubscriptionSchedulerBean"/>
    </property>
    <property name="consumerServiceBean">
    <bean class="de.carmunity.quickpay.extidentify.impl.ejb. services.ConsumerServiceBean"/>
    </property>
    </bean>
    </beans>

    Thanks in Advance,

    Best Regards,
    Rajasekhar.

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    I guess that you have some classloading issue with different spring versions. Check the server for multiple spring jars.

    On a side note I notice different xsd versions in your xml I suggest using 1 version instead of mixing versions.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4

    Default

    Quote Originally Posted by Marten Deinum View Post
    I guess that you have some classloading issue with different spring versions. Check the server for multiple spring jars.

    On a side note I notice different xsd versions in your xml I suggest using 1 version instead of mixing versions.
    hi, thanks for the reply and here I am attaching a EAR image file, where it shows the jar files used in this project, the used spring jars were highlighted, can you please check and give me whats wrong in the EAR file.


    Thanks in Advance,


    Regards,
    Rajasekhar
    Attached Images Attached Images

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    For starters you only need the spring.jar and not all the spring-*.jar files. They seem to be of the same version. I mentioned check your SERVER not only the APP so also check your jboss/lib and server/[name]/lib.

    Next to that you have an ear but are launching a war file? So also make sure that the spring.jar is ONLY in the ear and not in both the ear and the war because that might lead to classloading issues (class identity is based on class name and classloader !).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6

    Default

    Quote Originally Posted by Marten Deinum View Post
    For starters you only need the spring.jar and not all the spring-*.jar files. They seem to be of the same version. I mentioned check your SERVER not only the APP so also check your jboss/lib and server/[name]/lib.

    Next to that you have an ear but are launching a war file? So also make sure that the spring.jar is ONLY in the ear and not in both the ear and the war because that might lead to classloading issues (class identity is based on class name and classloader !).
    hi, thanks for the reply, there are the variations found with both ear and war Files:

    when I delete the spring-2.5.6.jar file in war and run the total EAR project file(I need to use the remaining module dependencies), then the initialization of Dispatcher servlet will fail, and throws
    ERROR [org.springframework.web.servlet.DispatcherServlet] (main) Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'faceletsViewResolver' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property 'viewClass'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.springframework.faces.mvc.JsfView]
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:480)
    I have two modules:

    1. quickpay-admin (developed using spring and struts)
    2. quickpay-admin-spring (redesigning quickpay-admin using spring mvc)

    when I run the ear file, quickpay-admin is working fine and quickpay-admin-spring is throwing errors,

    I dont know whats the problem, can you please check the quoted xml files, whats wrong in dispatcher-servler and context xml files.


    Thanks in Advance,

    Best Regards,
    Rajasekhar.

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Read my friend.. Read... There is nothing wrong with your xmls you are having a darn nasty classloading problem.

    If you have the spring.jar you don't need the spring-[modulename].jar which is what you have. I also suspect that in your war file that there are some spring-[modulename].jar files. The only spring-[modulename].jar you need in your WAR file is the spring-web.jar and spring-webmvc.jar because that isn't included in the big spring.jar.

    And I should read a bit better also, also make sure that the spring.jar from the ear is on the classpath of the war (check the manifest.mf for that).

    Also judging from the stacktrace are you using webflow or at least spring-faces? Because the class missing is from the spring-faces library and not of the core spring.
    Last edited by Marten Deinum; May 4th, 2010 at 11:32 AM.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  8. #8

    Default

    Quote Originally Posted by Marten Deinum View Post
    Read my friend.. Read... There is nothing wrong with your xmls you are having a darn nasty classloading problem.

    If you have the spring.jar you don't need the spring-[modulename].jar which is what you have. I also suspect that in your war file that there are some spring-[modulename].jar files. The only spring-[modulename].jar you need in your WAR file is the spring-web.jar and spring-webmvc.jar because that isn't included in the big spring.jar.

    And I should read a bit better also, also make sure that the spring.jar from the ear is on the classpath of the war (check the manifest.mf for that).

    Also judging from the stacktrace are you using webflow or at least spring-faces? Because the class missing is from the spring-faces library and not of the core spring.
    thank you very much for your valuable information...

    I have to include the required dependencies in the quickpay-adminSpring module though it can access required jar files from other modules, finally I included the dependencies as you said, then it worked perfectly.

    Thank you very much.

    Best Regards,
    Rajasekhar.

Posting Permissions

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