2009/9/10 Josh McDonald <[email protected]> > OK, thanks heaps for the pointers guys. I'll go through my stuff and double > check no package-protected classes are being injected into, and so on. Some > of those links I read but wasn't sure they applied to me as I'm not using > OSGI, and I'm deploying into TC6. I did come across the @Provides > initContext solution but it didn't help in my situation. >
the bridge classloading applies whenever you run inside a container that uses its own custom classloaders (such as OSGi, TC6, etc...) it doesn't actually contain anything specific to OSGi if you want a build with 343 applied you can use: http://peaberry.googlecode.com/svn/trunk/lib/build/guice-2.0-customloader.jar you could also try turning off the bridge classloading completely: "-Dguice.custom.loader=false" Jesse if you're reading, is the 343 patch already in trunk? Since I've got > to check out the source and build it myself to apply a patch either way, I > might as well try using trunk and see how it goes. > 343 is not in yet - I need to iron out a minor detail with Jesse and add some tests > Also wondering if there's some noisy debug logging I can enable that will > help me diagnose *which* of my classes are causing the problems in future? I > hate not being able to solve my own damned mess :) > if you turn on FINE logging then it should tell you whenever it creates the bridge classloaders, as well as any FastClass/Enhancer requests - which should help HTH > -Josh > > 2009/9/10 Stuart McCulloch <[email protected]> > >> 2009/9/9 Jean-Eudes COUIGNOUX <[email protected]> >> >>> Hi, >>> >>> I've the same issue in a previous thread. >>> >>> >>> http://groups.google.com/group/google-guice/browse_thread/thread/462c77c6b07246bd >>> >>> My problem were the line >>> bind(Context.class).to(InitialContext.class); >>> >>> I replace this by >>> >>> @Provides >>> public Context initContext() { >>> try { >>> return new InitialContext(); >>> } catch (NamingException e) { >>> throw new RuntimeException("Unable to initialize >>> context.",e); >>> } >>> } >>> >> >> I think patch 343 would also fix it (and let you keep the original code) >> because InitialContext comes from the system/container classloader >> which is the situation that 343 addresses. >> >> but if you can't use a patched build that's one way to workaround it... >> >> >>> 2009/9/9 Stuart McCulloch <[email protected]> >>> >>>> 2009/9/9 Josh McDonald <[email protected]> >>>> >>>>> Hey guys, >>>>> >>>>> I've recently upgraded an app from Guice 1.0, and I'm getting a >>>>> ClassNotFoundException: com.google.inject.internal.cglib.reflect.FastClass >>>>> which makes no sense, as >>>>> com.google.inject.internal.cglib.reflect.FastClass >>>>> is in guice-2.0.jar :-/ >>>>> >>>>> Any ideas? I've been pulling my hair out for hours :-/ >>>>> >>>> >>>> you might want to see if it works with the following patch: >>>> >>>> http://code.google.com/p/google-guice/issues/detail?id=343 >>>> >>>> for background about the classloading situation see: >>>> >>>> http://code.google.com/p/google-guice/wiki/ClassLoading >>>> http://code.google.com/p/google-guice/wiki/OSGi >>>> >>>> HTH >>>> >>>> >>>>> Code: >>>>> >>>>> public class Bootstrapper extends GuiceServletContextListener { >>>>> >>>>> public static Injector applicationInjector; >>>>> >>>>> @Override >>>>> protected Injector getInjector() { >>>>> >>>>> Injector injector = Guice.createInjector( >>>>> >>>>> PersistenceService.usingJpa() >>>>> .across(UnitOfWork.TRANSACTION) >>>>> .addAccessor(LoginUserFinder.class) >>>>> .addAccessor(PlayerFinder.class) >>>>> .addAccessor(AgentFinder.class) >>>>> .addAccessor(CoachFinder.class) >>>>> .addAccessor(MembershipFinder.class) >>>>> .buildModule(), >>>>> >>>>> FlexModule.buildModule(), >>>>> >>>>> new ServletModule() { >>>>> >>>>> @Override >>>>> protected void configureServlets() { >>>>> >>>>> serve("/upload").with(UploadServlet.class, >>>>> processWith(EntityImageProcessor.class)); >>>>> >>>>> serve("/download/*").with(DownloadServlet.class); >>>>> >>>>> serve("/incoming/*").with(IncomingVideoServlet.class); >>>>> } >>>>> }, >>>>> >>>>> BasketballExpressionsModule.buildModule()); >>>>> >>>>> //Kick start JPA. >>>>> injector.getInstance(PersistenceInitializer.class).start(); >>>>> >>>>> applicationInjector = injector; >>>>> >>>>> return injector; >>>>> } >>>>> >>>>> private Map<String, String> processWith(Class<? extends >>>>> UploadProcessor> processorClass) { >>>>> >>>>> Map<String, String> params = new HashMap<String, String>(); >>>>> params.put("processorClass", processorClass.getName()); >>>>> >>>>> return params; >>>>> } >>>>> } >>>>> >>>>> // ------------------------------------------------------------------- >>>>> >>>>> public class BasketballExpressionsModule extends AbstractModule { >>>>> >>>>> public void configure() { >>>>> >>>>> >>>>> bindConstant().annotatedWith(JpaUnit.class).to("BasketballExpressionsPU"); >>>>> bind(Context.class).to(InitialContext.class); >>>>> >>>>> bind(String.class).annotatedWith(Names.named("uploadFileLocation")).toProvider(JndiIntegration.fromJndi(String.class, >>>>> "java:comp/env/basketballExpressions/uploadFileLocation")); >>>>> >>>>> bind(String.class).annotatedWith(Names.named("incomingVideoLocation")).toProvider(JndiIntegration.fromJndi(String.class, >>>>> "java:comp/env/basketballExpressions/incomingVideoLocation")); >>>>> } >>>>> >>>>> public static BasketballExpressionsModule buildModule() { >>>>> return new BasketballExpressionsModule(); >>>>> } >>>>> } >>>>> >>>>> -- >>>>> "Therefore, send not to know For whom the bell tolls. It tolls for >>>>> thee." >>>>> >>>>> Josh 'G-Funk' McDonald >>>>> - [email protected] >>>>> - http://twitter.com/sophistifunk >>>>> - http://flex.joshmcdonald.info/ >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> Cheers, Stuart >>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> -- >> Cheers, Stuart >> >> >> > > > -- > "Therefore, send not to know For whom the bell tolls. It tolls for thee." > > Josh 'G-Funk' McDonald > - [email protected] > - http://twitter.com/sophistifunk > - http://flex.joshmcdonald.info/ > > > > > -- Cheers, Stuart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
