maven error: cannot find symbol class in a package - java

This is my first time using maven and i'm trying to understand how it works. Therefore i have a small example with two classes in different packages.
package maven.callee ;
public class Callee {
public void callMe() {
System.out.println("Callee says: You called me!");
}
}
And now the Caller class with the main function.
package maven.caller ;
import maven.callee.Callee ;
public class Caller {
public static void main(String [] args) {
Callee callee = new Callee ();
callee.callMe ();
}
}
I know the structure of the src directory is not the same as the standard.
When i run the command mvn package on the pom.xml file i get the following output:
[INFO] Compiling 1 source file to /home/ced/workspaceForOxygene/build/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/ced/workspaceForOxygene/build/src/maven/caller/Caller.java:[2,20] package maven.callee does not exist
[ERROR] /home/ced/workspaceForOxygene/build/src/maven/caller/Caller.java:[6,4] cannot find symbol
symbol: class Callee
location: class maven.caller.Caller
[ERROR] /home/ced/workspaceForOxygene/build/src/maven/caller/Caller.java:[6,24] cannot find symbol
symbol: class Callee
location: class maven.caller.Caller
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.645 s
[INFO] Finished at: 2018-04-24T17:12:36+02:00
[INFO] Final Memory: 13M/158M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project mavenTest: Compilation failure: Compilation failure:
[ERROR] /home/ced/workspaceForOxygene/build/src/maven/caller/Caller.java:[2,20] package maven.callee does not exist
[ERROR] /home/ced/workspaceForOxygene/build/src/maven/caller/Caller.java:[6,4] cannot find symbol
[ERROR] symbol: class Callee
[ERROR] location: class maven.caller.Caller
[ERROR] /home/ced/workspaceForOxygene/build/src/maven/caller/Caller.java:[6,24] cannot find symbol
[ERROR] symbol: class Callee
[ERROR] location: class maven.caller.Caller
[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
Please what happening hier? why can't maven locate that file? hier is my POM file, what i am doing wrong?
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.swt.build</groupId>
<artifactId>mavenTest</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src/maven/caller</sourceDirectory>
<!--specify output directory for binaries -->
<outputDirectory> classes </outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins </groupId>
<artifactId> maven-jar-plugin</artifactId>
<version> 3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath> true </addClasspath>
<mainClass> maven.caller.Caller </mainClass>
</manifest>
</archive>
<!--specify output directory for jar file -->
<outputDirectory>jars</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

maven.callee is missing from compiler path. It should be part of source dir or should be defined as lib dependency. With the current setting, Maven will try to compile the java files only under src/maven/caller.
Change sourceDirectory to src/maven in pom.xml.

Related

How to fix "The import org.apache.poi cannot be resolved"

I want to make use of Apache-POI in my code, but am getting an error message The import org.apache.poi cannot be resolved at the import statement
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
I am a beginner with a freshly set up Visual Studio Code v1.30.2, Maven 3.6.0, Java JRE 1.8.0_201.
I have activated the following extensions:
Debugger for Java, 0.16.0
Java dependency viewer, 0.3.0
Java extension pack, 0.5.0
Java test runner, 0.14.0
Language support for Java (TM), 0.37.0
Maven for Java, 0.14.0
I entered these statements in the pom.xml in the dependency section:
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
I've also tried with other POI versions, e.g. 3.10-FINAL.
I'm too new to Java, Maven and VSCode to be sure I've included all the necessary information to point to a solution. Please help me :)
I've run mvn compile, with this result:
C:\Users\MYUSERNAME\Documents\Java\project2>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< MYNAME.project2:project2 >---------------------
[INFO] Building project2 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # project2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\MYUSERNAME\Documents\Java\project2\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # project2 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\MYUSERNAME\Documents\Java\project2\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[12,1] package org.apache.poi.ss.usermodel does not exist
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[13,37] package org.apache.poi.xssf.usermodel does not exist
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[14,37] package org.apache.poi.xssf.usermodel does not exist
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[46,9] cannot find symbol
symbol: class XSSFWorkbook
location: class MYNAME.project2.App
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[46,45] cannot find symbol
symbol: class XSSFWorkbook
location: class MYNAME.project2.App
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[48,9] cannot find symbol
symbol: class XSSFSheet
location: class MYNAME.project2.App
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[55,13] cannot find symbol
symbol: method setCellValue(java.lang.String)
location: variable cell of type com.google.common.collect.Table.Cell
[INFO] 7 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.549 s
[INFO] Finished at: 2019-01-30T09:41:45+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project project2: Compilation failure: Compilation failure:
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[12,1] package org.apache.poi.ss.usermodel does not exist
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[13,37] package org.apache.poi.xssf.usermodel does not exist
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[14,37] package org.apache.poi.xssf.usermodel does not exist
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[46,9] cannot find symbol
[ERROR] symbol: class XSSFWorkbook
[ERROR] location: class MYNAME.project2.App
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[46,45] cannot find symbol
[ERROR] symbol: class XSSFWorkbook
[ERROR] location: class MYNAME.project2.App
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[48,9] cannot find symbol
[ERROR] symbol: class XSSFSheet
[ERROR] location: class MYNAME.project2.App
[ERROR] /C:/Users/MYUSERNAME/Documents/Java/project2/src/main/java/MYNAME/project2/App.java:[55,13] cannot find symbol
[ERROR] symbol: method setCellValue(java.lang.String)
[ERROR] location: variable cell of type com.google.common.collect.Table.Cell
[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/
I've also pasted the full output of mvn -X compile here
I've pasted my full POM.XML here
In my local folder C:\Users\MYUSERNAME.m2\repository\org\apache there is no subfolder poi.
Thanks all contributors, and especially to #ayZagen (who pointed me towards the pom.xml).
It turns out that I had inserted the dependencies for poi into the dependencies section of
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
rather than into the correct section <project> <dependencies>.
When I moved my dependencies to the correct section, maven downloads POI and that part of the code compiles.
Sorry for taking people's time over a trivial error. Thank you for helping me to find out, and asking the right questions! This was a very positive experience!
As per the error log there are 2 possibilities
Network issue.
Maven is not able to download the jar files from its repository, so there is no POI library at .m2 folder
Solution: Check the network/ Internet.
Files corrupted. This happens if file(s) got corrupted.
Solution: delete the folder org.apache.poi inside .m2 folder. the Right click on project(from Eclipse) --> Maven --> Update project. Then clean & refresh project, then Run command Maven clean install
EDIT
Try moving poi dependencies to the root dependencies tag.
Run mvn compile
The first time you execute this (or any other) command, Maven will
need to download all the plugins and related dependencies it needs to
fulfill the command. From a clean installation of Maven, this can take
quite a while (in the output above, it took almost 4 minutes). If you
execute the command again, Maven will now have what it needs, so it
won't need to download anything new and will be able to execute the
command much more quickly.
Maven: Getting Started

Maven release:prepare cannot commit parent module

I want to make a release with the maven release plugin in two steps:
1. mvn clean release:prepare
2. mvn release:perform
It worked fine the last two releases, but after changing my IDE from intellij to eclipse I am not able to perform a release this way with apache-maven 3.5.3 and eGit 4.9.2.
The general structure of my project is:
parent-dir
-> pom.xml
-> child1-dir
-> pom.xml
-> child2-dir
-> pom.xml
child1 and child2 contain code and packaging to jar, the parent has packaging goal pom.
Configuration of maven-release-plugin in parent pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
The plugin updates all poms with correct version #, committs changes and pushes to the remote repository for both child modules. But for the parent module I get the following error at the end of the log:
[INFO] Reactor Summary:
[INFO]
[INFO] test Parent 0.12-SNAPSHOT ........................ FAILURE [02:46 min]
[INFO] test Child1 ...................................... SUCCESS [ 0.011 s]
[INFO] test Child2 0.12-SNAPSHOT ........................ SUCCESS [ 0.205 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:48 min
[INFO] Finished at: 2018-09-08T12:56:06+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project test-parent: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] git#github.com: Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR]
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
[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
I do not understand why I get this error message after succesfull commiting and pushing the children modules?
You need to add your public key in Github.
For help please refer https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

Java "cannot find symbol" error

I am trying to make an Uber jar in Intellij and have run across this issue with maven shade. I have looked at other solutions but nothing seems to work. My project is to make a plugin for Minecraft, if that helps at all. I run 'mvn package' or 'mvn compile' and it produces the error below.
Error:
C:\Users\luckycosmos\IdeaProjects\discordMC>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< me.cosmicluck:discordMC >-----------------------
[INFO] Building discordMC 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # discordMC ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # discordMC ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 6 source files to C:\Users\luckycosmos\IdeaProjects\discordMC\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/DiscordHandler.java:[1,39] package com.onarandombox.MultiverseCore does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[1,39] package com.onarandombox.MultiverseCore does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/DiscordHandler.java:[19,13] cannot find symbol
symbol: class MultiverseCore
location: class DiscordHandler
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/DiscordHandler.java:[21,43] cannot find symbol
symbol: class MultiverseCore
location: class DiscordHandler
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[12,13] cannot find symbol
symbol: class MultiverseCore
location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[30,12] cannot find symbol
symbol: class MultiverseCore
location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[52,12] cannot find symbol
symbol: class MultiverseCore
location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[1,39] package com.onarandombox.MultiverseCore does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[2,43] package com.onarandombox.MultiverseCore.api does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[3,43] package com.onarandombox.MultiverseCore.api does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[13,13] cannot find symbol
symbol: class MultiverseCore
location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[16,15] cannot find symbol
symbol: class MultiverseCore
location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[21,12] cannot find symbol
symbol: class MVWorldManager
location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[25,50] cannot find symbol
symbol: class MVWorldManager
location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[25,23] cannot find symbol
symbol: class MultiverseWorld
location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[29,49] cannot find symbol
symbol: class MultiverseWorld
location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[33,31] cannot find symbol
symbol: class MultiverseCore
location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[34,21] cannot find symbol
symbol: class MultiverseCore
location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[31,13] cannot find symbol
symbol: class MultiverseWorld
location: class MVManager
[INFO] 19 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.685 s
[INFO] Finished at: 2018-06-23T20:28:39-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project discordMC: Compilation failure: Compilation failure:
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/DiscordHandler.java:[1,39] package com.onarandombox.MultiverseCore does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[1,39] package com.onarandombox.MultiverseCore does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/DiscordHandler.java:[19,13] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class DiscordHandler
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/DiscordHandler.java:[21,43] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class DiscordHandler
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[12,13] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[30,12] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[52,12] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[1,39] package com.onarandombox.MultiverseCore does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[2,43] package com.onarandombox.MultiverseCore.api does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[3,43] package com.onarandombox.MultiverseCore.api does not exist
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[13,13] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[16,15] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[21,12] cannot find symbol
[ERROR] symbol: class MVWorldManager
[ERROR] location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[25,50] cannot find symbol
[ERROR] symbol: class MVWorldManager
[ERROR] location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[25,23] cannot find symbol
[ERROR] symbol: class MultiverseWorld
[ERROR] location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[29,49] cannot find symbol
[ERROR] symbol: class MultiverseWorld
[ERROR] location: class MVManager
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[33,31] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/Main.java:[34,21] cannot find symbol
[ERROR] symbol: class MultiverseCore
[ERROR] location: class Main
[ERROR] /C:/Users/luckycosmos/IdeaProjects/discordMC/src/main/java/MVManager.java:[31,13] cannot find symbol
[ERROR] symbol: class MultiverseWorld
[ERROR] location: class MVManager
[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
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.cosmicluck</groupId>
<artifactId>discordMC</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<!--Spigot API-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Bukkit API-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.6.0_365</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven Shade Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I checked my JDK home, everything is correct. I am confused as to why this is happening, I have never seen this happen before. Hopefully I can get some enlightenment on this.

mvn COMPILATION ERROR : error reading jar error in opening zip file

i have a x-module with those properties:
module-name: x-datamodel
this is a part of the pom.xml
<groupId>com.x.datamodel</groupId>
<artifactId>x</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
i have install the project in a local repository with this command line:
mvn install:install-file -Dfile=/Users/me/Documents/Projects/x-datamodel/target/classes/x-datamodel.jar -DgroupId=com.x.datamodel -DgeneratePom=true -DlocalRepositoryPath=/Users/me/Documents/Projects/me-repository -DcreateChecksum=true -DartifactId=x -Dversion={1.0} -Dpackaging=jar
and added the project in bitbucket.
I try to integrate the module x in another project y.
here a part of the y's pom.xml
<dependency>
<groupId>com.x.datamodel</groupId>
<artifactId>x</artifactId>
<version>${x.version}</version>
</dependency>
<repositories>
<repository>
<id>me-repository</id>
<url>https://bitbucket.org/me/me-repository/src/master</url>
</repository>
</repositories>
i can import some classes of the module x in the project y, but when i build the y project i get this error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[3,32] package com.x.datamodel.model does not exist
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[18,12] cannot find symbol
symbol: class User
location: class com.y.server.serviceImpl.UserServiceImpl
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/security/CustomUserDetailsService.java:[3,32] package com.x.datamodel.model does not exist
[INFO] 16 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:56 min
[INFO] Finished at: 2016-12-28T15:51:05+01:00
[INFO] Final Memory: 29M/209M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project y: Compilation failure: Compilation failure:
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] error reading /Users/me/.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar; error in opening zip file
[ERROR] /Users/me/Documents/Projects/y/src/main/java/com/y/server/serviceImpl/UserServiceImpl.java:[3,32] package com.x.datamodel.model does not exist
[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
after installing the repository i have the library into this path:
.m2/repository/com/x/datamodel/x/1.0/x-1.0.jar
why not:
.m2/repository/com/x-datamodel/x/1.0/x-1.0.jar
I tend to think the file is corrupted. Try deleting it and downloading it again.
Try removing the below lines
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
With :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>

Maven complaints about Joda-Time even though I installed it

Because I want to use ActiveAndroid and ActiveAndroid-Validation I need to use Maven (which I never heard of until yesterday). So I installed maven and then tried to install ActiveAndroid.
I wrote a custom serializer in ActiveAndroid using JodaTime and included a JodaTime jar in the ActiveAndroid libs folder. When I build the project using ant it works perfectly well. Using Maven I first downloaded and installed JodaTime in Maven using mvn clean install from within the JodaTime source folder. Seeing the following lines this was successful:
[INFO] --- maven-install-plugin:2.4:install (default-install) # joda-time ---
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/pom.xml to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.pom
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-javadoc.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-javadoc.jar
[INFO] Installing /Users/kramer65/Downloads/joda-time-2.3/target/joda-time-2.3-sources.jar to /Users/kramer65/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.603s
[INFO] Finished at: Thu Sep 26 13:00:54 CEST 2013
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------
I then tried to install ActiveAndroid using the same mvn clean install from within the ActiveAndroid source folder. This however, resulted in the following errors:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.095s
[INFO] Finished at: Thu Sep 26 13:01:08 CEST 2013
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project activeandroid: Compilation failure: Compilation failure:
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[3,21] package org.joda.time does not exist
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[22,16] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[7,24] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[19,26] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[ERROR] /Users/kramer65/dev/repos/ActiveAndroid/src/com/activeandroid/serializer/JodaDateTimeSerializer.java:[27,28] cannot find symbol
[ERROR] symbol : class DateTime
[ERROR] location: class com.activeandroid.serializer.JodaDateTimeSerializer
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :activeandroid
Does anybody know how I can solve this? All tips are welcome!
==EDIT==
The pom.xml of ActiveAndroid can be found here. I did not change anything in it.
If your IDE does not complain, it means your IDE could build the project.
Then I assume your IDE does not rely on maven to build. I would recommand a stronger integration between maven and your IE.
You are not supposed to manually add the libs to your classpath (in IDE)
Your POM miss the dependency
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
As you have the android-maven-plugin in your build, you need to supply path to the SDK. For this maven plugin, this is done by adding it as property (android.sdk.path) in the properties section of the POM.
So you'll have something like this:
<properties>
<android.sdk.path>your/path/here</android.sdk.path>
</properties>
For quick solution, you can just add this to the POM's properties section. However, local settings like this usually go to settings.xml file in the conf dir inside your maven installation. This will make this property always present no matter what pom you use. Or, if you skip the activeProfiles part, you'll have to invoke maven with that profile enabled - "mvn -pandroidProfile clean install".
<profiles>
<profile>
<id>androidProfile</id>
<properties>
<android.sdk.path>your/path/here</android.sdk.path>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>androidProfile</activeProfile>
</activeProfiles>

Categories