ro.isdc.wro.model.WroModel
wro4jを使用するSpringアプリケーションでwro4jを取得したい。しかし、私はいつも
ro.isdc.wro.WroRuntimeException: 現在の要求サイクルに関連付けられたコンテキストがありません!
WroManager
fromを作成しようとすると例外が発生するwroManagerFactory.create()
なぜこの例外があり、誰がそれを修正するのか知っている人はいますか? WroModel
または、Spring Controller でを取得するより良い方法を知っている人はいますか?
(wro4j自体は問題なく動作します)
これは私のコードです (完全な例外は以下にあります):
@Controller
public class HomeController {
@Autowired
private WroFilter wroFilter;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home() {
WroManagerFactory managerFactory = this.wroFilter.getWroManagerFactory();
/*line 127*/WroManager manager = managerFactory.create();
WroModel wroModel = manager.getModelFactory().create();
....
}
}
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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>WebResourceOptimizer</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>wroFilter</param-value>
</init-param>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<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>
<filter-mapping>
<filter-name>WebResourceOptimizer</filter-name>
<url-pattern>/wro/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
春root-context.xml
...
<bean id="wroFilter" class="ro.isdc.wro.http.ConfigurableWroFilter">
<property name="properties" ref="wroProperties" />
</bean>
<util:properties id="wroProperties" location="classpath:wro.properties">
<prop key="debug">true</prop>
<prop key="cacheUpdatePeriod">0</prop>
<prop key="modelUpdatePeriod">0</prop>
</util:properties>
wro.xml
<groups xmlns="http://www.isdc.ro/wro">
<group name="g1">
<css>/styles/part1.css</css>
<css>/styles/part2.css</css>
</group>
<group name="g2">
<css>/styles/part1.css</css>
</group>
</groups>
完全な例外は
ERROR: ro.isdc.wro.util.ProxyFactory - exception
ro.isdc.wro.WroRuntimeException: No context associated with CURRENT request cycle!
at ro.isdc.wro.config.Context.validateContext(Context.java:121)
at ro.isdc.wro.config.Context.get(Context.java:103)
at ro.isdc.wro.model.group.processor.InjectorBuilder$16.create(InjectorBuilder.java:233)
at ro.isdc.wro.model.group.processor.InjectorBuilder$16.create(InjectorBuilder.java:231)
at ro.isdc.wro.util.ProxyFactory.getInterfacesSet(ProxyFactory.java:85)
at ro.isdc.wro.util.ProxyFactory.create(ProxyFactory.java:73)
at ro.isdc.wro.util.ProxyFactory.proxy(ProxyFactory.java:49)
at ro.isdc.wro.model.group.processor.InjectorBuilder.createReadOnlyContextProxy(InjectorBuilder.java:231)
at ro.isdc.wro.model.group.processor.InjectorBuilder.initMap(InjectorBuilder.java:92)
at ro.isdc.wro.model.group.processor.InjectorBuilder.build(InjectorBuilder.java:248)
at ro.isdc.wro.manager.WroManager$Builder.build(WroManager.java:432)
at ro.isdc.wro.manager.factory.BaseWroManagerFactory$1.initialize(BaseWroManagerFactory.java:144)
at ro.isdc.wro.manager.factory.BaseWroManagerFactory$1.initialize(BaseWroManagerFactory.java:73)
at ro.isdc.wro.util.LazyInitializer.get(LazyInitializer.java:32)
at ro.isdc.wro.manager.factory.BaseWroManagerFactory.create(BaseWroManagerFactory.java:156)
at ro.isdc.wro.manager.factory.BaseWroManagerFactory.create(BaseWroManagerFactory.java:51)
at ro.isdc.wro.manager.factory.DefaultWroManagerFactory.create(DefaultWroManagerFactory.java:73)
at ro.isdc.wro.manager.factory.DefaultWroManagerFactory.create(DefaultWroManagerFactory.java:18)
--> at test.testmvc.HomeController.home(HomeController.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:746)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:687)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:278)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)