It's hard to tell without the manifests of the bundles involved, but this looks like a framework setup error.
I can see that there's a JBoss modules ClassLoader and an Equinox ClassLoader in the mix here, and I'm guessing that you're starting an Equinox OSGi framework inside the JBoss modules framework. The rest of this answer assumes that this is what you're doing.
In order to make this work you will need to delegate loading of "JBoss provided packages" such as the Java EE API to the parent JBoss Modules framework, or otherwise you'll get inconsistent class space issues (such as the LinkageError
you're seeing) when you call to JBoss server components.
The thing that you need to do is add to the framework system packages (the packages provided by the system bundle in the Equinox framework). You do this by specifying the org.osgi.framework.system.packages.extra
property at startup.
The value of the property needs to include any packages that you want to add and their versions and and uses constraints (if you want things to work properly).
For example in this case you will need at least (and probably more than):
javax.mail;version=1.4;uses:="javax.activation,
javax.mail.event,javax.mail.search",
javax.mail.event;version=1.4;uses:="javax.mail"
javax.mail.internet;version=1.4;uses:="javax.activation,
javax.mail,javax.mail.util"
javax.mail.search;version=1.4;uses:="javax.mail,javax.mail.internet"
javax.mail.util;version=1.4;uses:="javax.activation,javax.mail.internet"
Note that the reason you need to do this isn't actually OSGi's fault. You're trying to access non-standard (i.e. non JRE) packages that exist outside the framework from inside the framework. OSGi's job is to enforce the runtime dependencies of your code, and this would normally mean "bundles you have deployed" in this case you're accessing packages that aren't coming from bundles, so you need to tell OSGi what they are.