[
https://issues.jboss.org/browse/SOLDER-222?page=com.atlassian.jira.plugin...
]
Roberto Carta commented on SOLDER-222:
--------------------------------------
I've find another way trying to solve my problem. This solution tries to use two
different class loader. First using original code, and if no classes/resources are
founded, using the _expectedType.getClassLoader()_.
Here the patch:
{code:title=solder-api/org.jboss.solder.util.service.ServiceLoader}
--- a/api/src/main/java/org/jboss/solder/util/service/ServiceLoader.java
+++ b/api/src/main/java/org/jboss/solder/util/service/ServiceLoader.java
@@ -148,6 +148,11 @@
List<URL> serviceFiles = new ArrayList<URL>();
try {
Enumeration<URL> serviceFileEnumerator =
loader.getResources(serviceFile);
+ if (!serviceFileEnumerator.hasMoreElements()) {
+ if (loader.equals(Thread.currentThread().getContextClassLoader())) {
+ serviceFileEnumerator =
expectedType.getClassLoader().getResources(serviceFile);
+ }
+ }
while (serviceFileEnumerator.hasMoreElements()) {
serviceFiles.add(serviceFileEnumerator.nextElement());
}
@@ -210,9 +215,21 @@
Class<? extends S> serviceClass = null;
try {
clazz = loader.loadClass(serviceClassName);
- serviceClass = clazz.asSubclass(expectedType);
} catch (ClassNotFoundException e) {
- log.warn("Could not load service class " + serviceClassName);
+ if (!loader.equals(expectedType.getClassLoader())) {
+ try {
+ clazz = expectedType.getClassLoader().loadClass(serviceClassName);
+ } catch (ClassNotFoundException e2) {
+
+ }
+ }
+ }
+ try {
+ if (clazz == null) {
+ log.warn("Could not load service class " + serviceClassName);
+ } else {
+ serviceClass = clazz.asSubclass(expectedType);
+ }
} catch (ClassCastException e) {
throw new RuntimeException("Service class " + serviceClassName +
" didn't implement the Extension interface");
}
{code}
*But keep in mind that*:
- i'm not able to evaluate possibile side effects, as this class is havily used.
- i've written the minimum changes to this class, without altering other classes, but
you can try to locate a class twice with the same class loader, depending on how
methods/constructor are invoked.
In the hope it will be useful
EAR contained WAR's beans.xml not processed
-------------------------------------------
Key: SOLDER-222
URL:
https://issues.jboss.org/browse/SOLDER-222
Project: Solder
Issue Type: Bug
Affects Versions: 3.0.0.Final
Environment: JBoss AS 7
Reporter: Mike Mosiewicz
I have the EAR app containing one ejb jar and one war. I placed seam-config.jar in
EAR's lib directory. My beans.xml are discovered by weld as follows:
15:21:36,588 DEBUG [org.jboss.weld] (MSC service thread 1-3) Found beans.xml:
"/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/mongodb-seam-0.0.1-SNAPSHOT.jar/META-INF/beans.xml"
15:21:36,591 DEBUG [org.jboss.weld] (MSC service thread 1-3) Found beans.xml:
"/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/seam-persistence-api-3.0.0.Final.jar/META-INF/beans.xml"
15:21:36,592 DEBUG [org.jboss.weld] (MSC service thread 1-3) Found beans.xml:
"/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/seam-security-api-3.0.0.Final.jar/META-INF/beans.xml"
15:21:36,594 DEBUG [org.jboss.weld] (MSC service thread 1-3) Found beans.xml:
"/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/seam-servlet-3.0.0.Final.jar/META-INF/beans.xml"
15:21:36,597 DEBUG [org.jboss.weld] (MSC service thread 1-3) Found beans.xml:
"/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/seam-solder-3.0.0.Final.jar/META-INF/beans.xml"
15:21:36,601 DEBUG [org.jboss.weld] (MSC service thread 1-3) Found beans.xml:
"/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/commerce-ejb-0.0.1-SNAPSHOT.jar/META-INF/beans.xml"
15:21:36,603 DEBUG [org.jboss.weld] (MSC service thread 1-11) Found beans.xml:
"/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/public-war.war/WEB-INF/beans.xml"
It seems that for ejb and other library jars the extension is executed but not for war.
Like this:
15:21:54,173 INFO [org.jboss.seam.config.xml.bootstrap.XmlConfigExtension] (MSC service
thread 1-10) Reading XML file:
vfs:/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/seam-security-api-3.0.0.Final.jar/META-INF/beans.xml
15:21:54,177 INFO [org.jboss.seam.config.xml.bootstrap.XmlConfigExtension] (MSC service
thread 1-10) Reading XML file:
vfs:/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/commerce-ejb-0.0.1-SNAPSHOT.jar/META-INF/beans.xml
15:21:54,195 INFO [org.jboss.seam.config.xml.bootstrap.XmlConfigExtension] (MSC service
thread 1-10) Reading XML file:
vfs:/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/seam-servlet-3.0.0.Final.jar/META-INF/beans.xml
15:21:54,196 INFO [org.jboss.seam.config.xml.bootstrap.XmlConfigExtension] (MSC service
thread 1-10) Reading XML file:
vfs:/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/mongodb-seam-0.0.1-SNAPSHOT.jar/META-INF/beans.xml
15:21:54,197 INFO [org.jboss.seam.config.xml.bootstrap.XmlConfigExtension] (MSC service
thread 1-10) Reading XML file:
vfs:/C:/servers/jboss-as-web-7.0.0.Final/standalone/deployments/laura.ear/lib/seam-solder-3.0.0.Final.jar/META-INF/beans.xml
15:21:54,204 INFO [org.jboss.seam.config.xml.bootstrap.XmlConfigExtension] (MSC service
thread 1-10) Adding XML Defined Bean: pl.proinet.seam.mongo.MongoResolver
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira