Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading resources by spring in a websphere application server

I have a web application running on websphere application server 8 (WAS). In web.xml i have:

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

Then when i deploy my app on WAS - It loads all my ctx files by urls with prefix "wsjar:file..." that is good.

But when in my working app i try to use object of my application context to load resources like this:

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

It's throws exception that url incorrect - but if i add preffix "wsjar:", like this:

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

It works well. But i need to create universal system to load resources on different app servers, and servlets containers. In tomcat prefix not needed.

How can i load resources in my app on WAS in the same way as ContextLoader via ContextLoaderListener load my ctx files without preffix "wsjar:"?

like image 618
Pavel Glushchenko Avatar asked Feb 17 '12 13:02

Pavel Glushchenko


People also ask

Does WebSphere use spring?

For WebSphere Application Server Version 7.0 or later, you must use Spring Framework Version 2.5.

Can we use WebSphere in spring boot application?

Deploying on WebSphere Liberty Profile (WLP) The providedRuntime directive makes sure that the war plugin moves the embeeded tomcat jar files to /WEB-INF/lib-provided from /WEB-INF/lib directory. The premise of Spring Boot is to develop and run Spring applications as standalones - extremely good for development teams.

What is class loader policy in WebSphere?

The application class-loader policy controls the isolation of applications that run in the system (on the server). An application class loader groups enterprise bean (EJB) modules, shared libraries, resource adapter archives (RAR files), and dependency Java™ archive (JAR) files associated to an application.


1 Answers

When i use full package names i have no problems with IBM WAS. Like this:

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

I didn't try using asteriks for pointing multiple files. Maybe listing all individuals files can work for you.

like image 70
Carlos Gavidia-Calderon Avatar answered Oct 26 '22 21:10

Carlos Gavidia-Calderon