Brandon S.
Brandon S.

Reputation: 306

Maven: mvn compile failure. "package does not exist". Dependency included in maven, Other SO Solutions Not Working. What am I missing?

I know that there are a lot of other SO answers on this topic, and although this question seems to have been the most useful, none of those solutions have led me to a complete resolution of my problem. So I could use a bit more help.

I have a Netbeans project created by someone who worked at my company before me, that has never been built with Maven, and I have haven't fully dived into the source of the project yet. However, because the number of dependencies for the project seemed overwhelming to me, I decided that I needed to figure out a management solution. This led me to Maven, and then indirectly to Apache Archiva.

So I set up an Archiva repository and uploaded all of the dependencies needed by the project. All of these artifacts are JAR files. I then created a pom.xml file in the preexisting project directory and tweaked the build settings to match the project. Now the project directory looks like this:

ProjectStructure and Import Error In Source Code

In the above screenshot, you can also see the error on line 12. This error says "package.imgscalr does not exist" this is later echoed by mvn compile.

The full project POM looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!--LISCENSE HEADER-->
    <project>
        <groupId>com.glsarchives</groupId>
        <artifactId>GLSLib</artifactId>
        <version>1.0</version>
        <modelVersion>4.0.0</modelVersion>
        <packaging>jar</packaging>
        <dependencies>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.1</version>
            </dependency>
            <dependency>
                <groupId>at.unbounded</groupId>
                <artifactId>serialization.jar</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>cecore</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>celib</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>ceplugins</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>cereports</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>cesession</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>ceutils</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>corbaidl</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>ebus405</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>MetafileRenderer</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>rasapp</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>com.businessobjects.sdk</groupId>
                <artifactId>rascore</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
            <dependency>
                <groupId>org.dspace.xmlui.concurrent</groupId>
                <artifactId>Concurrent</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>eclipselink</artifactId>
                <version>2.5.2</version>
            </dependency>
            <dependency>
                <groupId>org.imgscalr</groupId>
                <artifactId>imgscalr-lib</artifactId>
                <version>4.2</version>
            </dependency>
            <dependency>
                <groupId>org.lucee</groupId>
                <artifactId>commons-logging</artifactId>
                <version>1.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.lucee</groupId>
                <artifactId>xml-apis</artifactId>
                <version>0.0</version>
            </dependency>
            <dependency>
              <groupId>org.eclipse.persistence</groupId>
              <artifactId>javax.persistence</artifactId>
              <version>0.0</version>
            </dependency>
            <dependency>
              <groupId>org.netbeans.lib</groupId>
              <artifactId>awtextra</artifactId>
              <version>0.0</version>
              <scope>compile</scope>
            </dependency>
            <dependency>
              <groupId>org.netbeans.external</groupId>
              <artifactId>AbsoluteLayout</artifactId>
              <version>0.0</version>
            </dependency>
        </dependencies>

        <build>
            <sourceDirectory>./src</sourceDirectory>
            <finalName>GLSLib</finalName>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>

        <repositories>
            <repository>
              <id>GLS-Java-Repo</id>
              <name>Java Repository</name>
              <url>http://archiva:8080/repository/GLS-Java-Repo/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>
          </repositories>
          <pluginRepositories>
              <pluginRepository>
                  <id>GLS-Java-Repo</id>
                  <name>Java Repository</name>
                  <url>http://archiva:8080/repository/GLS-Java-Repo/</url>
                  <releases>
                      <enabled>true</enabled>
                  </releases>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
              </pluginRepository>
          </pluginRepositories>
    </project>

When I run mvn compile -X, I get the following output:

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GLSLib 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ GLSLib ---

[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\GLS_DEVELOPER\GLS_Projects\GLS_Lib
\Repositories\GIT\GLS-Lib_PR_Repo\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ GLSLib ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 91 source files to C:\GLS_DEVELOPER\GLS_Projects\GLS_Lib\Reposi
tories\GIT\GLS-Lib_PR_Repo\target\classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Rep
o/src/gls/ui/emp/EmpComboBoxPanel.java: Some input files use unchecked or unsafe
 operations.
[WARNING] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Rep
o/src/gls/ui/emp/EmpComboBoxPanel.java: Recompile with -Xlint:unchecked for deta
ils.
[INFO] 2 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Repo/
src/gls/image/ImagePanel.java:[12,20] package org.imgscalr does not exist
[ERROR] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Repo/
src/gls/image/ImagePanel.java:[106,18] cannot find symbol
  symbol:   variable Scalr
  location: class gls.image.ImagePanel
[ERROR] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Repo/
src/gls/image/ImagePanel.java:[128,18] cannot find symbol
  symbol:   variable Scalr
  location: class gls.image.ImagePanel
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.154 s
[INFO] Finished at: 2016-09-14T12:31:34-04:00
[INFO] Final Memory: 17M/321M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project GLSLib: Compilation failure: Compilation
failure:
[ERROR] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Repo/
src/gls/image/ImagePanel.java:[12,20] package org.imgscalr does not exist
[ERROR] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Repo/
src/gls/image/ImagePanel.java:[106,18] cannot find symbol
[ERROR] symbol:   variable Scalr
[ERROR] location: class gls.image.ImagePanel
[ERROR] /C:/GLS_DEVELOPER/GLS_Projects/GLS_Lib/Repositories/GIT/GLS-Lib_PR_Repo/
src/gls/image/ImagePanel.java:[128,18] cannot find symbol
[ERROR] symbol:   variable Scalr
[ERROR] location: class gls.image.ImagePanel
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on p
roject GLSLib: Compilation failure
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThre
adedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compila
tion failure
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(Abstrac
tCompilerMojo.java:858)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.ja
va:129)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:207)
        ... 20 more
[ERROR]
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption

So, the obvious problem is that maven can't seem to find the org.imgscalr package. But, none of my dependencies were overwritten or removed--based on the dependency tree produced by mvn dependency:tree -Dverbose, including the imgscalr-lib dependency (This is a JAR which contains the org.imgscalr package and META-INF).

Suspecting corruption, I deleted the imgscaler-lib folder in the local repository--and then the entire repository--neither of these worked. Upon compiling, Maven reacquired all of the files from my Archiva repository, but the problem persists.

I have checked mvn help:effective-pom, and it seems to match my pom.xml.

I have also tried running mvn dependency:copy-dependencies as suggested in the linked question, and all of my libraries are successfully copied into the target directory, including the library in question: org.imgscalr

What am I missing here?

edit: Updated pom.xml to add repository information

edit: The reason I have very weird version numbers in my pom.xml is because I uploaded artifacts to Archiva from a folder given to me by my predecessor. A lot of loose artifacts didn't have any version numbers, so I labeled these unknown version numbers "0.0"

edit: Deleted repository again after adding repo information to pom.xml. Ran another clean goal and another compile goal. Maven reacquired dependencies. I have confirmed that maven is getting the artifact from my Archiva Repository. Problem persists.

Upvotes: 1

Views: 10352

Answers (1)

eis
eis

Reputation: 53563

From a comment:

The package is DEFINITELY in the .jar. Not a .class file, but 3 .java source files. Including one called Scalr.java which appears to be the one that the compiler is complaining about.

This is your problem. Jars should contain compiled .class files, not source files, such as *.java files. You have put source jars in Archiva, but they're meant to be jars that contain compiled files.

I'm guessing you got those .jars through some unorthodox way, not by using regular tools.

Upvotes: 2

Related Questions