Announcement Announcement Module
Collapse
No announcement yet.
Context initialization failed - new user Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Context initialization failed - new user

    win XP
    tomcat 5.5.16
    spring 1.2.8
    java 1.5.0_06

    Hi all, I am a newbie to Spring as this post will no doubt reveal. Anyway, I'm working through the new book 'agile java development' and my first attempt at deploying the example 'timex' webapp failed. I think I found the relevant error stmt but can't find how to fix it (googled, searched forum with some key words from the error stmt, removed all other webapps from tomcat except for this one). I'm thinking the problem will be obvious to someone with more experience using the Spring framework. Any advice/direction on this is much appreciated?

    Eric

    error stmt I think matters most ...
    2006-06-05 16:33:21,048 ERROR [org.springframework.web.servlet.DispatcherServlet] - Context initialization failed
    org.springframework.beans.factory.BeanDefinitionSt oreException: Line 6 in XML document from ServletContext resource [/WEB-INF/timex-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".


    more complete stack ...
    [org.springframework.web.servlet.DispatcherServlet] - Initializing servlet 'timex'
    2006-06-05 16:33:20,957 INFO [org.springframework.core.CollectionFactory] - JDK 1.4+ collections available
    2006-06-05 16:33:20,957 INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'timex': initialization started
    2006-06-05 16:33:20,957 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/timex]] - Loading WebApplicationContext for Spring FrameworkServlet 'timex'
    2006-06-05 16:33:21,038 INFO [org.springframework.beans.factory.xml.XmlBeanDefin itionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/timex-servlet.xml]
    2006-06-05 16:33:21,048 ERROR [org.springframework.web.servlet.DispatcherServlet] - Context initialization failed
    org.springframework.beans.factory.BeanDefinitionSt oreException: Line 6 in XML document from ServletContext resource [/WEB-INF/timex-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.createSAXParseException(ErrorHandlerWrap per.java:236)
    at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(ErrorHandlerWrapper.java:172)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:382)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:316)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.rootElementSpecified(XMLDTDValidator.jav a:1652)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.handleStartElement(XMLDTDValidator.java: 1931)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.startElement(XMLDTDValidator.java:795)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanStartElement(XMLDocumentF ragmentScannerImpl.java:878)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl$ContentDispatcher.scanRootElementHook (XMLDocumentScannerImpl.java:1157)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDispatcher.dis patch(XMLDocumentFragmentScannerImpl.java:1794)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(DOMParser.java:250)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(DocumentBuilderImpl.java:292)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:222)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:173)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:148)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:129)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:145)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:126)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:94)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:89)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:262)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:139)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:3 06)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:251 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:220)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:112)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1105)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:932)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:3917)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4197)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:759)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:739)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:524)
    at org.apache.catalina.startup.HostConfig.deployWAR(H ostConfig.java:809)
    at org.apache.catalina.startup.HostConfig.deployWARs( HostConfig.java:698)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:472)
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1112)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:310)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
    Last edited by ewulff; Jun 5th, 2006, 06:55 PM. Reason: bad title

  • #2
    What does timex-servlet.xml look like? - the first 10 lines or so at least.

    Comment


    • #3
      Originally posted by manifoldronin
      What does timex-servlet.xml look like? - the first 10 lines or so at least.
      duh, sorry bout that . Here it is ...

      <?xml version="1.0" encoding="UTF-8"?>

      <beans xmlns="http://www.springframework.org/schema/beans"
      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.xsd">

      <bean id="placeholderConfig"
      class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
      <property name="location"
      value="WEB-INF/classes/timex-servlet.properties" />
      </bean>

      <!-- URL mapping -->
      <bean id="urlMap"
      class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
      <property name="urlMap">
      <props>
      <prop key="/signin.htm">signInController</prop>
      <prop key="/signout.htm">signOutController</prop>
      </props>
      </property>
      </bean>

      <bean id="urlMapAuthenticate"
      class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
      <property name="interceptors">
      <list>
      <ref bean="httpRequestInterceptor" />
      </list>
      </property>
      <property name="urlMap">
      <props>
      <prop key="/timesheetlist.htm">
      timesheetListController
      </prop>
      <prop key="/enterhours.htm">enterHoursController</prop>
      </props>
      </property>
      </bean>

      <bean id="httpRequestInterceptor"
      class="com.visualpatterns.timex.controller.HttpReq uestInterceptor">
      <property name="signInPage">
      <value>signin.htm</value>
      </property>
      <property name="applicationSecurityManager">
      <ref bean="applicationSecurityManager" />
      </property>
      </bean>

      <!-- Controllers -->
      <bean id="urlFilenameController"
      class="org.springframework.web.servlet.mvc.UrlFile nameViewController" />

      <bean name="signInController"
      class="com.visualpatterns.timex.controller.SignInC ontroller">
      <property name="sessionForm">
      <value>true</value>
      </property>
      <property name="formView">
      <value>/signin</value>
      </property>
      <property name="successView">
      <value>redirect:timesheetlist.htm</value>
      </property>
      <property name="commandClass">
      <value>com.visualpatterns.timex.model.Employee</value>
      </property>
      <property name="validator">
      <ref bean="signinValidator" />
      </property>
      <property name="employeeManager">
      <ref bean="employeeManager" />
      </property>
      <property name="applicationSecurityManager">
      <ref bean="applicationSecurityManager" />
      </property>
      <property name="timexJmxBean">
      <ref bean="timexJmxBean" />
      </property>
      </bean>

      <bean name="signOutController"
      class="com.visualpatterns.timex.controller.SignOut Controller">
      <property name="applicationSecurityManager">
      <ref bean="applicationSecurityManager" />
      </property>
      <property name="successView">
      <value>redirect:signin.htm</value>
      </property>
      </bean>

      <bean name="timesheetListController"
      class="com.visualpatterns.timex.controller.Timeshe etListController">
      <property name="timesheetManager">
      <ref bean="timesheetManager" />
      </property>
      <property name="applicationSecurityManager">
      <ref bean="applicationSecurityManager" />
      </property>
      <property name="timexJmxBean">
      <ref bean="timexJmxBean" />
      </property>
      <property name="successView">
      <value>timesheetlist</value>
      </property>
      </bean>

      <bean name="enterHoursController"
      class="com.visualpatterns.timex.controller.EnterHo ursController">
      <property name="sessionForm">
      <value>true</value>
      </property>
      <property name="commandClass">
      <value>com.visualpatterns.timex.model.Timesheet</value>
      </property>
      <property name="formView">
      <value>enterhours</value>
      </property>
      <property name="successView">
      <value>redirect:timesheetlist.htm</value>
      </property>
      <property name="validator">
      <ref bean="enterHoursValidator" />
      </property>
      <property name="timesheetManager">
      <ref bean="timesheetManager" />
      </property>
      <property name="departmentManager">
      <ref bean="departmentManager" />
      </property>
      <property name="applicationSecurityManager">
      <ref bean="applicationSecurityManager" />
      </property>
      </bean>

      <!-- Validators -->
      <bean id="enterHoursValidator"
      class="com.visualpatterns.timex.controller.EnterHo ursValidator" />

      <bean id="signinValidator"
      class="com.visualpatterns.timex.controller.SignInV alidator" />

      <!-- Model classes -->
      <bean id="employeeManager"
      class="com.visualpatterns.timex.model.EmployeeMana ger" />

      <bean id="timesheetManager"
      class="com.visualpatterns.timex.model.TimesheetMan ager" />

      <bean id="departmentManager"
      class="com.visualpatterns.timex.model.DepartmentMa nager" />

      <!-- Utility classes -->
      <bean id="applicationSecurityManager"
      class="com.visualpatterns.timex.util.ApplicationSe curityManager" />

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

      <!-- Spring mail support -->
      <bean id="mailSender"
      class="org.springframework.mail.javamail.JavaMailS enderImpl">
      <property name="host" value="acme.com" />
      <property name="username" value="myuserid" />
      <property name="password" value="mypassword" />
      </bean>

      <bean id="reminderEmailMessage"
      class="org.springframework.mail.SimpleMailMessage" >
      <property name="from" value="[email protected]" />
      <property name="subject" value="Reminder: Submit Timesheet" />
      <property name="text"
      value="Please don't forget to submit your timesheet. Thank you!" />
      </bean>

      <bean id="reminderEmail"
      class="com.visualpatterns.timex.job.ReminderEmail" >
      <property name="employeeManager">
      <ref bean="employeeManager" />
      </property>
      <property name="mailSender">
      <ref bean="mailSender" />
      </property>
      <property name="message">
      <ref bean="reminderEmailMessage" />
      </property>
      </bean>

      <!-- Spring job scheduling -->
      <bean id="reminderEmailJobDetail"
      class="org.springframework.scheduling.quartz.Metho dInvokingJobDetailFactoryBean">
      <property name="targetObject" ref="reminderEmail" />
      <property name="targetMethod" value="sendMail" />
      </bean>

      <bean id="reminderEmailJobTrigger"
      class="org.springframework.scheduling.quartz.CronT riggerBean">
      <property name="jobDetail" ref="reminderEmailJobDetail" />
      <property name="cronExpression" value="0 0 14 ? * 6" />
      </bean>

      <bean
      class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
      <property name="triggers">
      <list>
      <ref bean="reminderEmailJobTrigger" />
      </list>
      </property>
      </bean>

      <!-- Spring JMX support -->
      <bean id="timexJmxBean"
      class="com.visualpatterns.timex.util.TimexJmxBean" />

      <bean id="exporter"
      class="org.springframework.jmx.export.MBeanExporte r">
      <property name="registrationBehaviorName"
      value="REGISTRATION_IGNORE_EXISTING" />
      <property name="beans">
      <map>
      <entry key="Time Expression:name=timex-stats"
      value-ref="timexJmxBean" />
      </map>
      </property>
      </bean>

      <!-- Resource Bundle -->
      <bean id="messageSource"
      class="org.springframework.context.support.Resourc eBundleMessageSource">
      <property name="basenames">
      <list>
      <value>messages</value>
      </list>
      </property>
      </bean>

      </beans>

      Comment


      • #4
        this is the index.jsp from timex app's root - will a doctype decleration help?

        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <c:redirect url="signin.htm"/>

        also, there is no signin.htm in the dev dir tree nor the prod dir tree after deploy. perhaps this somehow relates to the signin.jsp.

        Comment


        • #5
          well, the problem seems to be resolved. I removed the original project and started from scratch and this time I have the sample app running. still not sure what caused the original problem. seems I corrupted something while stepping through the example. will report back if I come across the specific error.

          Eric

          Comment


          • #6
            Originally posted by ewulff
            well, the problem seems to be resolved. I removed the original project and started from scratch and this time I have the sample app running. still not sure what caused the original problem. seems I corrupted something while stepping through the example. will report back if I come across the specific error.

            Eric
            I think you used the Spring 2.0 xml syntax (using the xml schemas) with Spring 1.x library jar (that uses dtd).

            Comment


            • #7
              Originally posted by dejanp
              I think you used the Spring 2.0 xml syntax (using the xml schemas) with Spring 1.x library jar (that uses dtd).
              that very well may be the case. first try I used spring 1.2.8 instead of the spring.jar that comes witht the sample code for the book, agile java development. Would have been nice if that was mentioned in the book but perhaps I missed it.

              many thx for the feedback
              Eric

              Comment

              Working...
              X