Ya.. if you could open an issue, and even better: attach a testcase that reproduces it.
Thanks! sam On Tue, Jan 18, 2011 at 4:05 AM, jordi <[email protected]> wrote: > Hey there! > > I'm using Guice-rc2 and I found this error using Assisted Inject... but the > strange thing is that only happens when I bootstrap the injector with > Stage.PRODUCTION > > This is what i'm doing: > > public interface Mailer {} > > public class SmtpMailer implements Mailer { > @Inject > public SmtpMailer(@Assisted MailConfig config) { ... } > } > > The module config: > > install(new FactoryModuleBuilder() > .implement(Mailer.class, SmtpMailer.class) > .implement(Mailer.class, Simple.class, SimpleSmtpMailer.class) > .build(MailerFactory.class)); > > And then I'm injecting the MailerFactory to get the instance: > > factory.create(gappsConfig); > > Do you want me to open an issue? > > hth, guice is truly amazing > > jordi > > -- > > Here's the full stacktrace: > > com.google.inject.CreationException: Guice creation errors: > > 1) Error in custom provider, java.lang.IllegalStateException: Cannot use > optimized @Assisted provider outside the scope of the constructor. (This > should never happen. If it does, please report it.) > at com.eventuo.mail.MailerFactory.create(MailerFactory.java:1) > while locating com.eventuo.mail.MailConfig annotated with > @com.google.inject.assistedinject.Assisted(value=) > for parameter 0 at > com.eventuo.mail.SmtpMailer.<init>(SmtpMailer.java:38) > at com.eventuo.mail.MailerFactory.create(MailerFactory.java:1) > while locating com.eventuo.mail.Mailer annotated with interface > com.google.inject.assistedinject.Assisted > at > com.google.inject.assistedinject.FactoryProvider2.initialize(FactoryProvider2.java:538) > at > com.google.inject.assistedinject.FactoryModuleBuilder$1.configure(FactoryModuleBuilder.java:315) > > 1 error > at > com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:416) > at > com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:175) > at > com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109) > at com.google.inject.Guice.createInjector(Guice.java:95) > at com.google.inject.Guice.createInjector(Guice.java:83) > at > com.eventuo.test.GuiceJUnitRunner.createInjector(GuiceJUnitRunner.java:35) > at com.eventuo.test.GuiceJUnitRunner.createTest(GuiceJUnitRunner.java:25) > at > org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:258) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) > at > org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:255) > at > org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) > at org.junit.runners.ParentRunner.run(ParentRunner.java:236) > at > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) > 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.IllegalStateException: Cannot use optimized @Assisted > provider outside the scope of the constructor. (This should never happen. > If it does, please report it.) > at > com.google.inject.assistedinject.FactoryProvider2$ThreadLocalProvider.initialValue(FactoryProvider2.java:675) > at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:141) > at java.lang.ThreadLocal.get(ThreadLocal.java:131) > at > com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40) > at > com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38) > at > com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62) > at > com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84) > at > com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254) > at > com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46) > at > com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1021) > at > com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) > at com.google.inject.Scopes$1$1.get(Scopes.java:65) > at > com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40) > at > com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:204) > at > com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:198) > at > com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1021) > at > com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:198) > at > com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:179) > at > com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109) > at > com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:217) > at > com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:224) > at > com.google.inject.assistedinject.FactoryProvider2.getBindingFromNewInjector(FactoryProvider2.java:600) > at > com.google.inject.assistedinject.FactoryProvider2.initialize(FactoryProvider2.java:555) > at > com.google.inject.assistedinject.FactoryProvider2$$FastClassByGuice$$9dcdf6d7.invoke(<generated>) > at > com.google.inject.internal.cglib.reflect.$FastMethod.invoke(FastMethod.java:53) > at > com.google.inject.internal.SingleMethodInjector$1.invoke(SingleMethodInjector.java:56) > at > com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:90) > at > com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110) > at > com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:75) > at > com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:73) > at > com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1014) > at > com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:73) > at > com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:147) > at com.google.inject.internal.Initializer.injectAll(Initializer.java:92) > at > com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:173) > ... 23 more > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
