How to access JDK tools.jar javac from application deployed in JBoss 7 or WildFly

十年热恋 提交于 2019-12-11 10:35:42

问题


I am deploying an application that tries to use javac and finally fails with java.lang.NoClassDefFoundError: com/sun/tools/javac/Main

How should I make javac from tools.jar available to the application deployed in JBoss 7 or WildFly ?


回答1:


Here is the process I followed to create a JBoss module for javac:

mkdir -p modules/com/sun/tools/javac/main
ln -s /usr/java/latest/lib/tools.jar modules/com/sun/tools/javac/main/tools.jar

Create modules/com/sun/tools/javac/main/module.xml with content:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.sun.tools.javac">
    <resources>
        <resource-root path="tools.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <system export="true">
            <paths>
                <path name="com/sun/tools/javac"/>
            </paths>
        </system>
    </dependencies>
</module>

Note: I used a symbolic link because absolute path seems not supported by resource-root path attribute.

Then either add Dependencies: com.sun.tools.javac in META-INF/MANIFEST.MF or create a jboss-deployment-structure.xml file to declare use of this new module by the application: https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/html/Development_Guide/Add_an_Explicit_Module_Dependency_to_a_Deployment1.html



来源:https://stackoverflow.com/questions/24866883/how-to-access-jdk-tools-jar-javac-from-application-deployed-in-jboss-7-or-wildfl

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