WildFly 8.2.1.
I have a "common" module in modules/system/layers/base.
Also I have a EAR with EJB-JAR inside In this EAR I have jboss-deployment-structure.xml with dependence to the "common" module. It works ok, I can use Classes from that module.
But, when I try to construct JAXBContext
on package inside that module, and try to unmarshal some xml to Object, I get
unexpected element (uri:"{my namespace}", local:"{my local name}"). Expected elements are (none)
If I move that classes inside EJB-JAR(all in one module), unmarshalling works ok.
So it's something coming from modules separation.
I've tried to print .toString()
from JAXBContext
object.
With one module: All annotated classes are there.
With two modules: There is only ObjectFactory
class from specified package there.
If I explicitly add the class to JAXBContext
, I can see all need classes from .toString()
, but unmarshalling is still not wirking. I get null object.
What it could be? Thank you.
I've found the solution.
But I don't completely understand what was the problem :) It's something with modules separation, class loading and class isolation in OSGi-like infrastructure thing.
To solve the problem, it must be added dependency in module.xml to "common" module for a "javax.xml.bind.api" like that:
<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.3" name="{module name}">
<resources>
<resource-root path="."/>
<resource-root path="common-types-1.0.jar"/>
</resources>
<dependencies>
<module name="javax.xml.bind.api"/>
</dependencies>
</module>
It seems to be when this module is dependence to some deployment, it's not enough javax.xml.bind.api to present in that deployment for JAXBContext creation with those classes from common module. It needs to be added to common module as well.