Monday, May 7, 2012

RAD Application Server Publishing settings and WTP based Maven Projects

The WebSphere Application Server publishing setting in RAD has two options: 1) Run server with resources within the workspace, and 2) Run server with resources on Server. When perform "Run/Debug on Server", with the "within the workspace" option, applications run from the workspace, while with the "on Server" option, applications are deployed to Application Server first and then run from the server.

When there is a local application server is available, the "within the workspace" option is the default and it takes less publishing time compare to the "on Server" option. However, it may not work with WTP based Maven projects that have "Workspace Resolution" enabled.

Given a Maven project that consists of two modules - core and web, when perform "Run/Debug on Server" with Maven "Workspace Resolution" enabled and the "within the workspace" option selected. RAD doesn't publish the core jar file to the workspace publishing folder (e.g. .metadata\.plugins\org.eclipse.wst.server.core\tmp1\), and uses two different class loaders to load the core jar and the web application, thus causes class loading related issues, examples include

- spring xml in the web module cannot import spring xml from core module using <import resource="classpath:com/test/resources/spring-core-beans.xml" />

- the web module cannot load resources from core module using ResourceBundle.getBundle(baseName)

An easy solution to these issues is to use the "Run server with resources on Server" publishing settings.

No comments:

Post a Comment