rachavz / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

Reflections with JBoss 7.1.0.Beta1 #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I'm trying to test reflections with my test ear (containing ejb) project, 
deployed in JBoss 7.1.0.Beta1. First I tried to scan classes in runtime, but to 
no avail. Then I tried the reflection-maven plugin, and it created the 
rest1-ear-1.0.0.ear\rest1-ejb-1.0.0.jar\META-INF\reflections\rest1-ejb-reflectio
ns.xml file.

First problem I ran into was vfs, since JBoss 7 apparently uses vsf prefix, but 
0.9.5 version of reflection uses vsffile prefix. I exported the latest trunk 
version from the svn (0.9.7-SNAPSHOT) and built it, because this noticed this 
was fixed. But now I have a new problem: the ClasspathHelper.java file, method 
forPackage in line 56:

int index = url.toExternalForm().lastIndexOf(encodedResourceName);

url.toExternalForm() does not encode the path (backslashes remain \ ), but 
encodedResourceName is "META-INF%2freflections", so the comparison fails 
always. I changed the line to

int index = url.toExternalForm().lastIndexOf(resourceName);

and now index is > 0, but then the following exception is thrown:

16:28:56,801 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) 
MSC00001: Failed to start service 
jboss.deployment.subunit."rest1-ear-1.0.0.ear"."rest1-ejb-1.0.0.jar".component.J
axRsRegistrator.START: org.jboss.msc.service.StartException in service 
jboss.deployment.subunit."rest1-ear-1.0.0.ear"."rest1-ejb-1.0.0.jar".component.J
axRsRegistrator.START: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_27]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_27]
    at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct 
component instance
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:157)
    at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:79)
    at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:138)
    at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:151)
    at org.jboss.as.ee.component.ComponentStartService.start(ComponentStartService.java:44)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:]
    ... 3 more
Caused by: javax.ejb.EJBException: org.reflections.ReflectionsException: could 
not create Dir using vfsfile from url 
vfs:/C:/java/jboss-as-7.1.0.Beta1/bin/content/rest1-ear-1.0.0.ear/rest1-ejb-1.0.
0.jar/
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:232)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:337)
    at org.jboss.as.ejb3.tx.SingletonLifecycleCMTTxInterceptor.processInvocation(SingletonLifecycleCMTTxInterceptor.java:56)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:155)
    ... 9 more
Caused by: org.reflections.ReflectionsException: could not create Dir using 
vfsfile from url 
vfs:/C:/java/jboss-as-7.1.0.Beta1/bin/content/rest1-ear-1.0.0.ear/rest1-ejb-1.0.
0.jar/
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:98)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:88)
    at org.reflections.vfs.Vfs.findFiles(Vfs.java:119)
    at org.reflections.vfs.Vfs.findFiles(Vfs.java:140)
    at org.reflections.Reflections.collect(Reflections.java:304)
    at org.reflections.Reflections.collect(Reflections.java:291)
    at org.reflections.Reflections.collect(Reflections.java:278)
    at tv.beesmart.rest1.ejb.JaxRsRegistrator.init(JaxRsRegistrator.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_27]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_27]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_27]
    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_27]
    at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:130)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ee.component.interceptors.DependencyInjectionCompleteMarker$1.processInvocation(DependencyInjectionCompleteMarker.java:43)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:73)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:92)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)
    ... 18 more
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: 
C:\java\jboss-as-7.1.0.Beta1\bin\content\rest1-ear-1.0.0.ear\rest1-ejb-1.0.0.jar
 (The system cannot find the path specified)
    at org.reflections.vfs.ZipDir.<init>(ZipDir.java:23)
    at org.reflections.vfs.Vfs$DefaultUrlTypes$4.createDir(Vfs.java:165)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:96)
    ... 44 more
Caused by: java.io.FileNotFoundException: 
C:\java\jboss-as-7.1.0.Beta1\bin\content\rest1-ear-1.0.0.ear\rest1-ejb-1.0.0.jar
 (The system cannot find the path specified)
    at java.util.zip.ZipFile.open(Native Method) [:1.6.0_27]
    at java.util.zip.ZipFile.<init>(ZipFile.java:127) [:1.6.0_27]
    at java.util.zip.ZipFile.<init>(ZipFile.java:88) [:1.6.0_27]
    at org.reflections.vfs.ZipDir.<init>(ZipDir.java:22)
    ... 46 more

Maybe the problem is in the vfs path. I hard deploy ear into 
c:\java\jboss-as-7.1.0.Beta1\standalone\deployments\ folder, but the vfs path 
reads as C:\java\jboss-as-7.1.0.Beta1\bin\content

Are my problems just the fact that reflections are not compatible with JBoss 7 
or am I doing something wrong?

Original issue reported on code.google.com by peter.po...@gmail.com on 5 Dec 2011 at 10:17

GoogleCodeExporter commented 9 years ago
Hi,

i'm facing the same problem and therefore i decided to create a patch. 
Unfortunately release versions are not tagged in svn, so i started from svn 
revision r141 which seems to be the last revision for latest stable version 
0.9.6. This is a quick and dirty solution as it depends on jboss-vfs.jar, but 
it works for me.

Original comment by marcus.l...@googlemail.com on 24 Apr 2012 at 2:24

Attachments:

GoogleCodeExporter commented 9 years ago
thanks for the patched
fixed on 0.9.7-RC1 and trunk. comments?

Original comment by ronm...@gmail.com on 2 May 2012 at 3:53

GoogleCodeExporter commented 9 years ago
Hi, with 0.9.7 - RC1 it works on jetty it fails on Tomcat 7

Reflections ref = new Reflections(new ConfigurationBuilder()
        .setUrls(ClasspathHelper.forWebInfClasses(sc)));
Set<Class<? extends RemoteService>> classes = 
ref.getSubTypesOf(RemoteService.class);

Error: 

2012-05-15 11:20:07 Reflections [ERROR] could not create Vfs.Dir from url. 
ignoring the exception and continuing
org.reflections.ReflectionsException: could not create Vfs.Dir from url, no 
matching UrlType was found 
[jndi:/localhost/GroupWidget-0.0.1/WEB-INF/lib/guice-3.0.jar]
either use fromURL(final URL url, final List<UrlType> urlTypes) or use the 
static setDefaultURLTypes(final List<UrlType> urlTypes) or 
addDefaultURLTypes(UrlType urlType) with your specialized UrlType.
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:109)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:91)
    at org.reflections.Reflections.scan(Reflections.java:215)
    at org.reflections.Reflections.<init>(Reflections.java:107)

...

Original comment by rsallar on 15 May 2012 at 9:27

GoogleCodeExporter commented 9 years ago
rsallar: it does not fail, it just says it could not handle jndi: protocol. 
implement that vfs type or ignore. you probably don't really want to scan that 
jar.

I don't get how forWebInfClasses return urls from web-inf/lib... 

Original comment by ronm...@gmail.com on 15 May 2012 at 12:35

GoogleCodeExporter commented 9 years ago
fixed 0.9.7

Original comment by ronm...@gmail.com on 22 May 2012 at 7:47

GoogleCodeExporter commented 9 years ago
Hi ronm,

today i stumbled upon this issue again. Sorry that i did not answered your 
post, i've missed it somehow. However i did some research and found that the 
0.9.7 release supports vfs_jboss7 as where latest release 0.9.8 seems not. Is 
this correct and if so why this was removed with latest release?

Original comment by marcus.l...@googlemail.com on 16 Oct 2012 at 9:30

GoogleCodeExporter commented 9 years ago
marcus: check out this wiki for information
http://code.google.com/p/reflections/wiki/JBossIntegration
hope that helps

Original comment by ronm...@gmail.com on 16 Oct 2012 at 11:10

GoogleCodeExporter commented 9 years ago
ronm: thanks for the hint. so now i'm able to update to latest release 0.9.8 
here. good job!

Original comment by marcus.l...@googlemail.com on 16 Oct 2012 at 12:08