简体   繁体   中英

Add war file to java.class.path in JBoss environment

I'm using a library that scans my classpath in order to find the implementation for my interface (this might seem strange and I know there are better approaches but I cannot change this). When I'm using this library in a standalone application it works since

java.class.path

returns the classpath my jar file is on. Now I'm trying to use this library in a web project deployed to a Jboss 7. When asking the classpath in this case this is returned:

java.class.path /Applications/jboss-as-7.1.1.Final/jboss-modules.jar

I do not really know how I can add something to the java.class.path env variable. Any ideas how i can add something to this variable or a better approach towards this problem? An add() function exists in this lib where I can add a jar file that needs to be scanned. So if someone can tell me how I can get the location of this war file, that would help as well ;).

This is the library I'm talking about: http://software.clapper.org/javautil/

Note: the java.class.path is used inside this library and i do not really want to change anything to said lib.

Thanks in advance.

There is no portable way to do classpath scanning without being able to control the class loader. Better options to achieve this are:

  • use ServiceLoader and META-INF/services
  • use CDI and register the implementations as CDI beans

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM