I try to complete LTW example from AspectJ Cookbook, but it doesn't work.
I created and compiled Java class:
public class MyClass{
public void foo(int number, String name){
System.out.println("Inside of foo");
}
public static void main(String[] args) {
MyClass myObject = new MyClass();
myObject.foo(1, "Str");
}
}
it works just fine:
c:\TEMP\examples>java MyClass
Inside of foo
Then I created aspect:
public aspect HelloWorld{
pointcut callPointcut(): call(void MyClass.foo(int, String));
before() : callPointcut(){
System.out.println("Hello World from advice");
}
}
compiled it:
c:\TEMP\examples>c:\tools\aspectj1.8\bin\ajc -outjar my.jar HelloWorld.aj
C:\TEMP\examples\HelloWorld.aj:4 [warning] no match for this type name: MyClass [Xlint:invalidAbsoluteTypeName]
pointcut callPointcut(): call(void MyClass.foo(int, String));
^^^^^^^^^
[Xlint:invalidAbsoluteTypeName]
1 warning
And then try to run:
c:\TEMP\examples>java -classpath "C:\tools\aspectj1.8\lib\aspectjweaver.jar" "-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader" -Daj.class.path=. "-Daj.aspect.path=c:\TEMP\examples" MyClass
java.lang.ExceptionInInitializerError
at org.aspectj.weaver.WeaverMessages.<clinit>(WeaverMessages.java:18)
at org.aspectj.weaver.bcel.ClassPathManager.addPath(ClassPathManager.java:81)
at org.aspectj.weaver.bcel.ClassPathManager.<init>(ClassPathManager.java:63)
at org.aspectj.weaver.bcel.BcelWorld.<init>(BcelWorld.java:285)
at org.aspectj.weaver.tools.WeavingAdaptor.init(WeavingAdaptor.java:176)
at org.aspectj.weaver.tools.WeavingAdaptor.<init>(WeavingAdaptor.java:109)
at org.aspectj.weaver.loadtime.WeavingURLClassLoader.<init>(WeavingURLClassLoader.java:75)
at org.aspectj.weaver.loadtime.WeavingURLClassLoader.<init>(WeavingURLClassLoader.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.SystemClassLoaderAction.run(Unknown Source)
at java.lang.SystemClassLoaderAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.ClassLoader.initSystemClassLoader(Unknown Source)
at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
Caused by: java.lang.IllegalStateException: recursive invocation
at java.lang.ClassLoader.initSystemClassLoader(Unknown Source)
at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
at java.util.ServiceLoader.loadInstalled(Unknown Source)
at java.util.ResourceBundle.<clinit>(Unknown Source)
... 17 more
Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
at org.aspectj.weaver.WeaverMessages.<clinit>(WeaverMessages.java:18)
at org.aspectj.weaver.bcel.ClassPathManager.addPath(ClassPathManager.java:81)
at org.aspectj.weaver.bcel.ClassPathManager.<init>(ClassPathManager.java:63)
at org.aspectj.weaver.bcel.BcelWorld.<init>(BcelWorld.java:285)
at org.aspectj.weaver.tools.WeavingAdaptor.init(WeavingAdaptor.java:176)
at org.aspectj.weaver.tools.WeavingAdaptor.<init>(WeavingAdaptor.java:109)
at org.aspectj.weaver.loadtime.WeavingURLClassLoader.<init>(WeavingURLClassLoader.java:75)
at org.aspectj.weaver.loadtime.WeavingURLClassLoader.<init>(WeavingURLClassLoader.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.SystemClassLoaderAction.run(Unknown Source)
at java.lang.SystemClassLoaderAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.ClassLoader.initSystemClassLoader(Unknown Source)
at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
Caused by: java.lang.IllegalStateException: recursive invocation
at java.lang.ClassLoader.initSystemClassLoader(Unknown Source)
at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
at java.util.ServiceLoader.loadInstalled(Unknown Source)
at java.util.ResourceBundle.<clinit>(Unknown Source)
at org.aspectj.weaver.WeaverMessages.<clinit>(WeaverMessages.java:18)
at org.aspectj.weaver.bcel.ClassPathManager.addPath(ClassPathManager.java:81)
at org.aspectj.weaver.bcel.ClassPathManager.<init>(ClassPathManager.java:63)
at org.aspectj.weaver.bcel.BcelWorld.<init>(BcelWorld.java:285)
at org.aspectj.weaver.tools.WeavingAdaptor.init(WeavingAdaptor.java:176)
at org.aspectj.weaver.tools.WeavingAdaptor.<init>(WeavingAdaptor.java:109)
at org.aspectj.weaver.loadtime.WeavingURLClassLoader.<init>(WeavingURLClassLoader.java:75)
at org.aspectj.weaver.loadtime.WeavingURLClassLoader.<init>(WeavingURLClassLoader.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.SystemClassLoaderAction.run(Unknown Source)
at java.lang.SystemClassLoaderAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.ClassLoader.initSystemClassLoader(Unknown Source)
at java.lang.ClassLoader.getSystemClassLoader(Unknown Source)
I try different solutions and exception occurs only if I provide -Daj.aspect.path=c:\TEMP\examples, but as far as I understand it is because weaver will load aspect only of this option is provided. Without this option Java program works without any aspects weaved at load time.
Can you use the javaagent? I feel it is simpler than modifying the class loader:
javac MyClass.java
ajc HelloWorld.java -1.8 -outxml -d out
export CLASSPATH=.:out:$CLASSPATH
java -javaagent:$AJHOME/lib/aspectjweaver.jar MyClass
Hello World from advice
Inside of foo
The -outxml option on the ajc call is what produces the META-INF/aop-ajc.xml file in the out folder, and that is what the agent will look for to turn on weaving. (That xml file will simply list the aspects to 'turn on' and optionally some extra weaver configuration)
Related
While learning and exploring Java 9 from eclipse. I create a simple project in eclipse, Although when I compile the project, it prints the program's expected result but along following exception too.
Could not instrument class mymodule/App: java.lang.IllegalArgumentException
at org.eclipse.jdt.launching.internal.org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.eclipse.jdt.launching.internal.weaving.ClassfileTransformer.transform(ClassfileTransformer.java:25)
at org.eclipse.jdt.launching.internal.javaagent.Premain$1.transform(Premain.java:51)
at java.instrument/java.lang.instrument.ClassFileTransformer.transform(Unknown Source)
at java.instrument/sun.instrument.TransformerManager.transform(Unknown Source)
at java.instrument/sun.instrument.InstrumentationImpl.transform(Unknown Source)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at java.base/sun.launcher.LauncherHelper.loadMainClass(Unknown Source)
at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Java code:
package mymodule;
import java.util.List;
public class App {
public static void main(String[] args) {
List<String> immutables = List.of("Food", "Water", "House");
System.out.println(immutables.get(0));
}
}
module-info.java file
module mymodule {
}
Seems like Eclipse is yet to migrate to ASM_6.0 which is completely Java 9 compatible.
On the other hand you're looking at the stacktrace which is similar to BUG#526383 and you can follow the same for updates.
*When I try to run my TestNG test , I get the below exception . I tried ..project clean and then mvn eclipse:clean , mvn eclipse:eclipse in that order ..also have tried mvn clean install after that ..This error just wont go away . There was no issues in the test and was running fine before I made some changes
org.testng.TestNGException:
Cannot instantiate class com.<class Name>
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:331)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:295)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:118)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:183)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:128)
at org.testng.TestRunner.initMethods(TestRunner.java:416)
at org.testng.TestRunner.init(TestRunner.java:242)
at org.testng.TestRunner.init(TestRunner.java:212)
at org.testng.TestRunner.<init>(TestRunner.java:166)
at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:143)
at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:272)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:587)
at org.testng.SuiteRunner.init(SuiteRunner.java:161)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:114)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1290)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1277)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1131)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
... 21 more
Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.lookup.MapLookup.newMap(I)Ljava/util/HashMap;
at org.apache.logging.log4j.core.lookup.MainMapLookup.<clinit>(MainMapLookup.java:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:53)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:337)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:150)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:358)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:418)
at com.intuit.cg.qa.tto.test.BaseTest.<init>(BaseTest.java:47)
at com.intuit.cg.qa.tto.test.fed.productupsell.ProductUpsellBaseTest.<init>(ProductUpsellBaseTest.java:40)
at com.intuit.cg.qa.tto.test.fed.monetization.Monetization.<init>(Monetization.java:57)
... 26 more
java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at org.testng.remote.strprotocol.BaseMessageSender$ReaderThread.run(BaseMessageSender.java:254)
Periodically we have this problem that prevents an applet to go running, the process javaw.exe seems locked, killing them several times unlock the applet. In the trace file I find this (we have jdk 1.6_35, the applet is used by a j2ee web application):
**server running at port: 50091
basic: unique id: JavaControlPanel
basic: server port at: 49187
basic: getSingleInstanceFilename: C:\Users\amoriconi\AppData\LocalLow\Sun\Java\Deployment\tmp\si\JavaControlPanel-x86_49187
basic: file should be removed: C:\Users\amoriconi\AppData\LocalLow\Sun\Java\Deployment\tmp\si\JavaControlPanel-x86_50091
basic: waiting connection
Exception in thread "main" java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.security.jca.ProviderConfig$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.jca.ProviderConfig.doLoadProvider(Unknown Source)
at sun.security.jca.ProviderConfig.getProvider(Unknown Source)
at sun.security.jca.ProviderList.getProvider(Unknown Source)
at sun.security.jca.ProviderList$ServiceList.tryGet(Unknown Source)
at sun.security.jca.ProviderList$ServiceList.access$200(Unknown Source)
at sun.security.jca.ProviderList$ServiceList$1.hasNext(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.security.SecureRandom.getInstance(Unknown Source)
at java.security.SecureRandom.getDefaultPRNG(Unknown Source)
at java.security.SecureRandom.<init>(Unknown Source)
at com.sun.deploy.services.WPlatformService.getSecureRandom(Unknown Source)
at com.sun.deploy.si.SingleInstanceImpl.getSecureRandom(Unknown Source)
at com.sun.deploy.si.SingleInstanceImpl.access$100(Unknown Source)
at com.sun.deploy.si.SingleInstanceImpl$SingleInstanceServer$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.si.SingleInstanceImpl$SingleInstanceServer.createSingleInstanceFile(Unknown Source)
at com.sun.deploy.si.SingleInstanceImpl$SingleInstanceServer.<init>(Unknown Source)
at com.sun.deploy.si.SingleInstanceImpl.addSingleInstanceListener(Unknown Source)
at com.sun.deploy.panel.ControlPanel.<init>(Unknown Source)
at com.sun.deploy.panel.ControlPanel.main(Unknown Source)
Caused by: java.lang.RuntimeException: java.security.NoSuchAlgorithmException: class configured for SecureRandom(provider: SUN)cannot be found.
at java.security.SecureRandom.getDefaultPRNG(Unknown Source)
at java.security.SecureRandom.<init>(Unknown Source)
at com.sun.crypto.provider.SunJCE.<clinit>(DashoA13*..)
... 28 more
Caused by: java.security.NoSuchAlgorithmException: class configured for SecureRandom(provider: SUN)cannot be found.
at java.security.Provider$Service.getImplClass(Unknown Source)
at java.security.Provider$Service.newInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.security.SecureRandom.getInstance(Unknown Source)
... 31 more
Caused by: java.lang.ClassNotFoundException: com/sun/deploy/security/WSecureRandom
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
... 36 more**
For some reason this problem is originated from an hidden update of java, installing jdk 7u45 and then removing solve for some time the problem.....
I'm going crazy....
This is happening because there are more security checks that have been imposed on applets in the new release of the JRE (7u45-b18).
http://www.oracle.com/technetwork/java/javase/7u45-relnotes-2016950.html#newft
Its good to be on old JRE or implement security related changes.
My application was running fine until I upgraded my jre to 7u40. When my application is initializing, it's doing Logger.getLogger("ClassName"), and I'm getting the following exception.
java.lang.ExceptionInInitializerError
at java.util.logging.Logger.demandLogger(Unknown Source)
at java.util.logging.Logger.getLogger(Unknown Source)
at com.company.Application.Applet.<clinit>(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at java.util.logging.Logger.setParent(Unknown Source)
at java.util.logging.LogManager$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.doSetParent(Unknown Source)
at java.util.logging.LogManager.access$1100(Unknown Source)
at java.util.logging.LogManager$LogNode.walkAndSetParent(Unknown Source)
at java.util.logging.LogManager$LoggerContext.addLocalLogger(Unknown Source)
at java.util.logging.LogManager$LoggerContext.addLocalLogger(Unknown Source)
at java.util.logging.LogManager.addLogger(Unknown Source)
at java.util.logging.LogManager$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.<clinit>(Unknown Source)
The exception is coming from this line:
private static Logger logger = Logger.getLogger(Applet.class.getName());
Could it be because of any sideeffects with fix http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8017174 ?
A workaround is to open the java control center and enable logging. This is a concern since by default "Enable Logging" is unchecked. If I select "Enable Logging", the application starts fine.
This problem seems to be fixed in java7 update 45.
Try to package java.util.logging.* with your app in a JAR, and make sure it's on the classpath. That way it is always available. Also, what does your logging.properties look like?
I'm using Gin 1.5 and GWT 2.4 The project built just fine before I added Gin, but now it doesn't:
[ERROR] [foo] - Generator 'com.google.gwt.inject.rebind.GinjectorGenerator' threw an exception while rebinding 'com.foo.html.client.FooGinjector'
The error is:
20:58:04.252 [ERROR] [foo] Generator 'com.google.gwt.inject.rebind.GinjectorGenerator' threw an exception while rebinding 'com.foo.html.client.FooGinjector'
com.google.inject.internal.ComputationException: java.lang.NoClassDefFoundError: com/google/inject/assistedinject/Assisted
at com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at com.google.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at com.google.inject.internal.FailableCache.get(FailableCache.java:46)
at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:48)
at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:121)
at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:443)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:698)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:630)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:223)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:174)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:704)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:45)
at com.google.inject.internal.BindingProcessor.runCreationListeners(BindingProcessor.java:238)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:143)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:116)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:101)
at com.google.inject.Guice.createInjector(Guice.java:105)
at com.google.inject.Guice.createInjector(Guice.java:90)
at com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:47)
at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.foo.html.client.FooGameHtml.<init>(FooGameHtml.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/google/inject/assistedinject/Assisted
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:232)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:92)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:489)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:696)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:630)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:223)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:174)
at com.google.inject.internal.InjectorImpl.createProviderBinding(InjectorImpl.java:281)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:662)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:630)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:223)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:174)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:704)
at com.google.inject.internal.InjectorImpl.createParameterInjector(InjectorImpl.java:772)
at com.google.inject.internal.InjectorImpl.getParametersInjectors(InjectorImpl.java:760)
at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:55)
at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:27)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
at com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at com.google.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at com.google.inject.internal.FailableCache.get(FailableCache.java:46)
at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:48)
at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:121)
at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:443)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:698)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:630)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:223)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:174)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:704)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:45)
at com.google.inject.internal.BindingProcessor.runCreationListeners(BindingProcessor.java:238)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:143)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:116)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:101)
at com.google.inject.Guice.createInjector(Guice.java:105)
at com.google.inject.Guice.createInjector(Guice.java:90)
at com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:47)
at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.foo.html.client.FooGameHtml.<init>(FooGameHtml.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.google.inject.assistedinject.Assisted
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:232)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:92)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:489)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:696)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:630)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:223)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:174)
at com.google.inject.internal.InjectorImpl.createProviderBinding(InjectorImpl.java:281)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:662)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:630)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:223)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:174)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:704)
at com.google.inject.internal.InjectorImpl.createParameterInjector(InjectorImpl.java:772)
at com.google.inject.internal.InjectorImpl.getParametersInjectors(InjectorImpl.java:760)
at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:55)
at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:27)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
at com.google.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
at com.google.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at com.google.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at com.google.inject.internal.FailableCache.get(FailableCache.java:46)
at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:48)
at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:121)
at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:443)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:698)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:630)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:223)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:174)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:704)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:45)
at com.google.inject.internal.BindingProcessor.runCreationListeners(BindingProcessor.java:238)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:143)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:116)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:101)
at com.google.inject.Guice.createInjector(Guice.java:105)
at com.google.inject.Guice.createInjector(Guice.java:90)
at com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:47)
at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.foo.html.client.FooGameHtml.<init>(FooGameHtml.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
What am I doing wrong? I have guice-assistedinject-snapshot.jar and guice-snapshot.jar on my classpath, in that order.
The line that causes the error is in my entry point class is:
private final FooGinjector injector = GWT.create(FooGinjector.class);
FooGinjector.java:
#GinModules(FooGinModule.class)
public interface FooGinjector extends Ginjector {
EventBus eventBus();
PlaceHistoryHandler historyHandler();
}
I moved the assistedinject jar to be above the other gin jars in the classpath, and it appears to work fine now.
When I first saw this I thought of the obvious module inherits was missing in the gwt.xml
<!-- Other module inherits -->
<inherits name="com.google.gwt.inject.Inject"/>
Since you answered your own question, I thought I'd add in something else I found when converted over to GIN.
I converted the HelloMVP app over to GIN, based on a partial tutorial I found on the web.
What I've found is adding in Activities & Places is where it gets more complicated if you aren't familiar with the guice syntax.
If you go on and try to run your code with places, you will need to know the proper bind syntax in the configure method for your GINModule:
bind(SimplePanel.class).in(Singleton.class);
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
//Notice that the interface must be declared first, then the implementation on the binding.
bind(PlaceHistoryMapper.class).to(AppPlaceHistoryMapper.class).in(Singleton.class);
bind(ActivityMapper.class).to(AppActivityMapper.class).in(Singleton.class);
etc...
This one threw me for a while as I wasn't sure how to declare the singleton here. I don't know if you got past this issue or not.