generateSources cannot find JavacTool
See original GitHub issueWhen I have ....generateSources(JavaFileObjects.forSourceString("HelloWorld", "public class HelloWorld { }\n"));
I get an error (see below), this is true even if I use forResource(String)
for a file I used in the source list to ASSERT.about(javaSources()).that(...)
. Everything else works, it seems to be some sort of configuration issue.
ERROR!
java.lang.NoClassDefFoundError: com/sun/tools/javac/api/JavacTool
at com.google.testing.compile.Compilation.parse(Compilation.java:86)
at com.google.testing.compile.JavaSourcesSubject$SuccessfulCompilationBuilder.generatesSources(JavaSourcesSubject.java:255)
at com.imminentmeals.prestige.codegen.TestController.testControllerForPresentationWithProtocol(TestController.java:167)
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:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
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:601)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at $Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.api.JavacTool
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 32 more
Issue Analytics
- State:
- Created 10 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
IntelliJ can't find generated sources when used in same module
When running $ mvn clean compile I see that target/generated-sources/annotions/somepackage/SomeClassFactory is created and the module ...
Read more >"Generate sources and update folders" for maven projects ...
I've never been able to open up projects that have had generated sources and have IDEA find the generated sources automatically - but...
Read more >javac - Java programming language compiler
The javac tool reads class and interface definitions, written in the Java ... By default, only line number and source file information is...
Read more >Can't find definition in generated-sources like vscode #185
I have a big maven project, and there are five modules in it. In my project, one module named "common" is required by...
Read more >JDK-7068451 Regression: javac compiles fixed ... - Bug ID
... fixed sources against previous, not current, version of generated sources ... wrote new content /tmp/X.java:1: error: cannot find symbol package p; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Or this:
testCompile files(org.gradle.internal.jvm.Jvm.current().getToolsJar())
I don’t think Gradle will honor the profiles from the compile-testing POM, so it won’t add the
tools.jar
to the classpath. You should be able to add it using something like: