相关疑难解决方法(0)

为什么在初始化Spring时会出现NullPointerException

我在服务器上运行批处理作业时遇到问题,而在我的开发工作站上从Eclipse运行正常.

我已经使用Roo设置了我的Spring环境,创建了一个实体,并制作了一个可以完成某些工作的批处理,并在我的开发框中进行了测试.我初始化我的上下文并完成工作,但是当我在服务器上运行我的批处理时,上下文没有正确初始化.这是代码:

public class TestBatch {

    private static ApplicationContext context;


    @SuppressWarnings("unchecked")
    public static void main(final String[] args) {

            context = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext.xml");
            try {
                @SuppressWarnings("unused")
                TestBatch app = new TestBatch();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
    }

    public void TestBatch() { /** Do Something using the context **/ }

}
Run Code Online (Sandbox Code Playgroud)

这是日志和例外:

2010-02-16 11:54:16,072 [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6037fb1e: startup date [Tue Feb 16 11:54:16 CET 2010]; root of context hierarchy
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:194)
    at …
Run Code Online (Sandbox Code Playgroud)

java spring initialization classpath spring-roo

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

classpath ×1

initialization ×1

java ×1

spring ×1

spring-roo ×1