Samurai
Samurai

Reputation: 843

JBoss not loading inner classes from modules

I have created a new module for my sample.jar. It is having package like sample/example. Under example I have 2 more packages sample1, sample2.

I created module like modules/sample/example and my module.xml is

<module xmlns="urn:jboss:module:1.1" name="sample.example">
<resources>
    <resource-root path="sample.jar"/>
    <!-- Insert resources here -->
</resources>

In my deployment-structure xml,

<dependencies> 
    <module name="sample.example" /> 
</dependencies> 

sample.example.sample1.Test class is importing sample.example.sample2.Test2 file When I am creating object for sample.example.sample1.Test, I am getting below exception.

Exception in thread "main" java.lang.LinkageError: Failed to link sample/example/sample1/Test (Module "sample.example:main" from local module loader @117843d (finder: local module finder @eacb9c (roots: C:\Daten\Softwares\jboss-eap-6.2.0\jboss-eap-6.2\modules,C:\Daten\Softwares\jboss-eap-6.2.0\jboss-eap-6.2\modules\system\layers\base)))

Caused by: java.lang.NoClassDefFoundError: sample/example/sample2/Test2
    at java.lang.ClassLoader.defineClass1(Native Method)

Caused by: java.lang.ClassNotFoundException: sample.example.sample2.Test2 from [Module "sample.example:main" from local module loader @117843d (finder: local module finder @eacb9c (roots: C:\Daten\Softwares\jboss-eap-6.2.0\jboss-eap-6.2\modules,C:\Daten\Softwares\jboss-eap-6.2.0\jboss-eap-6.2\modules\system\layers\base))]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:443)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:431)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:373)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:118)
    ... 61 more

Upvotes: 0

Views: 3003

Answers (1)

James R. Perkins
James R. Perkins

Reputation: 17760

The module.xml and the JAR should be in the modules\sample\sample\main directory. It looks like in your case C:\Daten\Softwares\jboss-eap-6.2.0\jboss-eap-6.2\modules\sample\sample\main.

You could also use the CLI command module add command.

%JBOSS_HOME%\bin\jboss-cli.bat -c "module add --name=sample.sample --resources=sample.jar"

You could just connect the CLI client too and use tab complete to see all the options as well. The --resource will take the full path to your sample.jar and copy it over into the correct directory and make the module.xml file for you.

Upvotes: 1

Related Questions