Checksum validation failed in maven due to PART files with Java 11 - java

Background
I am using Java 11.0.3, Maven 3.6.2 and com.github.seahen.maven-s3-wagon 1.3.1.
I am using an s3 bucket as a maven repository. I have an internal jar artifact called dbclasses. I deploy dbclasses to the s3 maven repository using mvn source:jar deploy.
I have a different maven project called secapps which uses the dbclasses artifact. Here is the relevant configuration related to the s3 bucket and the artifact in the secapps pom file
<repositories>
<repository>
<id>maven.nuvalence.repo.release</id>
<url>s3://ec-appdev-mvn-repo/release</url>
</repository>
<repository>
<id>maven.nuvalence.repo.snapshot</id>
<url>s3://ec-appdev-mvn-repo/snapshot</url>
</repository>
</repositories>
<build>
<extensions>
<extension>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.1</version>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>edu.excelsior</groupId>
<artifactId>dbclasses</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
Issue
Whenever I run a mvn clean package on secapps it throws the following warning
[INFO] Downloading from maven.nuvalence.repo.release: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Logged in - ec-appdev-mvn-repo
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom.sha1
[WARNING] Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773 from maven.nuvalence.repo.release for s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom.sha1
[WARNING] Could not validate integrity of download from s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom: Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773
[WARNING] Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773 from maven.nuvalence.repo.release for s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloaded from maven.nuvalence.repo.release: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom (4.7 kB at 2.8 kB/s)
[INFO] Logged off - ec-appdev-mvn-repo
You'll notice that it says Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773
In other words, the expected checksum is 38790b95f185a41908a1767ae2ad2b5bfe436773, but you've given me blank.
So I looked at the local repository and I see the following
You'll notice the following two things for each file
For the pom and jar files there is an associated .part file
the .part file contains all the data, but the non the actual files are empty
If the .part files are renamed to remove the .partXXXX everything works fine. But for some reason every time I try to build it keeps the .part files and leaves the normal files at 0K
Question
What are these .part files and why are my normal files 0K? How do I resolve this?
Attempts
I have tried many things including
Manually deleting the dependency from my local repository
Redeploying the dependency to s3
Setting checksumPolicy to warning
Setting updatePolicy to always
However, none of these seem to work. Does anyone have a solution for this? All the other dependencies from Maven central pull down fine. None of the dependencies form s3 work

Answer
It looks like maven-s3-wagon doesn't play well with Java 11. I swapped out the maven-s3-wagon wagon for the aws-maven wagon and it resolved my issue
Prior wagon
<extension>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.1</version>
</extension>
New Wagon
<extension>
<groupId>com.github.platform-team</groupId>
<artifactId>aws-maven</artifactId>
<version>6.0.0</version>
</extension>

You can use the latest version of seahen s3 wagon 1.3.3 because the previous versions of seahen wagon doesn't work properly with newest java versions. And also you need to add the suitable dependency to work that wagon properly.
Add following wagon and dependency to pom.xml, delete all the previous builds in m2 as well as github file in m2 and try to reload project. That will resolve issue.
Wagon
<extension>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.3</version>
</extension>
Dependency
<dependency>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.3</version>
</dependency>
For further reference follow these links
https://github.com/seahen/maven-s3-wagonhttps://mvnrepository.com/artifact/com.github.seahen/maven-s3-wagon/1.3.3

Related

Maven dependency version

When doing a mvn clean install -U I am getting:
[ERROR] Failed to execute goal on project xxx-security: Could not resolve dependencies for project xxx:xxx-security:jar:50-SNAPSHOT: Failed to collect dependencies at
xxx:xxx-persistence:jar:50-SNAPSHOT -> org.mybatis:mybatis:jar:${mybatis.version}: Failed to read artifact descriptor for org.mybatis:mybatis:jar:${mybatis.version}: Could not
transfer artifact org.mybatis:mybatis:pom:${mybatis.version} from/to nexus (http://example.net/repository/Standard/): Failed to transfer file: http://example.net/repository/Stan
dard/org/mybatis/mybatis/$%7Bmybatis.version%7D/mybatis-$%7Bmybatis.version%7D.pom. Return code is: 400 , ReasonPhrase:Invalid repository path. -> [Help 1]
What I don't get is why maven is using mybatis.version in the url to get the dependency rather than a version number. I have searched the code and cannot find mybatis.version in there. I did find:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.0.4</version>
</dependency>
So why is maven using mybatis.version rather than 3.0.4?
It looks like your xxx:xxx-persistence:jar:50-SNAPSHOT jar has internal dependency with org.mybatis:mybatis:jar:${mybatis.version}. Provided that you define mybatis.version in your properties.
You can do following:
Execute mvn dependency:tree to check which specific jar has this dependency.
Also define <mybatis.version>3.0.4</mybatis.version> under <properties> section of pom.xml. You can optionally remove <version>3.0.4</version> from your <dependency> section where you defined mybatis dependency.

How can I download Infrequently used dependencies in maven?

Version: maven 3.6.3
I try to put this dependency into pom.xml,but it not auto download
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.11</artifactId>
<version>2.4.3</version>
</dependency>
so i use command line:
mvn dependency:get -DremoteRepositories=http://repo1.maven.org/maven2 -DgroupId=com.datastax.spark -DartifactId=spark-cassandra-connector_2.11 -Dversion=2.4.3 -Dtransitive=false
but it give me couldn't download artifact error log :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Could not transfer artifact com.datastax.spark:spark-cassandra-connector_2.11:jar:2.4.3
Do I need to upgrade remoteRepositories?
Why are some commonly used packages automatically downloaded quickly ? such as guava,commons-lang.
Some new versions are always problematic to rely on for download,Is it no cache in
repository?
How can I download the dependency? Thanks

NoClassDefFoundError when importing Tika 1.13 in Eclipse

I've done the following steps per the tika guide:
Add the tika-core and tika-parser dependencies to the pom.xml of the maven project
Run maven install from eclipse to produce tika-core jar and tika-parser jar
Add tika-core jar and tika-parser jar to my eclipse project build path
And I get this runtime exception when trying to run tika:
Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException
at com.ibm.hrl.ace.pdftotext.TikaExtracter.parse(TikaExtracter.java:33)
at com.ibm.hrl.ace.pdftotext.Main.AllPdfsToText(Main.java:116)
at com.ibm.hrl.ace.pdftotext.Main.main(Main.java:34)
Caused by: java.lang.ClassNotFoundException: org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException
at java.net.URLClassLoader.findClass(URLClassLoader.java:600)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:786)
at java.lang.ClassLoader.loadClass(ClassLoader.java:760)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:326)
at java.lang.ClassLoader.loadClass(ClassLoader.java:741)
... 3 more
As far as I can see, when I build the jars using maven, it does add pdfbox properly... from the build log:
[INFO] Including org.apache.pdfbox:pdfbox:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:fontbox:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:pdfbox-tools:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:pdfbox-debugger:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:jempbox:jar:1.8.12 in the shaded jar.
And here are my maven dependencies:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>1.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-parsers -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.13</version>
</dependency>
</dependencies>
The problem is that if you manually add tika-core and tika-parsers jars in your build path you will not have the transitive dependencies that are listed in their own POM.
So I would suggest to:
Remove the tika-core and tika-parsers version that you have built yourself. Instead you should rely on the versions that are available on central. This will ensure that another one building your project will get the same jar (and not a locally built one)
You have two options
(Option A, use Maven) Do not add manually into Eclipse build path the jars. Rely either or built-in Maven plugin for Eclipse (m2e for instance) or use Eclipse plugin for maven (call mvn eclipse:eclipse to update .classpath and .project).
(Option B, without Maven) If you cannot use Maven for your project, you will have to add not only tika-parsers and tika-core jars, but all (most of) the transitive dependencies needed by these project (including for instance specific library per format [POI for Office, pdfbox for PDF...). You can get a list of the dependencies by typing mvn dependency:list in the folder containing the pom of tika-parsers.

SonarQube "Class Not Found" during Main AST Scan

My setup:
Sonarqube 5.1.1
Sonar-Maven Plugin 2.6 (also tried 2.7 and 3.6)
JDK 1.7.0_51
Example of the error:
16:00:54 [INFO] [23:00:54.219] Sensor JavaSquidSensor
16:00:55 [INFO] [23:00:55.030] Java Main Files AST scan...
16:00:55 [INFO] [23:00:55.030] 1532 source files to be analyzed
16:00:58 [ERROR] [23:00:57.927] Class not found: javax.annotation.Nullable
16:00:58 [ERROR] [23:00:57.928] Class not found: javax.annotation.CheckReturnValue
16:00:58 [ERROR] [23:00:58.114] Class not found: javax.annotation.Nullable
According to this stackoverflow question, javax.annotation should be part of java 1.7 and up. Furthermore, I've tried putting it in the local maven repository but that didnt help.
So where is Sonar trying to find this package? Any help?!?
Update:
I've tried modifying the sonar-maven-plugin to include a dependency on javax.annotation
I've tried putting the dependency in my maven's settings.xml
Upgrading my JDK to 1.8 has not helped.
According to http://docs.oracle.com/javase/7/docs/api/index.html?javax/annotation/package-summary.html the classes you expect are not part of JDK 7.
The classes you're looking for are part of google JSR-305 implementation that was initiated here https://code.google.com/p/jsr-305/source/browse/trunk/ri/src/main/java/javax/annotation/Nullable.java?r=24 and which moved to Findbugs:
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
</dependency>
According to https://jcp.org/en/jsr/detail?id=305 the JSR-305 is finished, but is in dormant status and has not been added to a JDK release yet.
Hope it helps.
To avoid adding SonarQube specific dependencies to your project, define a profile like this:
<profile>
<id>sonarqube</id>
<dependencies>
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</profile>
Then run your sonar analysis with a command like
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar -Psonarqube,sonarqube-dev
The sonarqube-dev profile is defined in my ~/.m2/settings.xml and it just specifies where my development environment SonarQube installation is
<profile>
<id>sonarqube-dev</id>
<properties>
<!-- no direct db connections in new sonar -->
<sonar.host.url>
http://localhost:9000/
</sonar.host.url>
</properties>
</profile>
What is achieved by all this?
sonarqube analysis specific dependencies don't pollute the project unnecessarily
no sonarqube maven plugin defined in pom.xml. Each developer and Jenkins can use whatever sonar plugin and server installation they wish
This is more an addendum to the latest answer:
I see similar problems and adding the google findbugs dependency to the project dependencies helps. Similar problems occured with joda convert like
[ERROR] [20:44:25.247] Class not found: org.joda.convert.ToString
Hence I also added
`<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.8.1</version>
<scope>provided</scope>
</dependency>`
But note, that I set the scope to provided to prevent these new dependencies to be added to a resulting war file.
However, I still wonder why these errors occur since none of the analyzed classes seem to use these annotations?

IllegalAccessError when calling ant script from maven-antrun-plugin

I just updated Maven from 2.0.9 to 2.2.1 and I'm getting the following exception when running a maven build:
INFO] [antrun:run {execution: precompile-jsp}]
[INFO] Executing tasks
default:
jspc:
[mkdir] Created dir: C:\builds\trunk\webapps\vyre_portlets\WEB-INF\jsp_src
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: The following error occurred while executing this line:
C:\unify\trunk\portlets\build-jsps.xml:87: The following error occurred while executing this line:
C:\unify\trunk\portlets\build-jsps.xml:7: java.lang.IllegalAccessError: tried to access method org.apache.tools.ant.launch.Locator.decodeUri(Ljava/lang/String;)Ljava/lang/String; from class org.apache.tools.ant.AntClassLoader
The build-jsps.xml ant script runs the org.apache.jasper.JspC task to precompile JSP in the a webapp that maven is building. This was working fine with Maven 2.0.9.
Google gives a bunch of people asking similar questions, but no answers. Has anyone run into this and knows how to resolve this? Or even just why I'm getting the IllegalAccessError?
try to set ANT dependency for "maven-antrun-plugin" explicitly.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
....
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
</plugin>
Note that there are multiple places where you can find ANT in Maven's public repository:
<groupId>org.apache.ant</groupId>
<groupId>ant</groupId>
(2) is the old one so use (1) instead
In Maven 2.2.x, the versions of many of the plugins have been updated, if you run the build with -X, you'll see what version of the antrun-plugin has been used. If these are different versions, it may be using a different version of org.apache.tools.ant.launch.Locator. Looking at the change history for Locator, the decodeUri method was introduced in Ant 1.7 and has been tweaked a few times, though nothing that would obvioulsy cause the problem.
Can you post a minimal pom and ant configuration that shows the error? this would help diagnose the problem.

Categories