George Gastaldi created FORGE-1105:
--------------------------------------
Summary: ClassCastException with CLAC due to ApplicationScoped
implementations
Key: FORGE-1105
URL:
https://issues.jboss.org/browse/FORGE-1105
Project: Forge
Issue Type: Bug
Components: Furnace (Container)
Affects Versions: 2.0.0.Alpha10
Reporter: George Gastaldi
Fix For: 2.x Future
Having an interface:
{code}
@Exported
public interface ConfigurationFactory
{
/**
* Returns the user configuration. Eg: ~/.forge/config.xml
*/
Configuration getUserConfiguration();
/**
* Wraps the {@link FileResource} as a {@link Configuration} object
*/
Configuration getConfiguration(FileResource<?> configFile);
}
{code}
and an Implementation:
{code}
@ApplicationScoped
public class ConfigurationFactoryImpl implements ConfigurationFactory
{
private Configuration userConfiguration;
@Override
@Produces
@ApplicationScoped
public Configuration getUserConfiguration() throws ConfigurationException
{
if (userConfiguration == null)
{
File userConfigurationFile = new File(OperatingSystemUtils.getUserForgeDir(),
"config.xml");
userConfiguration = getConfiguration(userConfigurationFile);
}
return userConfiguration;
}
@Override
public Configuration getConfiguration(FileResource<?> configFile)
{
return getConfiguration(configFile.getUnderlyingResourceObject());
}
private Configuration getConfiguration(File file)
{
XMLConfiguration globalXml;
try
{
globalXml = new XMLConfiguration(file);
globalXml.setEncoding("UTF-8");
globalXml.setReloadingStrategy(new FileChangedReloadingStrategy());
globalXml.setAutoSave(true);
return new ConfigurationAdapter(globalXml);
}
catch (org.apache.commons.configuration.ConfigurationException e)
{
throw new ConfigurationException(e);
}
}
}
{code}
The following error is thrown when an attempt to @Inject ConfigurationFactory is tried:
{code}
org.jboss.forge.furnace.exception.ContainerException: Failed to get instance of [interface
org.jboss.forge.addon.configuration.ConfigurationFactory] from addon
[org.jboss.forge.addon:configuration,2.0.0-SNAPSHOT +STARTED HC: 1823678636]
at
org.jboss.forge.furnace.container.cdi.services.ExportedInstanceImpl.get(ExportedInstanceImpl.java:97)
at
org.jboss.forge.furnace.container.cdi.services.ExportedInstanceLazyLoader.loadObject(ExportedInstanceLazyLoader.java:72)
at
org.jboss.forge.furnace.container.cdi.services.ExportedInstanceLazyLoader.invoke(ExportedInstanceLazyLoader.java:52)
at
org.jboss.forge.addon.configuration.ConfigurationFactory_$$_javassist_0358fbf4-5f51-4eaa-b7de-123db6644efc.getConfiguration(ConfigurationFactory_$$_javassist_0358fbf4-5f51-4eaa-b7de-123db6644efc.java)
at
org.jboss.forge.addon.configuration.ConfigurationFactoryTest.testConfigurationFactory(ConfigurationFactoryTest.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.jboss.forge.furnace.proxy.ClassLoaderInterceptor$1.call(ClassLoaderInterceptor.java:52)
at org.jboss.forge.furnace.util.ClassLoaders.executeIn(ClassLoaders.java:34)
at
org.jboss.forge.furnace.proxy.ClassLoaderInterceptor.invoke(ClassLoaderInterceptor.java:64)
at
org.jboss.forge.addon.configuration.ConfigurationFactoryTest_$$_javassist_07ab8e6b-c9f6-4380-a1d2-5893bcaf8a54.testConfigurationFactory(ConfigurationFactoryTest_$$_javassist_07ab8e6b-c9f6-4380-a1d2-5893bcaf8a54.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.jboss.forge.arquillian.ForgeTestMethodExecutor.invoke(ForgeTestMethodExecutor.java:128)
at
org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
at
org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
at
org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
at
org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at
org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at
org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at
org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
at
org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)
at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)
at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException:
org.jboss.forge.addon.configuration.ConfigurationFactoryImpl$Proxy$_$$_WeldClientProxy_$$_javassist_354e9dfb-10e9-446c-a8d1-829c0ef69c91
cannot be cast to javassist.util.proxy.ProxyObject
at org.jboss.forge.furnace.proxy.Proxies.enhance(Proxies.java:103)
at
org.jboss.forge.furnace.container.cdi.services.ExportedInstanceImpl$2.call(ExportedInstanceImpl.java:86)
at org.jboss.forge.furnace.util.ClassLoaders.executeIn(ClassLoaders.java:34)
at
org.jboss.forge.furnace.container.cdi.services.ExportedInstanceImpl.get(ExportedInstanceImpl.java:93)
... 92 more
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira