1 Reply Latest reply on Oct 17, 2006 10:29 AM by Peter Johnson

    Find the path to my deployed .ear file

    Rusi Filipov Newbie

      Hello all,

      I'm a newbie and am trying to programatically find the filesystem path to the its .ear file, without to explicitly specify it. (I deploy myapp.ear in the jboss/server/default/deploy directory, but I don't want to have to configure it)

      I found a way (a hack) to do it like this:

      String rootPath = getClass().getResource("/").getFile();

      This points to the dir where the Tomcat deployer has deployed the app: jboss/server/default/tmp/deploy/tmp123myapp.ear-contents/myapp-webservice-exp.war . Then I create a File object and have the dir.
      File earDir = new File(rootPath).getParentFile();


      This URL-hack is certainly very deployment- and JBoss-specific and I was looking for a more-elegant solution. Perhaps the Java Management API (JSR-77) or the Java Deployment API (JSR-88) would help me? Any hints or code would be very appreciated!

      Rusi

      PS: My actual goal is to list all classes in my application that implement a given interface. I was surprised to see that this was not possible using Reflection. The only solution seems to be to brute-force search in the application's .ear file (or in the deployer's temp-dir) and to compare all classes with the interface using Class.isAssignableFrom().