Why does "sbt assembly" fail with ResolveException for stax-api.jar? - windows-7

While running sbt assembly, the command runs for some time and throws the following error on Windows 7:
[warn] Strategy 'discard' was applied to 4 files
[warn] Strategy 'first' was applied to 199 files
[info] Assembly up to date: C:\spark_\spark-1.0.2\assembly\target\scala-2.10\spark-assembly-1.0.2-hadoop1.0.4.jar
sbt.ResolveException: download failed: javax.xml.stream#stax-api;1.0-2!stax-api.jar
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:217)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:126)
Any ideas on how to solve this?

In the official documentation of Apache Spark there's the section Downloading that says:
If you’d like to build Spark from scratch, visit building Spark with Maven.
where you can find the command that worked fine for me (just two days ago on Mac OS X with Java 8):
mvn -Pyarn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests clean package
p.s. I wish they'd sticked to sbt as the build tool for official releases, though.

running sbt clean before sbt assembly solved the above problem.

Related

Could not find artifact org.apache.pulsar:pulsar-broker:pom:2.12.0-SNAPSHOT in apache.snapshots (https://repository.apache.org/snapshots)

While following the instructions to setup IntelliJ for pulsar development I got the below error
Could not find artifact org.apache.pulsar:pulsar-broker:pom:2.12.0-SNAPSHOT in apache.snapshots (https://repository.apache.org/snapshots)
Digging deeper into the snapshots, I don't see pulsar-broker at 2.12.0 either: https://repository.apache.org/content/groups/snapshots/org/apache/pulsar/pulsar-broker/
Is there some configuration step missing?
Attempted Fix [RESOLVED]
accepted answers steps and fix an issue with SDKMAN to have mvn call Java 17
I tried the command mvn -Pcore-modules,-main clean install -DskipTests -Dspotbugs.skip=true and got the new error below.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project buildtools: Compilation failure
[ERROR] /Users/brandon.hoffman/Projects/pulsar/buildtools/src/main/java/org/apache/pulsar/tests/RetryAnalyzer.java:[30,18] cannot access org.testng.ITestResult
[ERROR] bad class file: /Users/brandon.hoffman/.m2/repository/org/testng/testng/7.7.0/testng-7.7.0.jar(org/testng/ITestResult.class)
[ERROR] class file has wrong version 55.0, should be 52.0
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath.
Running this on the command line will fix that problem:
mvn -Pcore-modules,-main clean install -DskipTests -Dspotbugs.skip=true
You must use Java 17 for compiling the master branch version of Pulsar (requirements).
It's possible that there has been some change in the maven build after the instructions were originally written.
It does not look like the project is currently using the repository.apache.org for nightly snapshots. You should ask your question on the dev#pulsar.apache.org mailing list.
Also we have not yet cut the 2.12 branch. The VOTE for the first release of 2.11.0 just passed the PMC.
(FYI I am an Apache Pulsar PMC Member)

How to fix 'Missing requirement' error in Maven on Windows

I'm trying to build dbeaver and get the following error when running mvn package:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: org.jkiss.dbeaver.slf4j 1.0.0.qualifier
[ERROR] Missing requirement: org.jkiss.dbeaver.slf4j 1.0.0.qualifier requires 'bundle org.slf4j.api 0.0.0' but it could not be found
I'm running on Windows 10 and using apache-maven-3.6.1. The strange thing is that when I try the same steps on Linux it builds without problem.
Update
Possible cause is maven 3.6.1 https://www.eclipse.org/lists/tycho-user/msg08177.html
Original post
The problem here, I presume, is that https://dbeaver.io/eclipse-repo/ p2 site is missing slf4j bundle and Tycho (?) cannot resolve the requirement. I still do not know how to make standalone maven build work, but here is an ugly workaround on how to build Windows binary with Eclipse (and embedded maven).
You can use p2-maven-plugin to build that missing bundle yourself. Instead of setting up a brand new project, you can temporarily modify product\localRepository\pom.xml to have a single artifact like
...
<artifacts>
<artifact><id>org.slf4j:slf4j-api:1.7.26</id></artifact>
</artifacts>
...
Now build that (product\localRepository\) project and start jetty
mvn p2:site
start mvn jetty:start
Now you can add this interim update site (http://localhost:8080/site/) to your Eclipse installation (Help -> Install New Software) and install slf4j. You should already be able to run DBeaver from within Eclipse.
To build a binary, add this interim repo into main pom.xml file, e.g. right after local-contrib one.
<repository>
<id>more</id>
<url>http://localhost:8080/site/</url>
<layout>p2</layout>
</repository>
Then go to Run Configurations -> Maven Build -> dbeaver, enter package goal and tick Skip Tests, click Run and go have some coffee.
As you can see Eclipse uses some sort of embedded maven runtime, so I guess it resolves things differently.
Note that if you are updating your local git repo, you might need to update your Eclipse project big time. I was unable to do it with right clicking on the project -> Configure -> Configure and Detect Nested Projects :( But deleting Eclipse project and nested projects (without deleting underlying files) and re-importing Maven project did the trick for me.
There is also an open issue for this https://github.com/dbeaver/dbeaver/issues/6115 .

Maven Build gets Failed saying Could not assemble p2 repository: Mirroring failed: No repository found at

I have a maven build for building an eclipse plugin which gets hung sporadically during the execution of
--- tycho-p2-repository-plugin:1.1.0:assemble-repository (default-assemble-repository) # com.sample.product ---
Otherwise the build will get failed saying the following error.
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-repository-plugin:1.1.0:assemble-repository (default-assemble-repository) on project p2:Could not assemble p2 repository: Mirroring failed: No repository found at file:/C:/Users/obuli/.m2/repository/.
I am using the following maven goals and options
clean deploy -Dtycho.localArtifacts=ignore
I have searched for this issue and landed on this Bug , It says there was a bug in tycho 0.26.0 But I am currently using Tycho version 1.1.0
Since the issue is very sporadic I could not able to identify the root cause. Please let me what I am missing here.
I intermittently had this problem as well. After running mvn clean and mvn deploy separately once, mvn clean deploy started working as well.
Now I don't seem to be able to recreate the original issue, even using git clean -xfd and deleting all snapshots from the local and remote repository.
I can only guess that there were some leftover files from earlier builds which were not cleaned by mvn clean deploy but by mvn clean, and these leftover files must have broken the build.

addSbtPlugin without scala version

I am trying to use the babel webjar plugin in my project that is built with playframework 2.5, which basically runs sbt to build the project.
When I put
addSbtPlugin("org.webjars" %% "babel" % "6.3.26-1" )
in project/plugins.sbt, I get this error:
[info] Resolving org.webjars#babel;6.3.26-1 ...
[warn] module not found: org.webjars#babel;6.3.26-1
<trying other repositories>
[warn] https://repo1.maven.org/maven2/org/webjars/babel_2.10_0.13/6.3.26-1/babel-6.3.26-1.pom
The pom file is located at http://repo1.maven.org/maven2/org/webjars/babel/6.3.26-1/babel-6.3.26-1.pom. This is almost the address that sbt tried, but sbt added the scala version.
Is there a way to tell sbt to not add the scala version? I tried this version and a single percent sign, and both of them added the scala version.
I am using sbt 0.13.9.

mvn sonar:sonar throws exception while doing Java AST scan

Please note :- My mvn clean install goes successful
but when i do mvn sonar:sonar it throws me
[ERROR] Squid Error occurs when analysing :/junk/test/src/main/java/API/com/API/HelloAPI.java
org.sonar.squid.api.AnalysisException: The source directory does not correspond to the package declaration com.API
at org.sonar.java.ast.visitor.PackageVisitor.checkPhysicalDirectory(PackageVisitor.java:93) [sonar-squid-java-plugin-2.8.jar:na]
at org.sonar.java.ast.visitor.PackageVisitor.createSourcePackage(PackageVisitor.java:75) [sonar-squid-java-plugin-2.8.jar:na]
http://sonar-dev.787459.n3.nabble.com/file/n3324837/squid-test.zip
The message is quite clear: the package declaration is wrong. It should be API.com.API if the source directory is /junk/test/src/main/java (that is the default value in Maven). An alternative is to change the source dir to src/main/java/API.
Could it be that your POM contains this line:
<sourceDirectory>.</sourceDirectory>
If so, changing it to this might help:
<sourceDirectory>src/main/java</sourceDirectory>
Maven doesn't care, but sonar does.
I had the same problem with sonar and a maven project generated by eclipse.
(Found the solution at http://www.digipedia.pl/usenet/thread/13899/13064/ )
I got the same error message after upgrading to a more recent sonar plugin (sonar-maven3-plugin:3.7.1/3.7.3/4.0 running against SonarQube Server 3.5.1) for a source file which worked with 3.6-RC3/3.6.3/3.7.0. Apparently 3.7.1 introduced the issue :-/

Resources