[jboss-dev] new scanning in AS trunk
Ales Justin
ales.justin at gmail.com
Thu Jun 3 09:26:11 EDT 2010
This is what they use:
static String[] getServiceEntries(String key)
{
List< String > results = null;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
return EMPTY_ARRAY;
}
Enumeration< URL > urls = null;
String serviceName = "META-INF/services/" + key;
try {
urls = loader.getResources(serviceName);
} catch (IOException ioe) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.log(Level.SEVERE,
ioe.toString(),
ioe);
}
}
if (urls != null) {
InputStream input = null;
BufferedReader reader = null;
while (urls.hasMoreElements()) {
try {
if (results == null) {
results = new ArrayList< String >();
}
URL url = urls.nextElement();
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
input = conn.getInputStream();
if (input != null) {
try {
reader =
new BufferedReader(new InputStreamReader(input,
"UTF-8"));
} catch (Exception e) {
reader =
new BufferedReader(new InputStreamReader(input));
}
for (String line = reader.readLine();
line != null;
line = reader.readLine()) {
results.add(line.trim());
}
}
} catch (Exception e) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.log(Level.SEVERE,
"jsf.spi.provider.cannot_read_service",
new Object[]{serviceName});
LOGGER.log(Level.SEVERE,
e.toString(),
e);
}
} finally {
if (input != null) {
try {
input.close();
} catch (Exception ignored) {
}
}
if (reader != null) {
try {
reader.close();
} catch (Exception ignored) {
}
}
}
}
}
return ((results != null && !results.isEmpty())
? results.toArray(new String[results.size()])
: EMPTY_ARRAY);
}
On Jun 3, 2010, at 3:19 PM, David M. Lloyd wrote:
> The way that ServiceLoader would look it up is as a resource, so if the
> target path is case-insensitive (like a JAR file) then it should work
> regardless of how the case is in the file. On the filesystem it'd be a
> different story though.
>
> That said, it doesn't look like Mojarra is using ServiceLoader (they
> probably want to retain 1.5 compat, at least for now?) so I guess you'd
> have to look at the source, which I don't currently have on hand.
>
> On 06/03/2010 08:08 AM, Stan Silvert wrote:
>> That seemed strange to me too. But I figured that just because it
>> wasn't in the stack trace doesn't mean it was never called. I did
>> verify that the class was loaded shortly before the exception, so
>> Mojarra was referring to it somehow.
>>
>> The lookup file is in jsf.deployer/Mojarra-2.0/jsf-libs/jboss-faces.jar
>>
>>
>> Ales Justin wrote:
>>> I'm just debugging it myself. :-)
>>> But I don't see our JBossAP being used -- see stack trace.
>>>
>>> projects/jboss-jsf-int/trunk/jboss-faces/src/main/resources/
>>> projects/jboss-jsf-int/trunk/jboss-faces/src/main/resources/META-INF/
>>> projects/jboss-jsf-int/trunk/jboss-faces/src/main/resources/META-INF/services/
>>> projects/jboss-jsf-int/trunk/jboss-faces/src/main/resources/META-INF/services/com.sun.faces.spi.annotationprovider
>>>
>>> Shouldn't the last one be AnnotationProvider instead of all low level chars?
>>> btw, in which jar is this services lookup file?
>>>
>>> ------------------
>>>
>>> 14:51:23,395 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] : java.util.zip.ZipException: error in opening zip file
>>> at java.util.zip.ZipFile.open(Native Method) [:1.6.0_20]
>>> at java.util.zip.ZipFile.<init>(ZipFile.java:114) [:1.6.0_20]
>>> at java.util.jar.JarFile.<init>(JarFile.java:135) [:1.6.0_20]
>>> at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:67) [:1.6.0_20]
>>> at sun.net.www.protocol.jar.URLJarFile$1.run(URLJarFile.java:214) [:1.6.0_20]
>>> at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_20]
>>> at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:198) [:1.6.0_20]
>>> at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:50) [:1.6.0_20]
>>> at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70) [:1.6.0_20]
>>> at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:104) [:1.6.0_20]
>>> at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:71) [:1.6.0_20]
>>> at com.sun.faces.config.AnnotationScanner.processClasspath(AnnotationScanner.java:290) [:2.0.2-FCS]
>>> at com.sun.faces.config.AnnotationScanner.getAnnotatedClasses(AnnotationScanner.java:215) [:2.0.2-FCS]
>>> // HERE --- JBP?
>>> at com.sun.faces.config.ConfigManager$AnnotationScanTask.call(ConfigManager.java:765) [:2.0.2-FCS]
>>> at com.sun.faces.config.ConfigManager$AnnotationScanTask.call(ConfigManager.java:736) [:2.0.2-FCS]
>>> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_20]
>>> at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_20]
>>> at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:329) [:2.0.2-FCS]
>>> at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223) [:2.0.2-FCS]
>>> at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:72) [:1.0.0-SNAPSHOT]
>>> at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3409) [:]
>>> at org.apache.catalina.core.StandardContext.start(StandardContext.java:3872) [:]
>>> at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:309) [:6.0.0-SNAPSHOT]
>>> at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:144) [:6.0.0-SNAPSHOT]
>>> at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461) [:6.0.0-SNAPSHOT]
>>> at org.jboss.web.deployers.WebModule.startModule(WebModule.java:116) [:6.0.0-SNAPSHOT]
>>> at org.jboss.web.deployers.WebModule.start(WebModule.java:95) [:6.0.0-SNAPSHOT]
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_20]
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_20]
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_20]
>>> at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_20]
>>> at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) [:6.0.0.Beta5]
>>> at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) [:6.0.0.Beta5]
>>> at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) [:6.0.0.Beta5]
>>> at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271) [:6.0.0.Beta5]
>>> at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670) [:6.0.0.Beta5]
>>> at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206) [:2.2.0.Alpha10]
>>> at $Proxy41.start(Unknown Source) at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:53) [:2.2.0.Alpha10]
>>> at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:41) [:2.2.0.Alpha10]
>>> at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.Alpha10]
>>> at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.Alpha10]
>>> at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.Alpha10]
>>> at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.Alpha10]
>>> at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:301) [:2.2.0.Alpha10]
>>>
>>>
>>>
>>> On Jun 3, 2010, at 2:48 PM, Stan Silvert wrote:
>>>
>>>
>>>> Ales Justin wrote:
>>>>
>>>>> Old bug or something new?
>>>>> Can you please attach the stack trace to the forums.
>>>>>
>>>> Done.
>>>>
>>>> https://community.jboss.org/message/546040#546040
>>>>
>>>>
>>>
>>>
>>
>>
>> _______________________________________________
>> jboss-development mailing list
>> jboss-development at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jboss-development
>
> --
> - DML ☍
> _______________________________________________
> jboss-development mailing list
> jboss-development at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-development/attachments/20100603/f02ab010/attachment.html
More information about the jboss-development
mailing list