java - The RepositoryFactory has already been initialized Exception in tiles and Velocity Integration -
i trying integrate tiles+ velocity in spring mvc.
i found link in github serving same purpose. using classes in project in eclispe. when run project getting following exception:
http status 500 - servlet.init() servlet appservlet threw exception type exception report message servlet.init() servlet appservlet threw exception description server encountered internal error prevented fulfilling request. exception javax.servlet.servletexception: servlet.init() servlet appservlet threw exception org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312) java.util.concurrent.threadpoolexecutor.runworker(unknown source) java.util.concurrent.threadpoolexecutor$worker.run(unknown source) java.lang.thread.run(unknown source) root cause org.springframework.beans.factory.beancreationexception: error creating bean name 'tilesconfigurer' defined in servletcontext resource [/web-inf/spring/appservlet/servlet-context.xml]: invocation of init method failed; nested exception java.lang.runtimeexception: not initialize velocityengine: java.lang.illegalstateexception: repositoryfactory has been initialized! org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1455) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:519) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:456) org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:294) org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:225) org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:291) org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193) org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:585) org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:913) org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:464) org.springframework.web.servlet.frameworkservlet.configureandrefreshwebapplicationcontext(frameworkservlet.java:631) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:588) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:645) org.springframework.web.servlet.frameworkservlet.initwebapplicationcontext(frameworkservlet.java:508) org.springframework.web.servlet.frameworkservlet.initservletbean(frameworkservlet.java:449) org.springframework.web.servlet.httpservletbean.init(httpservletbean.java:133) javax.servlet.genericservlet.init(genericservlet.java:160) org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312) java.util.concurrent.threadpoolexecutor.runworker(unknown source) java.util.concurrent.threadpoolexecutor$worker.run(unknown source) java.lang.thread.run(unknown source) root cause java.lang.runtimeexception: not initialize velocityengine: java.lang.illegalstateexception: repositoryfactory has been initialized! org.apache.velocity.tools.view.velocityview.init(velocityview.java:354) org.apache.velocity.tools.view.velocityview.init(velocityview.java:310) org.apache.velocity.tools.view.velocityview.<init>(velocityview.java:213) org.apache.tiles.velocity.renderer.velocityattributerenderer.commit(velocityattributerenderer.java:82) com.me.velo.velocitytilescontainerfactory.registerattributerenderers(velocitytilescontainerfactory.java:175) org.apache.tiles.factory.basictilescontainerfactory.createrendererfactory(basictilescontainerfactory.java:411) org.apache.tiles.factory.basictilescontainerfactory.createcontainer(basictilescontainerfactory.java:111) org.apache.tiles.startup.abstracttilesinitializer.createcontainer(abstracttilesinitializer.java:124) org.apache.tiles.startup.abstracttilesinitializer.initialize(abstracttilesinitializer.java:70) org.springframework.web.servlet.view.tiles2.tilesconfigurer.afterpropertiesset(tilesconfigurer.java:339) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1514) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1452) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:519) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:456) org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:294) org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:225) org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:291) org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193) org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:585) org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:913) org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:464) org.springframework.web.servlet.frameworkservlet.configureandrefreshwebapplicationcontext(frameworkservlet.java:631) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:588) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:645) org.springframework.web.servlet.frameworkservlet.initwebapplicationcontext(frameworkservlet.java:508) org.springframework.web.servlet.frameworkservlet.initservletbean(frameworkservlet.java:449) org.springframework.web.servlet.httpservletbean.init(httpservletbean.java:133) javax.servlet.genericservlet.init(genericservlet.java:160) org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312) java.util.concurrent.threadpoolexecutor.runworker(unknown source) java.util.concurrent.threadpoolexecutor$worker.run(unknown source) java.lang.thread.run(unknown source) root cause java.lang.illegalstateexception: repositoryfactory has been initialized! org.apache.velocity.runtime.resource.loader.stringresourceloader$repositoryfactory.setrepositoryclass(stringresourceloader.java:209) org.apache.velocity.runtime.resource.loader.stringresourceloader.init(stringresourceloader.java:99) org.apache.velocity.runtime.resource.resourcemanagerimpl.initialize(resourcemanagerimpl.java:147) org.apache.velocity.runtime.runtimeinstance.initializeresourcemanager(runtimeinstance.java:594) org.apache.velocity.runtime.runtimeinstance.init(runtimeinstance.java:241) org.apache.velocity.app.velocityengine.init(velocityengine.java:116) org.apache.velocity.tools.view.velocityview.init(velocityview.java:347) org.apache.velocity.tools.view.velocityview.init(velocityview.java:310) org.apache.velocity.tools.view.velocityview.<init>(velocityview.java:213) org.apache.tiles.velocity.renderer.velocityattributerenderer.commit(velocityattributerenderer.java:82) com.me.velo.velocitytilescontainerfactory.registerattributerenderers(velocitytilescontainerfactory.java:175) org.apache.tiles.factory.basictilescontainerfactory.createrendererfactory(basictilescontainerfactory.java:411) org.apache.tiles.factory.basictilescontainerfactory.createcontainer(basictilescontainerfactory.java:111) org.apache.tiles.startup.abstracttilesinitializer.createcontainer(abstracttilesinitializer.java:124) org.apache.tiles.startup.abstracttilesinitializer.initialize(abstracttilesinitializer.java:70) org.springframework.web.servlet.view.tiles2.tilesconfigurer.afterpropertiesset(tilesconfigurer.java:339) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1514) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1452) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:519) org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:456) org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:294) org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:225) org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:291) org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193) org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:585) org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:913) org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:464) org.springframework.web.servlet.frameworkservlet.configureandrefreshwebapplicationcontext(frameworkservlet.java:631) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:588) org.springframework.web.servlet.frameworkservlet.createwebapplicationcontext(frameworkservlet.java:645) org.springframework.web.servlet.frameworkservlet.initwebapplicationcontext(frameworkservlet.java:508) org.springframework.web.servlet.frameworkservlet.initservletbean(frameworkservlet.java:449) org.springframework.web.servlet.httpservletbean.init(httpservletbean.java:133) javax.servlet.genericservlet.init(genericservlet.java:160) org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312) java.util.concurrent.threadpoolexecutor.runworker(unknown source) java.util.concurrent.threadpoolexecutor$worker.run(unknown source) java.lang.thread.run(unknown source) note full stack trace of root cause available in apache tomcat/7.0.35 logs. apache tomcat/7.0.35
i don't know means after looking @ root cause found out the repositoryfactory has been initialized main reason. using classes provided in repository provided @ github link mentioned above , servlet-context.xml is
<?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- dispatcherservlet context: defines servlet's request-processing infrastructure --> <!-- enables spring mvc @controller programming model --> <annotation-driven /> <!-- handles http requests /resources/** efficiently serving static resources in ${webapproot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- resolves views selected rendering @controllers .jsp resources in /web-inf/views directory --> <!-- <beans:bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <beans:property name="prefix" value="/web-inf/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> --> <context:component-scan base-package="com.me.velo" /> <!-- <beans:bean id="tilesviewresolver" class="org.springframework.web.servlet.view.urlbasedviewresolver"> <beans:property name="viewclass" value="org.springframework.web.servlet.view.tiles2.tilesview"/> <beans:property name="order" value="1"/> </beans:bean> <beans:bean id="velocityconfig" class="org.springframework.web.servlet.view.velocity.velocityconfigurer"> <beans:property name="resourceloaderpath" value="/web-inf/views/" /> </beans:bean> <beans:bean id="viewresolver" class="org.springframework.web.servlet.view.velocity.velocityviewresolver"> <beans:property name="cache" value="true"/> <beans:property name="prefix" value="/web-inf/views/"/> <beans:property name="suffix" value=".vm"/> <beans:property name="order" value="2"/> </beans:bean> <beans:bean id="tilesconfigurer" class="org.springframework.web.servlet.view.tiles2.tilesconfigurer"> <beans:property name="definitions"> <beans:list> <beans:value>/web-inf/tiles.xml</beans:value> </beans:list> </beans:property> </beans:bean> --> <!-- velocity + tiles initializer --> <beans:bean id="velocitytilesinitializer" class="com.me.velo.velocitytilesinitializer"> <beans:property name="veolocitytoolbox" value="/web-inf/tools.xml" /> <beans:property name="veolocityproperties" value="/web-inf/velocity.properties" /> <beans:property name="definitions"> <beans:list> <beans:value>/web-inf/tiles.xml</beans:value> </beans:list> </beans:property> </beans:bean> <!-- tiles config velocitytiles initializer --> <beans:bean id="tilesconfigurer" class="org.springframework.web.servlet.view.tiles2.tilesconfigurer"> <beans:property name="tilesinitializer" ref="velocitytilesinitializer" /> </beans:bean> <!-- tiles view --> <beans:bean id="viewresolver" class="org.springframework.web.servlet.view.urlbasedviewresolver"> <beans:property name="viewclass" value="sk.openhouse.web.velocitytilesview" /> <beans:property name="contenttype" value="text/html;charset=utf-8" /> <!-- default attributes every view --> <beans:property name="attributesmap"> <beans:map> <beans:entry key="authentication" value-ref="authenticationservice" /> </beans:map> </beans:property> </beans:bean> </beans:beans>
tiles.xml:
<!doctype tiles-definitions public "-//apache software foundation//dtd tiles configuration 2.0//en" "http://tiles.apache.org/dtds/tiles-config_2_1.dtd"> <tiles-definitions> <definition name="base.definition" template="/web-inf/velocity/layout.vm"> <put-attribute name="body" value="" /> </definition> <definition name="home" extends="base.definition"> <put-attribute name="body" value="/web-inf/velocity/test.vm" /> </definition> </tiles-definitions>
velocity.properties:
userdirective=org.apache.tiles.velocity.template.addattributedirective,\ org.apache.tiles.velocity.template.addlistattributedirective,\ org.apache.tiles.velocity.template.definitiondirective,\ org.apache.tiles.velocity.template.getasstringdirective,\ org.apache.tiles.velocity.template.importattributedirective,\ org.apache.tiles.velocity.template.insertattributedirective,\ org.apache.tiles.velocity.template.insertdefinitiondirective,\ org.apache.tiles.velocity.template.inserttemplatedirective,\ org.apache.tiles.velocity.template.putattributedirective,\ org.apache.tiles.velocity.template.putlistattributedirective
web.xml:
<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" 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"> <!-- definition of root spring container shared servlets , filters --> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml</param-value> </context-param> <!-- creates spring container shared servlets , filters --> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- processes application requests --> <servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/appservlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>velocity</servlet-name> <servlet-class>org.apache.velocity.tools.view.velocityviewservlet</servlet-class> <init-param> <param-name>org.apache.velocity.toolbox</param-name> <param-value>/web-inf/tools.xml</param-value> </init-param> <init-param> <param-name>org.apache.velocity.properties</param-name> <param-value>/web-inf/velocity.properties</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>appservlet</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>one.jsp</welcome-file> </welcome-file-list> </web-app>
i not sure causing exception. if has encountered exception, please help. in advance.
Comments
Post a Comment