我有一个spring引导应用程序,并使用嵌入式jetty容器,没有web.xml文件。我有一个自定义的ContextLoaderLister类,它是default Spring ContextLoaderListener的子类
public class MyContextListener extends org.springframework.web.context.ContextLoaderListener
并按如下方式进行注册:
@Configuration
public class ApplicationConfiguration {
@Bean
public ServletCo
我试图在我的Spring项目中使用H2和hibernate存储数据,但我无法摆脱这一点:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.AbstractMethodError: ch.qos.logback.classic.Logger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String
自定义ContextLoaderListener类无法在Websphere中工作,它将引发以下错误。同样,在Tomcat、JBoss、Weblogic中工作也很好。
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
我的自定义上下文加载器类如下所示:
public class CustomContextListener extends ContextLoaderListener {
//implemented contextInit
我想把我的maven project改成dynamic web project。我删除了pom.xml文件,创建了一个新的工作空间,并导入了项目。我得到了下面的错误。我添加了所需的所有jar文件。
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener.
Exception sending context destroyed event to listener instance of class
严重:异常将上下文初始化事件发送到类org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError的侦听器实例:org/apache/commons/org/LogFactory at org.springframework.core.CollectionFactory.(CollectionFactory.java:64) at org.springframework.web.context.ContextLoader.(ContextLoader.java:153) at org.s
对于我的spring应用程序与junit的集成测试,我对org.springframework.test.context.ContextLoader进行了子类化,因为我想使用已经存在的XmlWebApplicationContext来连接我的测试类,如下所示:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader=MyContextLoader.class)
@Transactional
public class MyTest {
@Autowired
public AccountDao acc
如果应用程序启动时有一些空的数据库表,我希望使用应用程序API向数据库中插入一些数据。我该怎么做呢?
我使用的是Spring 3.1,Hibernate 4.1.1。
编辑
多亏了AlexR,答案是对ContextLoaderListener进行子类化,在contextInitialized中调用超级,然后做你需要做的任何事情:
public class MyContextLoaderListener extends ContextLoaderListener {
public void contextInitialized(final ServletContextEvent eve
我喜欢使用javassist在web应用程序中更改第三方类。当org.springframework.web.context.ContextLoaderListener调用spring web应用程序上下文初始化时,将加载该类。我尝试了自定义的BeanFactoryPostProcessor,但似乎为时已晚:
javassist.CannotCompileException: by java.lang.LinkageError: loader ... duplicate class definition for name: "SomeClass"
我想这可以通过在初始化bean
我正在为一个遗留应用程序将Spring2.x升级到4.x,该应用程序作为FileSystem Xml application上下文运行,并使用父上下文中的bean启动具有WebApplicon上下文的嵌入式jetty服务器。
在Spring2中,这是通过覆盖createContextLoader()的自定义ContextLoaderListener实现的
public class CustomContextLoaderListener extends ContextLoaderListener implements ApplicationContextAware {
private
我是谷歌应用程序引擎的新手。我得到了这个错误:
java.lang.NoClassDefFoundError: Could not initialize class
org.apache.commons.logging.LogFactory at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoaderListener.cont