VirtualWebappLoader or similar for WebLogic to add directories to war's classpath?

戏子无情 提交于 2019-12-20 04:52:30

问题


How can I make an external directory (where additional jars will be deployed) available on the classpath of a war deployed to WebLogic?

I am familiar with how to do this on Tomcat by defining a Loader element in the context.xml and including a virtualClasspath attribute which specifies Additional repositories to search for resources.

Is there a similar feature in WebLogic?


回答1:


Yes weblogic has the option to do this as well with virtual-directory-mapping inside weblogic.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
  <virtual-directory-mapping>
    <local-path>C:\my\images</local-path>
    <url-pattern>*.jpg</url-pattern>
    <url-pattern>dir/*</url-pattern>
  </virtual-directory-mapping>
</weblogic-web-app>

See the Oracle docs here

Other options to use jars outside of a war include installing the jar as a shared library or simply including the jar files inside of your <domain>/lib folder to make them available to all applications.




回答2:


You can create a file with name .beabuild.txt inside application's exploded directory and then map any directory or file to the application's directory.

Example usage

Let's assume we have Gradle multiproject build ExampleProject. Then .beabuild.txt could look like:

C\:/Users/User/.gradle/caches/modules-2/files-2.1/asm/asm/1.5.3/63a2715c39c9e97f88fe371d4441a1b3493d74f9/asm-1.5.3.jar = APP-INF/lib/asm-1.5.3.jar
C\:/Users/User/.gradle/caches/modules-2/files-2.1/asm/asm-all/2.2.3/9b79af5fc90f2dca349f16b771c21a43045f97ba/asm-all-2.2.3.jar = APP-INF/lib/asm-all-2.2.3.jar
C\:/Users/repos/ExampleProject/ui/src/main/webapp = ui.war
C\:/Users/repos/ExampleProject/ui/build/classes/main = ui.war/WEB-INF/classes
C\:/Users/repos/ExampleProject/ui/build/resources/main = ui.war/WEB-INF/classes
C\:/Users/repos/ExampleProject/common/build/classes/main = APP-INF/classes
C\:/Users/repos/ExampleProject/common/build/resources/main = APP-INF/classes

Creating a Split Development Directory Environment at docs.oracle.com



来源:https://stackoverflow.com/questions/28267226/virtualwebapploader-or-similar-for-weblogic-to-add-directories-to-wars-classpat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!