2012-02-17 109 views
5

我有一个运行在websphere应用程序服务器8(WAS)上的web应用程序。在web.xml中我有:在websphere应用程序服务器中弹簧加载资源

<context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>classpath*:by/example/**/*-ctx.xml</param-value> 
</context-param> 

然后当我部署我的应用程序在WAS - 它通过与前缀“wsjar的:文件...”的网址加载我所有的CTX文件是好的。

但是当我工作的程序,我尝试使用我的应用程序上下文的对象加载资源,这样的:

applicationContext.getResource("classpath*:by/example/**/I-*.sql").getUrl() 

它抛出URL不正确的例外 - 但如果我添加preffix“wsjar的:”像这:

applicationContext.getResource("wsjar:classpath*:by/example/**/I-*.sql").getUrl() 

它运作良好。但我需要创建通用系统来加载不同的应用程序服务器和servlet容器上的资源。在tomcat前缀不需要。

如何通过ContextLoaderListener以与ContextLoader相同的方式在WAS中加载资源,而无需preffix“wsjar:”加载我的ctx文件?

回答

-1

尝试类似这样的事情。

 ApplicationContext appContext = 
     new ClassPathXmlApplicationContext(new String[] {"If-you-have-any.xml"}); 

    Resource resource = 
     appContext.getResource("classpath*:by/example/**/I-*.sql"); 
+2

问题是,“Resource resource = appContext.getResource(”classpath *:by/example/**/I - *。sql“);”不在工作 – 2012-02-17 13:46:29

1

当我使用完整软件包名称时,我对IBM WAS没有任何问题。像这样:

  classpath:com/tdp/abc/facilitador/boost/config/reglaBoostWS-support.xml   

我没有尝试使用星号来指向多个文件。也许列出所有个人文件可以为你工作。

相关问题