4 Replies Latest reply on Mar 14, 2012 2:45 AM by jehanzeb.qayyum

    Use JRE lib/ext classes in the application

    jehanzeb.qayyum

      Hi,

       

      I have some libraries/jars inside JRE's lib/ext folder that i want to use in my application deployed in JBOSS AS 7.1.1 Final. These libraries are under arbitrary package i.e. com.abc.asd. I tried to use the classes present in those jars but i get ClassNotFoundException. How do i fix this under JBOSS 7 modular architecture?

       

      Thanks

        • 1. Re: Use JRE lib/ext classes in the application
          guinotphil

          Hello,

           

          You need to define a new module like this:

          <module xmlns="urn:jboss:module:1.1" name="yourmodule">

              <dependencies>

                  <system export="true">

                      <paths>

                          <path name="com/abc"/>

                          <path name="com/abc/asd"/>

                      </paths>

                  </system>

              </dependencies>

          </module>

           

           

          And then add a dependency to this module on your application.

           

          You can also directly add the system dependencies to your jboss-deployment-structure.xml

          • 2. Re: Use JRE lib/ext classes in the application
            wdfink

            I would pack it into one or even more modules and set a dependency in the MANIFEST (or jboss-deployment-structure) of your EAR.

            The JRE lib is not included in the JBoss classpath.

            • 3. Re: Use JRE lib/ext classes in the application
              guinotphil

              On my side, I add to add some lib to the JRE classpath because I couldn't make them work any other way (things such as Charset Provider, etc...)

               

              In standalone.sh, it seemed quite difficul and dangerous to use java -cp instead of java -jar to load jboss-modules, so I did it that way:

               

              # Classpath for system libraries that can not be loaded as modules

              LIB_EXT="$JAVA_HOME/jre/lib/ext:/path/to/my/other/libs"

              if [ "x$LIB_EXT" != "x" ]; then

                JAVA_OPTS="$JAVA_OPTS -Djava.ext.dirs=$LIB_EXT"

              fi

               

              (my JAVA_HOME refers to a JDK installation)

              • 4. Re: Use JRE lib/ext classes in the application
                jehanzeb.qayyum

                Thanks, How would i add all subpackages in a module? Instead of writing each in module.xml. e.g. is there any syntax like <path name="com/abc/*"/>.

                Because there are alot of jars and packages.