FYI - This is how it should look when you reproduce the problem. What's happening in this case is that Forge is starting up just fine in the test, but for some reason the ContainerServiceExtension is not intercepting the service classes deployed in one of the addons.

This makes me think that the system classloader is being scanned properly, but that there is a subtle problem with the module structure defined by AddonModuleLoader that is preventing these classes from being scanned. Either that, or the ModularURLScanner class requires modifications to work within the Surefire environment.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.example.AddonDependencyTest
Starting addon(s) [dependency:main]
Nov 1, 2012 7:12:23 PM org.jboss.weld.bootstrap.WeldBootstrap <clinit>
INFO: WELD-000900 2.0.0 (Alpha3)
Nov 1, 2012 7:12:24 PM org.jboss.weld.bootstrap.WeldBootstrap startContainer
INFO: WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
Nov 1, 2012 7:12:24 PM org.jboss.weld.interceptor.util.InterceptionTypeRegistry <clinit>
WARNING: Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
Nov 1, 2012 7:12:24 PM org.jboss.weld.interceptor.util.InterceptionTypeRegistry <clinit>
WARNING: Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
Starting container [dependency:main]
Services loaded from addon module [dependency:main] - [class org.example.published.PublishedService]
Starting addon(s) [919307ca-cd39-46a6-a641-ff50055f6db2:main]
Nov 1, 2012 7:12:27 PM org.jboss.weld.bootstrap.WeldBootstrap startContainer
INFO: WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
Starting container [919307ca-cd39-46a6-a641-ff50055f6db2:main]
2012-11-01 19:12:27.558:INFO:oejs.Server:jetty-8.1.5.v20120716
2012-11-01 19:12:27.622:INFO:oejs.AbstractConnector:Started SelectChannelConnector@127.0.0.1:4141
Remote test server started.
Exception in thread "919307ca-cd39-46a6-a641-ff50055f6db2:main" org.jboss.forge.container.exception.ContainerException: [Thread - 919307ca-cd39-46a6-a641-ff50055f6db2:main] Error invoking Task within ClassLoader [ModuleClassLoader for Module "919307ca-cd39-46a6-a641-ff50055f6db2:main" from AddonModuleLoader]
    at org.jboss.forge.container.util.ClassLoaders.executeIn(ClassLoaders.java:33)
    at org.jboss.forge.container.AddonRunnable.run(AddonRunnable.java:41)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
    at org.example.consuming.ConsumingService.getMessage(ConsumingService.java:25)
    at org.example.consuming.ConsumingService.postStartup(ConsumingService.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
    at org.jboss.weld.annotated.runtime.InvokableAnnotatedMethod.invokeOnInstance(InvokableAnnotatedMethod.java:82)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:97)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:259)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:246)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:221)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:225)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:129)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:97)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:77)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:70)
    at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:625)
    at org.jboss.forge.container.ContainerControlImpl.start(ContainerControlImpl.java:54)
    at org.jboss.forge.container.ContainerControlImpl.bootstrap(ContainerControlImpl.java:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
    at org.jboss.weld.annotated.runtime.InvokableAnnotatedMethod.invokeOnInstance(InvokableAnnotatedMethod.java:82)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:97)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:259)
    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:246)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:221)
    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:225)
    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:129)
    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:97)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:77)
    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:70)
    at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:625)
    at org.jboss.forge.container.AddonRunnable$1.call(AddonRunnable.java:57)
    at org.jboss.forge.container.util.ClassLoaders.executeIn(ClassLoaders.java:29)
    ... 2 more
Stopping addon(s) [919307ca-cd39-46a6-a641-ff50055f6db2:main]
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.032 sec <<< FAILURE!



On Thu, Nov 1, 2012 at 3:51 PM, Lincoln Baxter, III <lincolnbaxter@gmail.com> wrote:
Hey Everyone!

I've been working on Forge 2.0, and it looks like I've hit a very strange problem that I am having difficulty solving. It involves Surefire Maven Plugin and the Forge Arquillian tests.

The tests work fine in eclipse, because Eclipse launches using a real java classpath, however...

Because of how Surefire handles classloading, Forge is not properly finding classes, booting weld, and loading addons. I've gotten close to a solution a few times, but I've not been able to find the exact concoction that gets things working.

Anyone have experience with this feel like taking a look?

Just check out the Forge 2.0 branch from https://github.com/forge/core, first cd into the maven-far-plugin directory, install it with `mvn clean install`, then return to the main directory and run `mvn clean install`, you should then see the failures I am describing.

Thanks!

--
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."



--
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."