[java] Maven compile: package does not exist

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.

This question is related to java maven compiler-errors

The answer is


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.


You do not include a <scope> tag in your dependency. If you add it, your dependency becomes something like:

<dependency>
     <groupId>org.openrdf.sesame</groupId>
     <artifactId>sesame-runtime</artifactId>
     <version>2.7.2</version>
     <scope> ... </scope>
</dependency>

The "scope" tag tells maven at which stage of the build your dependency is needed. Examples for the values to put inside are "test", "provided" or "runtime" (omit the quotes in your pom). I do not know your dependency so I cannot tell you what value to choose. Please consult the Maven documentation and the documentation of your dependency.


the issue happened with me, I resolved by removing the scope tag only and built successfully.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to maven

Maven dependencies are failing with a 501 error Why am I getting Unknown error in line 1 of pom.xml? Why am I getting "Received fatal alert: protocol_version" or "peer not authenticated" from Maven Central? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Unable to compile simple Java 10 / Java 11 project with Maven ERROR Source option 1.5 is no longer supported. Use 1.6 or later 'react-scripts' is not recognized as an internal or external command How to create a Java / Maven project that works in Visual Studio Code? "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository Java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException

Examples related to compiler-errors

intellij idea - Error: java: invalid source release 1.9 Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' Deserialize JSON with Jackson into Polymorphic Types - A Complete Example is giving me a compile error Android java.exe finished with non-zero exit value 1 error: expected primary-expression before ')' token (C) What does "collect2: error: ld returned 1 exit status" mean? Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing Maven error :Perhaps you are running on a JRE rather than a JDK? What does a "Cannot find symbol" or "Cannot resolve symbol" error mean? Operator overloading ==, !=, Equals