I am getting this strange issue with Maven, Intellij IDEA with GWT compiling. I have this set up and working on my desktop pc but now that I have pulled the changes and loaded the project on my other computer I get this issue:
...snip... \EmailServiceImpl.java C:\Users\Szabolcs\Java\Workspace\ims-project\ims\src\main\java\nz\co\doltech\ims\shared\domains\InjuryType.java -s C:\Users\Szabolcs\Java\Workspace\ims-project\ims\target\generated-sources\annotations -g -nowarn -target 1.7 -source 1.7 -encoding UTF-8
[INFO] Compiling 370 source files to C:\Users\Szabolcs\Java\Workspace\ims-project\ims\target\ims-1.0-SNAPSHOT\WEB-INF\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \Users\Szabolcs\Java\Workspace\ims-project\ims\src\main\java\nz\co\doltech\ims\client\application\investigation\InvestigationPresenter.java:[126,26] error: cannot find symbol
[ERROR] \Users\Szabolcs\Java\Workspace\ims-project\ims\src\main\java\nz\co\doltech\ims\client\application\investigation\InvestigationPresenter.java:[126,40] error: cannot find symbol
[ERROR] \Users\Szabolcs\Java\Workspace\ims-project\ims\src\main\java\nz\co\doltech\ims\client\application\investigation\InvestigationPresenter.java:[123,84] error: type argument MyView is not within bounds of type-variable T
[ERROR] \Users\Szabolcs\Java\Workspace\ims-project\ims\src\main\java\nz\co\doltech\ims\client\application\investigation\InvestigationPresenter.java:[204,11] error: cannot find symbol
[ERROR] \Users\Szabolcs\Java\Workspace\ims-project\ims\src\main\java\nz\co\doltech\ims\client\application\investigation\InvestigationModule.java:[10,2] error: no suitable method found for bindPresenter(Class<InvestigationPresenter>,Class<MyView>,Class<InvestigationView>,Class<MyProxy>)
[INFO] 5 errors
Bigger log trace view: here
File the error points to:
123 public class InvestigationPresenter extends IncidentPresenter<InvestigationPresenter.MyView,
InvestigationPresenter.MyProxy> implements InvestigationViewUiHandlers, ChangeSectionHandler {
126 interface MyView extends IncidentView, HasUiHandlers<InvestigationViewUiHandlers> {
void setupValidation(Map<Integer, SectionTuple> sections);
void flush();
void limited(LimitType type);
... snip ...
InvestigationModule.java
public class InvestigationModule extends AbstractPresenterModule {
#Override
protected void configure() {
bind(InvestigationView.Resources.class).asEagerSingleton();
10 bindPresenter(InvestigationPresenter.class, InvestigationPresenter.MyView.class,
InvestigationView.class, InvestigationPresenter.MyProxy.class);
}
}
This makes no sense. The IDE isn't showing an issue and it shouldn't be... Using the same compiler settings, same JDK same bytecode version etc. How could it work on my other machine but now not on this one that is essentially setup exactly the same?
Javac 1.7
JDK 7
GWT 2.6.1
Maven 3.1.0
I've tried:
invalidating cache and restarting
Deleting Intellij IDEA system directory then reimporting the maven project
Double, triple, quadtruple checking the settings and config
Any help with this issue is appreciated.
While the reason is still mysterious, the problem is linked to the fact that the JAVA compiler has a hard time figuring out the inheritance chain correctly while Eclipse and IntelliJ compilers are being a little bit more generous with what you can compile.
Extracting MyView from InvestigationPresenter will fix your problem.
Related
My project was compiled successfully 3 weeks ago. I'm avoiding to update appcelerator components because certain modules of my project need that specific version.
I'm not update Java (1.8 131) neither the appcelerator cli or sdk since 3 weeks ago. The SDK version i am using is 6.0.2.
I can't undestand why titanium is showing this errors now in the "building Java source files" stage:
[INFO] Building Java source files: /usr/lib/jvm/java-8-oracle/bin/javac "-J-Xmx1024M" "-encoding" "utf8" "-bootclasspath" "/home/user/android-sdk/platforms/android-23/android.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/kroll-v8.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-analytics.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/aps-analytics.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-android.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/jaxen-1.1.1.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/ti-commons-codec-1.3.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/kroll-common.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/titanium.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/android-support-multidex.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-filesystem.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-app.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-ui.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/nineoldandroids-appc-2.4.0.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-media.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-appcompat.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/android-support-v4.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/android-support-v7-appcompat.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-cardview.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/cardview-v7-23.0.1.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-locale.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-network.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-xml.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-map.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-calendar.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-geolocation.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-database.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-accelerometer.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-platform.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-contacts.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-gesture.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/modules/titanium-utils.jar:/home/user/Appcelerator_Studio_Workspace/myproject/modules/android/ti.map/3.1.1/map.jar:/home/user/Appcelerator_Studio_Workspace/myproject/modules/android/ti.map/3.1.1/lib/google-play-services-gcm+maps.jar:/home/user/Appcelerator_Studio_Workspace/myproject/modules/android/ti.imagefactory/3.0.0/imagefactory.jar:/home/user/Appcelerator_Studio_Workspace/myproject/modules/android/ti.goosh/2.0.5/ti.goosh.jar:/home/user/Appcelerator_Studio_Workspace/myproject/modules/android/ti.goosh/2.0.5/lib/gson.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/kroll-apt.jar:/home/user/.titanium/mobilesdk/linux/6.0.2.GA/android/lib/titanium-verify.jar:Manifest.class:R.class:AssetCryptImpl.class:FixioActivity.class:FixioAppInfo.class:FixioApplication.class" "-d" "/home/user/Appcelerator_Studio_Workspace/myproject/build/android/bin/classes" "-proc:none" "-target" "1.6" "-source" "1.6" "#/home/user/Appcelerator_Studio_Workspace/myproject/build/android/java-sources.txt"
[ERROR] Failed to compile Java source files:
[ERROR]
[ERROR] /home/user/Appcelerator_Studio_Workspace/myproject/build/android/gen/es/myproject/AssetCryptImpl.java:44: error: cannot find symbol
[ERROR] Range range = assets.get(path);
[ERROR] ^
[ERROR] symbol: variable assets
[ERROR] location: class AssetCryptImpl
[ERROR] /home/user/Appcelerator_Studio_Workspace/myproject/build/android/gen/es/myproject/AssetCryptImpl.java:48: error: cannot find symbol
[ERROR] return new String(filterDataInRange(assetsBytes, range.offset, range.length));
[ERROR] ^
[ERROR] symbol: variable assetsBytes
[ERROR] location: class AssetCryptImpl
[ERROR] Note: /home/user/Appcelerator_Studio_Workspace/myproject/build/android/gen/es/fixio/AssetCryptImpl.java uses unchecked or unsafe operations.
[ERROR] Note: Recompile with -Xlint:unchecked for details.
[ERROR] 2 errors
Thanks in advance for your help and sorry for my bad English.
UPDATE (2017-07-05):
I found this appcelerator jira with the same problem:
https://jira.appcelerator.org/browse/TIMOB-24895
I'm waiting for a official workarround.
Have you tried cleaning the project directory before compiling? If you're using studio, just go to Project/Clean in the menu and select your project, or you can use the command line tools (http://docs.appcelerator.com/platform/latest/#!/guide/Titanium_CLI_Tasks-section-src-38931164_TitaniumCLITasks-CleanYourBuildFolder)
Apparently the problem is version 4.4.0-81 of my linux kernel (Ubuntu 16.04). At the moment, my solution has been to start up with version 4.4.0-79 in order to compile as usually.
I have a problem. When I compile my app with maven, I'm receiving following error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project myproject-core: Compilation failure
[ERROR]
/home/group/Check/19-01-2017---13-40-59/myproject/src/main/java/repository/dao/documents/FileDAO.java:[213,24]
error: cannot access Comparable
in this line and column there are:
public Integer insertFile(File file) throws Exception {
Properties p = Util.getProperties("prop.properties");
MyFacade.setup(p.getProperty("url).toString(),
Integer.valueOf(p.getProperty("port").toString()).intValue(), p.getProperty("service").toString(),
p.getProperty("user").toString(), p.getProperty("pwd").toString());
final DocumentsFile documentFile = MyFacade.creaFile(p.getProperty("codDoc").toString(), file);
MyFacade.teardown();
return documentFile.getId(); //this is the line 213}
What could be the problem?
Thanks for the response
I had a similar problem ("Cannot access" some interface) due to a misalignment in java version. But I had to update the compiler plugin (to 3.10) to get it to indicate that the class file version was too advanced (java 17) for what I was using in my project (Java 11) instead of just "cannot access".
I have legacy source which uses new FtpClient(), and found that FtpClient is a abstract class in jre1.7. The code is fine for jre1.6 or before.
I am using maven to build my project now. My JAVA_HOME points to jdk1.7, which cause the compilation of my source failure. But it is fine when my JAVA_HOME point to jdk1.6. However, the jdk versioin in my company is 1.7 default, and would not downgrade to version 1.6.
Question: how to make it work to compile my source without change the JAVA_HOME?
Below the concerned build log:
[INFO] Compiling 601 source files to C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\target\classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:[44,9] error: FtpClient is abstract; cannot be instantiated
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:[45,6] error: cannot find symbol
could not parse error message: symbol: method openServer(String)
location: variable aftp of type FtpClient
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:46: error: no suitable method found for login(String,String)
aftp.login(user,psw);
^
could not parse error message: method FtpClient.login(String,char[],String) is not applicable
(actual and formal argument lists differ in length)
method FtpClient.login(String,char[]) is not applicable
(actual argument String cannot be converted to char[] by method invocation conversion)
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:47: error: cannot find symbol
aftp.ascii();
^
could not parse error message: symbol: method ascii()
location: variable aftp of type FtpClient
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:53: error: FtpClient is abstract; cannot be instantiated
aftp = new FtpClient();
^
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:[54,6] error: cannot find symbol
could not parse error message: symbol: method openServer(String,int)
location: variable aftp of type FtpClient
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:55: error: no suitable method found for login(String,String)
aftp.login(user,psw);
^
could not parse error message: method FtpClient.login(String,char[],String) is not applicable
(actual and formal argument lists differ in length)
method FtpClient.login(String,char[]) is not applicable
(actual argument String cannot be converted to char[] by method invocation conversion)
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:56: error: cannot find symbol
aftp.binary();
^
could not parse error message: symbol: method binary()
location: variable aftp of type FtpClient
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:62: error: cannot find symbol
aftp.closeServer();
^
could not parse error message: symbol: method closeServer()
location: variable aftp of type FtpClient
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:127: error: cannot find symbol
aftp.cd(RWFileDir);
^
could not parse error message: symbol: method cd(String)
location: variable aftp of type FtpClient
C:\MyData\Project\A-Trunk\CCA\Online\branches\CCA_TabletAccess_Maven\Common_Source\src\com\hhbb\cca\services\ens\util\FTPCommon.java:128: error: cannot find symbol
TelnetOutputStream outs = aftp.put(filename);
^
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Thu Mar 24 14:12:52 CST 2016
you can try to play with that:
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
You are hitting a common misunderstanding of Java cross-compilation with a special case: you want to use sun.* classes, which have no guarantee to be compatible across Java versions. From official Oracle note
A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.
In your specific case, setting source/target of the Maven Compiler Plugin would not be enough. And in general is really dangerous. The Java compiler only knows about bytecode, not about Java API (the rt.jar file). So compiling using Java 7 compiler would still use the rt.jar of Java 7, which in your case is going to break code for Java 6 (especially because of the sun.* usage).
Check this SO answer for a more in deep explanation on the matter. Check also comments from Stuart Marks from Oracle, if ever you have doubts about its content.
In your specific case, you hence mandatory need a JDK 6 installed, because you need to point to the JDK 6 rt.jar file for Java 6 API, otherwise your code would never compile correctly. For such, you could use the executable option of the Maven Compiler Plugin, to point at a different installation of JDK to use, in conjunction with the fork option.
However, you would have to do the same for test execution as well and in general for any plugin requiring this switch. Hence, a more reliable approach would be to set the JAVA_HOME variable upfront before every build (to point to JDK 6) or to use Maven toolchain and set a JDK to use across a set of Maven plugins. But, again, you need JDK 6 installed in your system, otherwise it would not work.
You may also consider Maven profiles to isolate the different JDK usage. In such a profile, I would also suggest to add the Animal Sniffer Maven Plugin as described in the aforementioned SO answer.
As general consideration, the points above explain the why and how you could fix it temporarily, but your application and build may easily suffer maintenance headaches. A more structured approach is definitely to fix the usage of sun.* package, which is a really bad practice. But, yet again, even then be aware about cross-compilation, it's a tricky topic which is often underestimated.
You can add the maven compiler plugin in the pom.xml file.
https://maven.apache.org/plugins/maven-compiler-plugin/
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Play with different values of source and target here. You should get it.
I am building my spark environment, refering to http://spark.apache.org/docs/latest/building-spark.html#spark-tests-in-maven. But when i use this command: "mvn -Pyarn -Phadoop-2.3 -DskipTests -Phive -Phive-thriftserver clean package", I met some errors.
[error] bad symbolic reference. A signature in WebUI.class refers to term eclipse
[error] in package org which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling WebUI.class.
[error] bad symbolic reference. A signature in WebUI.class refers to term jetty
[error] in value org.eclipse which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling WebUI.class.
[error]
[error] while compiling: /download_wlh/spark-1.6.0/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala
[error] during phase: erasure
[error] library version: version 2.10.5
[error] compiler version: version 2.10.5
There is somebody ask a question which is similar to this. Refering to strange error message: bad symbolic reference. A signature in package.class refers to term apache in package org which is not available
But there are no solutions mentioned.
I ran into the same problem as you trying to make a Spark distribution with Hadoop 2.4 using Java 8 and Scala 2.11.
My original attempt was: ./make-distribution.sh --name hadoop-2.4-custom --tgz -Phadoop-2.4 -Dscala-2.11
This produced the error described in Spark SQL 1.5 build failure
Following the advice from that post, I ran ./dev/change-version-to-2.11.sh and then omitted the -Dscala-2.11 as one of the comments suggested. This yielded your exact error. When I added the scala flag back in, the build passed. In summary, I fixed all my problems with:
./dev/change-version-to-2.11.sh
./make-distribution.sh --name hadoop-2.4-custom --tgz -Phadoop-2.4 -Dscala-2.11
I am getting started with Gradle on a polyglot java/scala project. The java modules are legacy modules built using JDK 1.6 so I decided to have my build environment use the older JDK.
This has a very practical rationale. Code such as the following:
class X{
private int i;
<T extends X> void aMethod(T t){
int it = t.i;
}
}
will compile fine using JDK 1.6 but will break with JDK 1.7 with the following error:
error: i has private access in X
For this reason (although unhappily) I decided to stick to JDK 1.6 (we do have code that looks like that).
Now I created a brand new Gradle project (no dependency/build tool was used before) with two modules:
myApp
|---- common (java module)
|---- someService (depends on common)
| |---- service (scala module)
| |---- api (java client)
and set the java source and target compatibility to 1.6. If I build with gradle everything works fine, i.e., the build runs and the jars get build correctly (both java and scala), without any error.
Now I generated my IntelliJ project files using the 'idea' plugin. IntelliJ loads up the project correctly. Now when I try and build from IntelliJ (Ctrl + F9) I get the following:
Information: Modules "myApp", "someService", "common" were fully rebuilt due to project configuration/dependencies changes
Information: Compilation completed with 4 errors and 44 warnings in 2 sec
Information: 4 errors
Information: 44 warnings
Error: scala: warning: [options] bootstrap class path not set in conjunction with -source 1.6
Error: scala: 1 error
Error: scala: 43 warnings
Warning: scala: Some input files use unchecked or unsafe operations.
Warning: scala: Recompile with -Xlint:unchecked for details.
... (the warnings follow)
error: properties has private access in X
As you can see, I am now getting the JDK 1.7 error (although I'm compiling with 1.6) and the build fails. IntelliJ says there are 4 errors but I believe the root cause is just that one.
Now If I go and fix the code above as follows:
class X{
private int i;
<T extends X> void aMethod(T t){
// SDK 1.7: explicit downcast grants access to base private members
int it = ((X)t).i;
}
}
I get the following error:
scala: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
java.lang.InternalError
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:838)
...
at java.lang.ClassLoader.getBootstrapResource(ClassLoader.java:1305)
...
at sbt.classfile.Analyze$$anonfun$apply$8$$anonfun$sbt$classfile$Analyze$$anonfun$$processDependency$1$1.apply$mcV$sp(Analyze.scala:49)
...
at scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:153)
...
at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:44)
at org.jetbrains.jps.incremental.scala.local.CompilerImpl.compile(CompilerImpl.scala:63)
...
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
at java.lang.reflect.Method.invoke(Method.java:606)
at com.martiansoftware.nailgun.NGSession.run(Unknown Source)
Caused by: java.io.FileNotFoundException: /usr/lib/jvm/java-7-oracle/jre/lib/resources.jar
...
which I believe is caused by the fact that I uninstalled JDK 1.7 and installed JDK 1.6 and somewhere in the IntelliJ paths something is still pointing at the old JDK.
So I have two questions:
1. How to get rid of any reference to JDK 1.7 in IntelliJ?
2. How to get rid of the first error altogether without changing the code? I know this is possible because Gradle does it successfully.
Silly me! I had uninstalled JDK 7 without restarting IntelliJ so it was still pointing to some of the JDK 7 folders. This was a very odd experience!