简体   繁体   中英

org.springframework.beans.factory.UnsatisfiedDependencyException moskito

Tomcat8 (jdk8) is not starting. I am using moskito version 2.4.3. Its already embedded by devs, dont know what am i missing.

Can you point me? Thanks

04-May-2017 16:22:07.553 SEVERE [localhost-startStop-1] org.springframework.web.context.ContextLoader.initWebApplicationContext Context initialization failed
                 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionListener' defined in class path resource [monitoringContext-web.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.servlet.Filter]: Could not convert factory method argument value of type [net.anotheria.moskito.web.session.SessionCountProducer] to required type [javax.servlet.Filter]: Failed to convert value of type [net.anotheria.moskito.web.session.SessionCountProducer] to required type [javax.servlet.Filter]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [net.anotheria.moskito.web.session.SessionCountProducer] to required type [javax.servlet.Filter]: no matching editors or conversion strategy found
                        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724)
                        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
                        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
                        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
                        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
                        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
                        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
                        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
                        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
                        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
                        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
                        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
                        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
                        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
                        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
                        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
                        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
                        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
                        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596)
                        at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1805)
                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
                        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                        at java.lang.Thread.run(Thread.java:745)
    May 04, 2017 4:22:07 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
    May 04, 2017 4:22:07 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Context [/myapp] startup failed due to previous errors

Using these dependencies:

moskito-aop-2.4.3.jar
moskito-central-connectors-common-1.1.0.jar
moskito-central-embedded-common-1.1.0.jar
moskito-core-2.4.4.jar

Here is monitoringContext-web.xml.

    <?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-4.2.xsd">

   <bean id="uiUrlBuilderFilter" factory-bean="applicationFilters" factory-method="add">
      <constructor-arg>
         <bean class="net.domain.myapp.monitoring.filters.ApplicationContextUrlBuilderFilter" />
      </constructor-arg>
   </bean>
   <bean id="methodFilter" factory-bean="applicationFilters" factory-method="add">
      <constructor-arg>
         <bean class="net.anotheria.moskito.web.filters.MethodFilter" />
      </constructor-arg>
   </bean>
   <bean id="userAgentFilter" factory-bean="applicationFilters" factory-method="add">
      <constructor-arg>
         <bean class="net.anotheria.moskito.web.filters.UserAgentFilter" />
      </constructor-arg>
   </bean>

   <bean id="sessionListener" factory-bean="applicationFilters" factory-method="add">
      <constructor-arg>
         <bean class="net.anotheria.moskito.web.session.SessionCountProducer" />
      </constructor-arg>
   </bean>
</beans>

The problem is that you are using a factory that creates FILTERS. I think that's not the way to declare a session counter. You should find another factory for LISTENERS or declare it yourself in the web.xml as stated here

https://confluence.opensource.anotheria.net/display/MSK/MoSKito-Essential+Integration+Guide#MoSKito-EssentialIntegrationGuide-Listeners

+1 to Rubio's answer
SessionCountProducer is not a Filter and the proper way of initializing it is to place next code to web.xml :

<listener>
  <listener-class>
    net.anotheria.moskito.web.session.SessionCountProducer
  </listener-class>
</listener>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM