5

Running:

mvn compile

Generates error:

package org.apache.commons.codec.binary does not exist

pom.xml includes:

  <dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.10</version>
  </dependency>

ls ~/.m2/repository/commons-codec/commons-codec/1.10

Returns:

commons-codec-1.10.jar
commons-codec-1.10.jar.sha1  
commons-codec-1.10.pom  
commons-codec-1.10.pom.sha1  
_remote.repositories

jar tvf commons-codec-1.10.jar | grep binary

Returns:

org/apache/commons/codec/binary/
org/apache/commons/codec/binary/Base32.class
org/apache/commons/codec/binary/Base32InputStream.class
org/apache/commons/codec/binary/Base32OutputStream.class
org/apache/commons/codec/binary/Base64.class
org/apache/commons/codec/binary/Base64InputStream.class
org/apache/commons/codec/binary/Base64OutputStream.class
org/apache/commons/codec/binary/BaseNCodec$Context.class
org/apache/commons/codec/binary/BaseNCodec.class
org/apache/commons/codec/binary/BaseNCodecInputStream.class
org/apache/commons/codec/binary/BaseNCodecOutputStream.class
org/apache/commons/codec/binary/BinaryCodec.class
org/apache/commons/codec/binary/CharSequenceUtils.class
org/apache/commons/codec/binary/Hex.class
org/apache/commons/codec/binary/StringUtils.class

Pom:

<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>dashboard</groupId>
<artifactId>dashboard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Dashboard</name>
<description>Dashboard</description>
<dependencyManagement>
<dependencies>
    <dependency>
        <groupId>com.ocpsoft</groupId>
        <artifactId>prettyfaces-jsf2</artifactId>
        <version>3.3.2</version>
    </dependency>
            ...
        <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.10</version>
    </dependency>
            ...
</dependencies>
</dependencyManagement>
<repositories>
    <repository>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>public-snapshots</id>
        <url>http://public-snapshots</url>
    </repository>
    <repository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>central</id>
        <name>Central Repository</name>
        <url>https://repo.maven.apache.org/maven2/</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>public-snapshots</id>
        <url>http://public-snapshots</url>
    </pluginRepository>
    <pluginRepository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>central</id>
        <name>Central Plugin Repository</name>
        <url>https://repo.maven.apache.org/maven2/</url>
    </pluginRepository>
</pluginRepositories>
<build>
    <sourceDirectory>/home/username/workspace/MyApp/src</sourceDirectory>
    <scriptSourceDirectory>/home/username/workspace/MyApp/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>/home/username/workspace/MyApp/src/test/java</testSourceDirectory>
    <outputDirectory>/home/username/workspace/MyApp/target/classes</outputDirectory>
    <testOutputDirectory>/home/username/workspace/MyApp/target/test-classes</testOutputDirectory>
    <resources>
        <resource>
            <directory>/home/username/workspace/MyApp/src</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
    <testResources>
        <testResource>
            <directory>/home/username/workspace/MyApp/src/test/resources</directory>
        </testResource>
    </testResources>
    <directory>/home/username/workspace/MyApp/target</directory>
    <finalName>dashboard-0.0.1-SNAPSHOT</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.3</version>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>analyze</id>
                        <goals>
                            <goal>analyze-only</goal>
                        </goals>
                        <configuration>
                            <failOnWarning>true</failOnWarning>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>


    </pluginManagement>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <executions>
                <execution>
                    <id>default-testCompile</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </execution>
                <execution>
                    <id>default-compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>default-war</id>
                    <phase>package</phase>
                    <goals>
                        <goal>war</goal>
                    </goals>
                    <configuration>
                        <warSourceDirectory>WebContent</warSourceDirectory>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>default-clean</id>
                    <phase>clean</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>default-install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>install</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>default-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-testResources</id>
                    <phase>process-test-resources</phase>
                    <goals>
                        <goal>testResources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <executions>
                <execution>
                    <id>default-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>default-deploy</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.3</version>
            <executions>
                <execution>
                    <id>default-site</id>
                    <phase>site</phase>
                    <goals>
                        <goal>site</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
                        <reportPlugins>
                            <reportPlugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-project-info-reports-plugin</artifactId>
                            </reportPlugin>
                        </reportPlugins>
                    </configuration>
                </execution>
                <execution>
                    <id>default-deploy</id>
                    <phase>site-deploy</phase>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
                        <reportPlugins>
                            <reportPlugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-project-info-reports-plugin</artifactId>
                            </reportPlugin>
                        </reportPlugins>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
                <reportPlugins>
                    <reportPlugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                    </reportPlugin>
                </reportPlugins>
            </configuration>
        </plugin>
    </plugins>
</build>
<reporting>
    <outputDirectory>/home/username/workspace/MyApp/target/site</outputDirectory>
</reporting>

</project>

Errors:

INFO] Compiling 62 source files to /home/username/workspace/MyApp/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/webservices/util/fname1.java:[10,39] package org.apache.commons.codec.binary does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/webservices/util/fname1.java:[11,29] package org.apache.commons.io does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/report/ReportBean.java:[17,24] package javax.faces.bean does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/report/ReportBean.java:[18,24] package javax.faces.bean does not exist
[ERROR] /home/username/workspace/MyApp/src/xx/yyy/zzzz/dashboard/report/ReportBean.java:[32,2] cannot find symbol

symbol: class ManagedBean

Any suggestions regarding why mvn cannot resolve this package would be much appreciated.

FYI, just getting started with maven.

Thanks,

KevinC

3
  • Could you share the pom.xml build configuration and complete error logs in terms of why is it not able to find the package. Commented Oct 5, 2017 at 17:37
  • Usually maven puts these dependencies in the classpath. For some reason it doesn't. Did you put anything weird in your pom or settings.xml? Commented Oct 5, 2017 at 17:45
  • Besides ug_ answer, most of what you define in your pom is the default configuration of a Maven project, you could easilly get rid of 3/4 of you pom. Maven is good exemple of convention over configuration and if you stick to the Maven convention as your project seems to be, you won't need so much configuration Commented Oct 5, 2017 at 21:17

1 Answer 1

4

The problem is you have your dependency of commons-codec underneath the <dependencyManagement> tag.

You should change your the the tag <dependencyManagement> to be <dependencies>

See differences between dependencymanagement and dependencies in maven

Sign up to request clarification or add additional context in comments.

1 Comment

You rock! Thanks for relieving my pain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.