I'm trying to compile my java project with maven, but every time i got this error:
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project tts: Compilation failure: Compilation failure:
[ERROR] /Users/stefano/Programming/git/DyslexoTTS/src/main/java/io/dyslexo/graphics/Tray.java:[3,22] cannot find symbol
[ERROR] symbol: class AboutHandler
[ERROR] location: package com.apple.eawt
On intelliJ I have no issues, why maven does not work?
Here the piece of code:
Application application = Application.getApplication();
application.setAboutHandler(e -> {
//my code
});
I also tried to compile on different platforms like linux and windows, but i got the same error.
How can I fix that?
I also tried to compile on different platforms like linux and windows,
but i got the same error. How can I fix that?
You'll have to add a stub library since those classes aren't available on non-Mac platforms. AppleJavaExtensions is one example. Put it in your compilation classpath, but be sure not to include it in the final product, assuming those classes will be available runtime.
Related
The problem is probably the same as in this question, but the solution offered there has become inapplicable in the last 8 years.
I have an Eclipse RCP project which is in the process of being transformed to use Tycho (version 2.3.0) instead. The project can be run with Eclipse 2019-06 and the custom target platform built for this project.
Then I have set up Tycho with the same target platform (a separate Maven module referencing the same *.target file used by Eclipse).
But then when I run Maven (version 3.6.3) with the usual "clean install" goals, I get this error message:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.3.0:compile (default-compile) on project my.project.module: Compilation failure: Compilation failure:
[ERROR] C:\path\to\a\source\file\in\a\module.java:
[ERROR] /*
[ERROR] ^
[ERROR] The type org.eclipse.swt.widgets.Event cannot be resolved. It is indirectly referenced from required .class files
The target platform specifies the same environment (win32.win32.x86_64) for both Eclipse and Tycho, and both SWT .jar files (org.eclipse.swt_3.111.0.v20190605-1801.jar and org.eclipse.swt.win32.win32.x86_64_3.111.0.v20190605-1801.jar) are in one of the directories making up the target platform.
After adding
jars.extra.classpath = platform:/plugin/org.eclipse.swt.win32.win32.x86_64
to the build.properties file (as recommended here) the problem is gone.
I am developing a Web Service, built on Java 8. I am trying to determine how to overcome a common Maven error, but with a slight twist. Running the mvn install goal works perfectly, without any errors. My web service successfully builds and runs. It is only when trying to perform the site:deploy goal that I run into issues.
I have narrowed down the issue to the JMS 2.0 simplified API. Or more accurately, there is an issue where the streams-aq dependency I am using is not aware of the newer simplified API that was released with JMS 2.0 back in 2013. At least that is what appears to be happening. There is also a potential issue with the version of Spring being used. Regardless, the Spring / JMS dependencies that are imported are not aware of the JMS Context object.
When I try to create a Context object in code there isn't a problem running it. Yet when Maven's site-deploy attempts to compile the underlying dependencies (to build all of the JavaDocs used in the site documentation), I get the following error message:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/{path}/src/main/java/org/name/config/JmsConfigurationComp.java:[75,46] cannot find symbol
symbol: method createContext()
location: interface javax.jms.ConnectionFactory
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.037 s
[INFO] Finished at: 2019-09-16T19:31:17-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.7.1:site (default-site) on project testProject: failed to get report for org.apache.maven.plugins:maven-javadoc-plugin: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project testProject: Compilation failure
[ERROR] /C:/{path}/src/main/java/org/name/config/JmsConfigurationComp.java:[75,46] cannot find symbol
[ERROR] symbol: method createContext()
[ERROR] location: interface javax.jms.ConnectionFactory
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
QUESTION: There should be a way to exclude just the javax.jms.ConnectionFactory class, so that Maven does not try to compile it. I do not need the ConnectionFactory in my JavaDocs. I really don't need any of the JMS API docs in my documentation.
Since the code runs flawlessly, it seems ridiculous to be blocked simply by Maven's inability to build JavaDocs for an external class for which it cannot resolve! Especially when it is a valid method that the Java compiler has no trouble finding! ;-)
I have tried a number of exclude commands in my POM file, but none of them seem to have worked. I don't want to risk swaying any of you fine engineers from offering a solution that you think I have already tried, so I won't waste space here with a list of POM code blocks. If you have ran into an issue similar to this, please take a moment and give any suggestions or examples that worked for you.
I resolved the issue. After reading through this excellent article that identifies an extensive list of causes that would result in the ("Cannot find symbol" compilation error) thrown by Maven, I realized that my attempts to exclude the unlocatable class was not the solution. #khmarbaise communicated a similar sentiment.
I resolved the compilation issue by explicitly defining version 2.0 of the JMS API as a Maven dependency in my project POM file. Previously only JMS 1.1 was resolving.
I erroneously stated that it was there already, but because version 1.1 was being inherited from an internal project that included streams-aq (and subsequently JMS), only version 1.1 of the JMS API was available.
Once JMS version 2.0 was properly defined, Maven was able to find the missing JMS 2.0 methods, and successfully compile the sources into the JavaDocs for the service. It had also been misleading because the Java code had no problem locating the methods in question.
When I try to build my project with Maven 3.5.4 and Java 11.0.2, the build fails with the message:
Compilation failure: Compilation failure: [ERROR]
xx/directory/krb5/KerberosContextSource.java:[38,20] package
sun.security.krb5 is not visible [ERROR] (package sun.security.krb5
is declared in module java.security.jgss, which does not export it to
the unnamed module)
I have read from several sources that it's not necessary to modularise your project to upgrade it to Java 9+.
Why do I still run into this issue which clearly asks me to define a module-info.java? As mentioned here.
How do I get around it?
I try to generate query type classes (e.g. QUser) but got errors...
You can find my source code here: https://github.com/TheNakedMan/remindme.server/
I'am working with IntelliJ IDEA, and it seems like I have working plugin.
Help me, please.
Log message:
/remindme.server/src/main/java/com/qoobico/remindme/server/repository/UserRepository.java
Error:(21, 126) java: cannot find symbol symbol: class QUser
Error:(25, 62) java: cannot find symbol symbol: class QUser
location: interface
com.qoobico.remindme.server.repository.UserRepository
UPDATE:
After LifeCycle->clean and run apt:process in IntelliJ, I have this error:
[ERROR] Failed to execute goal on project com.qoobico.remindme.server:
Could not resolve dependencies for project
com.qoobico.remindme.server:com.qoobico.remindme.server:war:1.0-SNAPSHOT:
Could not find artifact
com.qoobico.remindme.server:com.qoobico.remindme.server:jar:1.0-SNAPSHOT
In your sources you did not import the generated classes, for instance:
import com.qoobico.remindme.server.entity.QUser;
If you want to generate the classes without compile and/or install the package use the maven goal apt:process.
You can use IntelliJ to start such a maven goal, use the Maven Projects window. The window will show you all available goals.
On the commandline you could use the mvn cli, which can be downloaded here.
Hint: the command from the help plugin mvn help:describe -Dplugin=com.mysema.maven:apt-maven-plugin will show you a list of all available apt-maven-plugin goals.
You configured the outputDirectory to: target/generated-sources/java
To let your IDE find that classes, put them into your class path. Some IDEs like IntelliJ will do this automatically for maven projects, because that folder is the default.
I use maven (3.2.1) to build our project. My project depends on some propretiary libraries that we have in local maven repo. Those libraries are declared with provided scope (because we don't need them in distribution). Our dependencies depends, of course, on some other libs, e.g. apache-scxml lib, but our code don't do anything with any class from apache-scxml. And in JDK8u20 we cannot build our system anymore, it fails with exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project <myproject>: Compilation failure
[ERROR] <myclass>.java:[47,45] error: cannot access SCXMLListener
But project builds completely fine with JDK8u5 and JDK8u11.
I tried to find some info and only thing I found is here: https://issues.jboss.org/browse/FORGE-2019
but I don't think its the same, or at least I cannot understand it. Can someone explain to me what can be the reason that it compiles with JDK8u11 and not with u20?