maven compile failure, cannot access - java

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".

Related

Scala 2.12: Compile error - type PlainNioFile is not a member of package scala.reflect.io

I'm trying to compile my spark scala application and getting below error. Same code was working fine with scala 2.11 version.
I did look at this solution and tried adding scala-reflect as the dependency but still getting the same error. I do see scala-reflect is added as dependency
Can't import scala.reflect.runtime.universe
Scala version 2.12.10
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.0. Compiling...
/var/folders/92/9c7h444d28x8rtcm91n0r7bc0000gq/T/sbt_97534c54/scala/ZincCompat.scala:19: error: type PlainNioFile is not a member of package scala.reflect.io
type PlainNioFile = scala.reflect.io.PlainNioFile
^
/var/folders/92/9c7h444d28x8rtcm91n0r7bc0000gq/T/sbt_97534c54/scala/ZincCompat.scala:23: error: type mismatch;
found : pf.type (with underlying type scala.ZincCompat.PlainNioFile)
required: ?{def getClass: ?}
val f = pf.getClass.getDeclaredField("nioPath") // it's not val'd in 2.12 :-/
two errors found
[info] Attempting to fetch org.scala-sbt:compiler-bridge_2.12:1.6.0.
[warn] Unrecognized repository Scala Plugin Bundled Repository, ignoring it
[warn] Unrecognized repository Scala Plugin Bundled Repository, ignoring it
[error] (Compile / compileIncremental) Error compiling the sbt component 'compiler-bridge_2.12'

Error while running maven project via Jenkins

I'm getting the following error while trying to build my maven project in Jenkins.
[ERROR] Failed to execute goal com.oracle.adf.plugin:ojmake:12.2.1-0-0:compile (default) on project TestApp: Execution default of goal com.oracle.adf.plugin:ojmake:12.2.1-0-0:compile failed: Unable to load the mojo 'compile' in the plugin 'com.oracle.adf.plugin:ojmake:12.2.1-0-0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: oracle/jdeveloper/deploy/maven/OjmakeMojo : Unsupported major.minor version 52.0
[ERROR] -----------------------------------------------------
[JENKINS] Archiving C:\test\pom.xml to com.test/test/3.7.2/TestApp-3.7.2.pom
[ERROR] realm = plugin>com.oracle.adf.plugin:ojmake:12.2.1-0-0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/maven-repository/com/oracle/adf/plugin/ojmake/12.2.1-0-0/ojmake-12.2.1-0-0.jar
[ERROR] urls[1] = file:/C:/maven-repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
Jenkins version : 2.19.2
Maven version : 3.3.9
jdk version : 1.7.0_79
I'm using maven compiler plugin in my pom.xml file, the target and source set is 1.7. I'm working in Windows Environment. Ensured that the PATH variable is set as required. However, still the Jenkins job fails.
How to overcome this error?
The version number shown describes the version of the JRE the class file is compatible with.
Java SE 8 = 52
Might be you have a dependency that need java 1.8
Refernce - https://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
This seems to be a java mismatch.
Configure you're Jenkins Jobs to use JDK 8.
It can be done under "Manage Jenkins" option or you can make it specific to job under "configure" option inside the jobs.
The issue is resolved by replacing the ojmake.exe with ojmake file in all the pom.xml files in the source code.
JDeveloper provides multiple types of ojmake files, check the type of file with Linux command 'file' and check if it is Linux executable.

bad symbolic reference. A signature in WebUI.class refers to term eclipse in package org which is not available

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

Maven Intellij IDEA failing to gwt compile classes

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.

How to use 51Degrees.Mobi with Maven

I am trying to get 51Degrees.mobi to work with my Maven, JSF and Java project however I am having no luck so far. I have downloaded the 2 jars from http://51degrees.mobi/Support/Documentation/Java.aspx and followed the instructions. I now have a filter which looks like this
import fiftyone.mobile.detection.BaseDeviceInfo;
import fiftyone.mobile.detection.Provider;
import fiftyone.mobile.detection.binary.BinaryException;
import fiftyone.mobile.detection.binary.Reader;
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String s = httpRequest.getHeader("user-agent");
//Create a Provider object
Provider p;
try {
p = Reader.create();
} catch (BinaryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Provider p = Reader.create(PATH_TO_PREMIUM_DATA);
//Read in a HttpServletRequest or User Agent String
BaseDeviceInfo b = p.getDeviceInfo(s);
//Get the value of a property
String result = b.getFirstPropertyValue("IsMobile");
//Check the property value
if(result.equals("True")){
System.out.println("This is mobile");
}
if(result.equals("False")){
System.out.println("This is not mobile");
}
//Before exiting your application, ensure you dispose of the Provide to
//release it's resources such as it's thread pool
p.destroy();
}
Thats throws no errors. From looking online I have found the dependancy I must add to the pom file and I have it as such
<dependency><!-- Start 51Degrees.mobi dependencies -->
<groupId>mobi.51degrees</groupId>
<artifactId>detection</artifactId>
<version>2.1.15.1</version>
</dependency><!-- End 51Degrees.mobi dependencies -->
Again no errors are thrown in the file itself, however when I use mvn clean install in the directory I get the following error
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[18,32] error: package fiftyone.mobile.detection does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[19,32] error: package fiftyone.mobile.detection does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[20,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[21,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[45,4] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[47,7] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[50,11] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[60,4] error: cannot find symbol
[INFO] 8 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.730s
[INFO] Finished at: Wed Nov 14 12:45:35 GMT 2012
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default- compile) on project redirectionportal: Compilation failure: Compilation failure:
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[18,32] error: package fiftyone.mobile.detection does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[19,32] error: package fiftyone.mobile.detection does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[20,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[21,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[45,4] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[47,7] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[50,11] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[60,4] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoFailureException
Anyone have any ideas?
As per the rules, I state that I work for 51Degrees.mobi as a Java developer. I am not sure from looking at the page at this time if you solved your problem? So I thought I would add some more information.
Firstly, If you have two Jar files then you are using 2.1.16.1 not 2.1.15.1, although this should not directly effect your problem I thought I would say for clarity :).
Also, 51Degrees.mobi's version 2.1.16.1 solution was recently made available via the maven central repository, after the current answers were posted. So now all you should have to do is add this dependency to your pom:
<dependency><!-- Start 51Degrees.mobi dependencies -->
<groupId>net.sourceforge.fiftyone-java</groupId>
<artifactId>51Degrees.mobi.detection.core</artifactId>
<version>2.1.16.1</version>
</dependency><!-- End 51Degrees.mobi dependencies -->
If you wished to use our second jar just replace "core" with "webapp".
Make sure you have 51Degrees.mobi in your repository (local or remote). I did a quick search in maven public repository and i cannot find it.
If the jar is in your local folder some where. You can use
mvn install:install-file -Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-Dsources=src.jar] \
[-Djavadoc=apidocs.jar] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=sources] \
[-DgeneratePom=true] \
[-DcreateChecksum=true]
check the link maven install plugin
Try to find the jar in your repository:
The jar should reside here:
~/.m2/repository/mobi/51degrees/detection/2.1.15.1/
If you find it there, check whether it contains the classes under package
fiftyone.mobile.detection
-- Update --
In case you don't find this jar, you can use one of the following options:
Use ''system'' scope dependency - it makes your build platform/environment dependent so I don't recommend it, although its the easiest way.
Use mvn install:install-file so that it will place your jar into your local maven repository. Its much better than the first method, but you still will need to use this command before running maven in each local environment / your local repository gets purged...
Maintain your own maven repository somewhere on server, map the maven to use this repository. This is by far the best approach I'm aware of. The best will be to work with repository proxies like 'Nexus' or 'Artifactory'. In the worst case you can create a repository as a plain file system and make it accessible through web server (like apache).
In this repository you'll be able to store thirdparty jars that don't exist in the public maven repository, your own artifacts, or maybe artifacts which are not free/opensource and therefor can't be maintained in the public maven repo (like commercial software that you can use).
Hope this helps

Categories