I have a module whose pom file is:
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>common module</name>
In that artifact (‘common’), I have a package named com.mycompany.common.objects. In the consuming package, my pom file is:
<dependency>
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
When I run mvn install it always complain: package com.mycompany.common.objects does not exist.
I tried explicit importing in the class where the error was:
import com.mycompany.common.objects
No luck. I tried in both the IDE (IntelliJ) and in commandline. Any idea? thanks
asked Mar 5, 2013 at 0:53
While working with IntellijIDEA, generated files can cause this issue. Writing
mvn idea:idea
on IntellijIDEA Maven console to reset those files did the trick for me. Also, see:
Package doesn’t exist error in intelliJ
answered Aug 9, 2020 at 14:53
Onat KorucuOnat Korucu
91411 silver badges13 bronze badges
From your sample, we cannot see any artifact containing the package com.mycompany.common.objects
you are using.
You are adding dependency com.mycompany.Common:common as a POM (and you are declaring the packaging of com.mycompany.Common:common as POM too). If it is actually a JAR artifact that contains the package you need to use, then remove the packaging
from the POM and dependency (which means, using default which is JAR).
answered Mar 5, 2013 at 1:14
Adrian ShumAdrian Shum
38k10 gold badges79 silver badges128 bronze badges
0
For anyone struggling with this and not familiar with java, make sure that the said package exists in your local repository. Maven has a local repository ~/.m2
where the packages are installed for local access, so even if your dependency package is correctly declared as a dependency in pom.xml
and is compiled and exists in your project, if it does not exist in the local repository, the mvn compile
will trigger a "package does not exist"
error.
To fix this:
In the missing package folder, do:
mvn install //--> this will package and install your missing package in the local repo
Then in your project that you wanted to compile:
mvn compile // --> now that the missing package is in the local repo it should work
answered May 18, 2018 at 19:20
elooneeloone
4,2082 gold badges31 silver badges35 bronze badges
1
Please correct me, If I’m wrong. I understand that the common is a POM that defines several dependencies which intents to be used by other modules. The Importing Dependencies may meet your requirement.
For example
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I hope this may help.
answered Mar 5, 2013 at 1:34
Charlee ChitsukCharlee Chitsuk
8,7372 gold badges58 silver badges69 bronze badges
1
I had the same problem recently. Everything in my project was setup correctly with dependencies etc. I tried removing /target dirs but nothing worked.
Finally, I solved it by removing the Module Dependency from my dependent project and then readding the dependency. Not sure what is going on in the background, but some sort of refresh of the classpath must have been made. Perhaps the problem was due to the Maven setup.
Hope it helps someone who reaches this question from a search engine.
answered Apr 19, 2013 at 7:34
H.RabieeH.Rabiee
4,6483 gold badges23 silver badges35 bronze badges
Not sure if there was file corruption or what, but after confirming proper pom configuration I was able to resolve this issue by deleting the jar from my local m2 repository, forcing Maven to download it again when I ran the tests.
answered Jan 2, 2014 at 16:15
eebbeseneebbesen
5,0228 gold badges49 silver badges70 bronze badges
For me the problem was with the sourceDirectory and testSourceDirectory nodes in my pom.xml.
I was using
<sourceDirectory>${basedir}/src/test</sourceDirectory>
<testSourceDirectory>${basedir}/test</testSourceDirectory>
and changed it to
<sourceDirectory>../src/test/java</sourceDirectory>
<testSourceDirectory>../src/test/java</testSourceDirectory>
answered Mar 6, 2017 at 14:42
j4nusj4nus
13 bronze badges
Your IDE (Eclipse in my case) may not distinguish between compile and runtime scope. This means that the IDE will let you use runtime scope dependencies in your code, but maven won’t. In such a such change the dependency scope from runtime to compile.
answered Feb 1 at 14:59
wyttenwytten
2,7501 gold badge21 silver badges37 bronze badges
you need to add the maven-plugin into (each) child module (for compiling main and test source)
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugins>
and then you add the plugin-management into the parent pom, for centralizing the plugin config (version…)
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</pluginManagement>
Then you can add your dependency into the dependent module pom
<dependency>
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
http://www.jouvinio.net/wiki/index.php/Projet_Maven_multi-modules
answered May 5, 2020 at 21:06
I have a module whose pom file is:
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>common module</name>
In that artifact (‘common’), I have a package named com.mycompany.common.objects. In the consuming package, my pom file is:
<dependency>
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
When I run mvn install it always complain: package com.mycompany.common.objects does not exist.
I tried explicit importing in the class where the error was:
import com.mycompany.common.objects
No luck. I tried in both the IDE (IntelliJ) and in commandline. Any idea? thanks
asked Mar 5, 2013 at 0:53
While working with IntellijIDEA, generated files can cause this issue. Writing
mvn idea:idea
on IntellijIDEA Maven console to reset those files did the trick for me. Also, see:
Package doesn’t exist error in intelliJ
answered Aug 9, 2020 at 14:53
Onat KorucuOnat Korucu
91411 silver badges13 bronze badges
From your sample, we cannot see any artifact containing the package com.mycompany.common.objects
you are using.
You are adding dependency com.mycompany.Common:common as a POM (and you are declaring the packaging of com.mycompany.Common:common as POM too). If it is actually a JAR artifact that contains the package you need to use, then remove the packaging
from the POM and dependency (which means, using default which is JAR).
answered Mar 5, 2013 at 1:14
Adrian ShumAdrian Shum
38k10 gold badges79 silver badges128 bronze badges
0
For anyone struggling with this and not familiar with java, make sure that the said package exists in your local repository. Maven has a local repository ~/.m2
where the packages are installed for local access, so even if your dependency package is correctly declared as a dependency in pom.xml
and is compiled and exists in your project, if it does not exist in the local repository, the mvn compile
will trigger a "package does not exist"
error.
To fix this:
In the missing package folder, do:
mvn install //--> this will package and install your missing package in the local repo
Then in your project that you wanted to compile:
mvn compile // --> now that the missing package is in the local repo it should work
answered May 18, 2018 at 19:20
elooneeloone
4,2082 gold badges31 silver badges35 bronze badges
1
Please correct me, If I’m wrong. I understand that the common is a POM that defines several dependencies which intents to be used by other modules. The Importing Dependencies may meet your requirement.
For example
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I hope this may help.
answered Mar 5, 2013 at 1:34
Charlee ChitsukCharlee Chitsuk
8,7372 gold badges58 silver badges69 bronze badges
1
I had the same problem recently. Everything in my project was setup correctly with dependencies etc. I tried removing /target dirs but nothing worked.
Finally, I solved it by removing the Module Dependency from my dependent project and then readding the dependency. Not sure what is going on in the background, but some sort of refresh of the classpath must have been made. Perhaps the problem was due to the Maven setup.
Hope it helps someone who reaches this question from a search engine.
answered Apr 19, 2013 at 7:34
H.RabieeH.Rabiee
4,6483 gold badges23 silver badges35 bronze badges
Not sure if there was file corruption or what, but after confirming proper pom configuration I was able to resolve this issue by deleting the jar from my local m2 repository, forcing Maven to download it again when I ran the tests.
answered Jan 2, 2014 at 16:15
eebbeseneebbesen
5,0228 gold badges49 silver badges70 bronze badges
For me the problem was with the sourceDirectory and testSourceDirectory nodes in my pom.xml.
I was using
<sourceDirectory>${basedir}/src/test</sourceDirectory>
<testSourceDirectory>${basedir}/test</testSourceDirectory>
and changed it to
<sourceDirectory>../src/test/java</sourceDirectory>
<testSourceDirectory>../src/test/java</testSourceDirectory>
answered Mar 6, 2017 at 14:42
j4nusj4nus
13 bronze badges
Your IDE (Eclipse in my case) may not distinguish between compile and runtime scope. This means that the IDE will let you use runtime scope dependencies in your code, but maven won’t. In such a such change the dependency scope from runtime to compile.
answered Feb 1 at 14:59
wyttenwytten
2,7501 gold badge21 silver badges37 bronze badges
you need to add the maven-plugin into (each) child module (for compiling main and test source)
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugins>
and then you add the plugin-management into the parent pom, for centralizing the plugin config (version…)
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</pluginManagement>
Then you can add your dependency into the dependent module pom
<dependency>
<groupId>com.mycompany.Common</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
http://www.jouvinio.net/wiki/index.php/Projet_Maven_multi-modules
answered May 5, 2020 at 21:06
I have a (seemingly) simple maven problem I can not solve. In my POM I have specified a dependency to openrdf-sesame like this:
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime</artifactId>
<version>2.7.2</version>
</dependency>
Running the project from eclipse works well, I can even export a runnable jar file.
Unfortunately, I cant get it to work properly via cmd-line maven.
To build a jar, I have added the following to my pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>foo.bar.Cli</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
The compilation fails with the following errors:
.../PLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../PLDReducer.java:[27,33] package org.openrdf.sail.nativerdf does not exist
.../LowPLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../Cli.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../SchemaBuilder.java:[30,33] package org.openrdf.sail.nativerdf does not exist
.../RepoQuerier.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../PLDReducer.java:[78,44] cannot find symbol
Strangely, as soon as I add the compile plugin to the pom and update project settings, eclipse cant seem to compile anymore as well. I have checked my repository, and all sesame files are in there.
mvn —version gives this output:
Apache Maven 2.2.1 (rdebian-8)
Java version: 1.6.0_27
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.8.0-25-generic" arch: "amd64" Family: "unix"
I see that it seems to point to a jre, but my googling indicated that I would see another error if the compiler itself was not found.
I have pasted the complete POM here, if it is of any help.
Is there anything I am missing? I can’t find any errors in my POM.
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Hi,
I am trying to build a Struts Web Application using Maven. I am getting the following errors when I run mvn compile:
1. package org.apache.struts.action does not exist
2. package org.apache.struts.util does not exist
Also getting the following unrecognised symbol errors:
1. ActionMapping, ActionForm, ActionForward, ActionErrors
2. HttpSevletRequest, HttpServletResponse
3. DynaActionForm
I tried installing the struts.jar file in the local maven repository using the command:
mvn install:install-file -DgroupId=struts -DartifactId=struts -Dversion=1.0 -Dpackaging=jar -Dfile= Path to file.
It gives the following error:
The plugin ‘org.apache.maven.plugins:maven-D-plugin’ does not exist or no valid version could be found.
Please help.
Thanks,
Praneet.
Thanks,
Praneet
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Try to install the jar file with the version that you have mentioned in your POM dependency.
I think these two are mismatching.
Thanks in Advance,
Kousik
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Kousik — that did not work unfortunately.
Do you know what is the latest version of the struts jar file?
Thanks,
Praneet
Thanks,
Praneet
Kousik Majumder
Ranch Hand
Posts: 244
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
I think that hardly matter. What you have used in your project that only matters.
You also need to install servlet API jar. Because your error list also include that one.
Thanks in Advance,
Kousik
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Have managed to install servlet-api.jar successfully.
Its struts.jar that is giving the problem.
Thanks,
Praneet
Thanks,
Praneet
Kousik Majumder
Ranch Hand
Posts: 244
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Give the pom.xml code and full error trace.
Thanks in Advance,
Kousik
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
I tried installing the struts.jar file in the local maven repository using the command:
It already available in the Maven repo. What exact errors do you get? And what does your pom.xml look like?
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Hi,
I downloaded the struts jar from the maven repository and pasted it in my local maven repository.
Pasted the following at the path — D:Documents and Settingspraneet.mirchandani.m2repositorystrutsstruts1.0.2
struts-1.0.2.jar, struts-1.0.2.jar.sha1, struts-1.0.2.pom, struts-1.0.2.pom.sha1.
Then I ran mvn compile. This is the error log I got:
[ERROR] FATAL ERROR
[INFO] ————————————————————————
[INFO] The plugin descriptor for the plugin Plugin [struts:struts] was not found
. Please verify that the plugin JAR D:Documents and Settingspraneet.mirchandan
i.m2repositorystrutsstruts1.0.2struts-1.0.2.jar is intact.
[INFO] ————————————————————————
[INFO] Trace
java.lang.IllegalStateException: The plugin descriptor for the plugin Plugin [st
ruts:struts] was not found. Please verify that the plugin JAR D:Documents and S
ettingspraneet.mirchandani.m2repositorystrutsstruts1.0.2struts-1.0.2.jar
is intact.
at org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginM
anager.java:360)
at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(De
faultPluginManager.java:224)
at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPlug
inManager.java:184)
at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(Def
aultPluginManager.java:1642)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(Defa
ultLifecycleExecutor.java:1540)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindPluginToLifec
ycle(DefaultLifecycleExecutor.java:1503)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycl
eMappings(DefaultLifecycleExecutor.java:1282)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:534)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
0)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
This is the pom.xml file:
Thanks,
Praneet
Thanks,
Praneet
Kousik Majumder
Ranch Hand
Posts: 244
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Remove the last struts plugin:
<plugin>
<groupId>struts</groupId>
<artifactId>struts</artifactId>
<version>1.0.2</version>
</plugin>
Then run again.
Thanks in Advance,
Kousik
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Hi Kousik,
Tried what you suggested. Now it is throwing me some more errors when I run mvn compile:
package org.apache.struts.action does not exist
package org.apache.struts.util does not exist
Unrecognised Symbols
ActionMapping, ActionForm
ActionForward, ActionErrors
DynaActionForm, DispatchAction
Thanks,
Praneet
Thanks,
Praneet
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Hi,
I need to include a jar file I have made in order to build the project.
I think I would need to mention that in my pom.xml, but I dont know how?
I dont think it can be put in the dependency tag or the plug in tag. So where do I put it?
Thanks,
Praneet
Thanks,
Praneet
Kousik Majumder
Ranch Hand
Posts: 244
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
I think you have installed in wrong way.
Run the following command and install again.
I have only changed the groupid.
mvn install:install-file -DgroupId=org.apache.struts -DartifactId=struts -Dversion=1.0 -Dpackaging=jar -Dfile= Path to file
Thanks in Advance,
Kousik
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Hi,
I tried that. It throws the following error:
The plugin ‘org.apache.maven.plugins:maven-D-plugin’ does not exist or no valid version could be found.
Thanks,
Praneet
Thanks,
Praneet
Kousik Majumder
Ranch Hand
Posts: 244
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Sorry . I make the mistake now. make the version 2.0.6 in the command line prompt that I had written.
mvn install:install-file -DgroupId=org.apache.struts -DartifactId=struts -Dversion=2.0.6 -Dpackaging=jar -Dfile= Path to file
Thanks in Advance,
Kousik
Author
Posts: 12617
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Struts 2.0.6?!
To the original poster: please show the *exact* command you’re typing, and put it inside code tags, so we can see where any spaces are. So far it just looksl ike you’re not putting quotes around a path that has spaces in it, which will cause the install to fail.
You can also just *look* in the repository to see if it’s there, and obviously the dependency needs to be in your POM.
To summarize:
— Post the *exact* command you’re using to install, in code tags
— Check to see if it’s already in the repository
— Post the POM dependency you’re using.
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Sorry. Noted for next time.
I had to include a certain jar as a dependency. So I pasted it in the local repository and then ran the command below.
It gave the following error:
The plugin ‘org.apache.maven.plugins:maven-D-plugin’ does not exist or no valid version could be found.
Tried searching a lot for this error, but could not figure out.
Thanks,
Praneet
Thanks,
Praneet
David Newton
Author
Posts: 12617
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Like I said, you’re not quoting a path with a space in it: the computer has no way of knowing that space isn’t delimiting commands. I’d also remove the space after the «-Dfile= «.
And *don’t* put it in the repository manually—put it somewhere easy (like c:), then you don’t have to worry about spaces at all.
Praneet Mirchandani
Ranch Hand
Posts: 46
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Hi
I managed to install the external jar. Thanks David.
But when I ran mvn compile after that, it still threw me errors saying it cannot recognise certain packages which were in the newly installed jar. Any idea why this happened?
Thanks,
Praneet
David Newton
Author
Posts: 12617
posted 12 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
You did it wrong? Your POM dependency is wrong? The jar doesn’t contain the classes you think it does?
Without knowing any details, it’s impossible to help.
Issue
I need to parse a json file in my maven project.
For that I started with a simple import in my java file (App.java)
package com.mycompany.app;
import com.fasterxml.jackson.*;// <-------- HERE
public class App
{
public static void main( String[] args )
{
}
}
Then, I tried to compile the project by using mvn package
but I got an error:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ my-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/my-app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ my-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /tmp/my-app/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /tmp/my-app/src/main/java/com/mycompany/app/App.java:[2,1] package com.fasterxml.jackson does not exist
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.628 s
[INFO] Finished at: 2022-05-10T15:31:39+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project my-app: Compilation failure
[ERROR] /tmp/my-app/src/main/java/com/mycompany/app/App.java:[2,1] package com.fasterxml.jackson does not exist
[ERROR]
[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
Here is how I built my maven project:
- I created my maven project:
mvn -B archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4
- I modified the file App.java (created by the previous command) to match with my file.
- I modified pom.xml in order to add the dependency:
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.2</version>
</dependency>
Do you know how to solve this error?
Solution
I’ve already recently answered a similar question: the problem is that com.fasterxml.jackson
is not a package, there is a folder com/fasterxml/jackson
(see the source), but not a package. In Java, package
is a namespace that contains at least one class. Asterix import imports non-recursively all the classes in the package. So, if you need, let’s say, to use classes JsonParser.java
and JacksonException.java
from the package com.fasterxml.jackson.core
, you may add an asterix import like that: com.fasterxml.jackson.core.*
Answered By — Andrej Istomin
Answer Checked By — David Goodson (JavaFixing Volunteer)
I have a (seemingly) simple maven problem I can not solve. In my POM I have specified a dependency to openrdf-sesame like this:
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime</artifactId>
<version>2.7.2</version>
</dependency>
Running the project from eclipse works well, I can even export a runnable jar file.
Unfortunately, I cant get it to work properly via cmd-line maven.
To build a jar, I have added the following to my pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>foo.bar.Cli</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
The compilation fails with the following errors:
.../PLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../PLDReducer.java:[27,33] package org.openrdf.sail.nativerdf does not exist
.../LowPLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../Cli.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../SchemaBuilder.java:[30,33] package org.openrdf.sail.nativerdf does not exist
.../RepoQuerier.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../PLDReducer.java:[78,44] cannot find symbol
Strangely, as soon as I add the compile plugin to the pom and update project settings, eclipse cant seem to compile anymore as well. I have checked my repository, and all sesame files are in there.
mvn —version gives this output:
Apache Maven 2.2.1 (rdebian-8)
Java version: 1.6.0_27
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.8.0-25-generic" arch: "amd64" Family: "unix"
I see that it seems to point to a jre, but my googling indicated that I would see another error if the compiler itself was not found.
I have pasted the complete POM here, if it is of any help.
Is there anything I am missing? I can’t find any errors in my POM.