Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dependencies.dependency.version' is missing error

Tags:

I am trying to create a bundle using apache maven. When I run mvn clean install command it is giving the below error:

dependencies.dependency.version' is missing for javax.servlet:servlet-api.jar

I have placed that ‘servlet-api.jar’ inside resource folder of my project

Could any anyone please tell where should I place that jar file?

UPDATE: Here is my pom.xml

    <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/maven-v4_0_0.xsd">   <parent>    <artifactId>felix-parent</artifactId>    <groupId>org.apache.felix</groupId>    <version>2.1</version>    <relativePath>../pom/pom.xml</relativePath>  </parent>   <modelVersion>4.0.0</modelVersion>   <artifactId>maven-bundle-plugin</artifactId>  <version>2.4.1-SNAPSHOT</version>  <packaging>maven-plugin</packaging>   <name>Maven Bundle Plugin</name>  <description>   Provides a maven plugin that supports creating an OSGi bundle   from the contents of the compilation classpath along with its   resources and dependencies. Plus a zillion other features.   The plugin uses the Bnd tool (http://www.aqute.biz/Code/Bnd)  </description>   <scm>   <connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/bundleplugin</connection>   <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/bundleplugin</developerConnection>   <url>http://svn.apache.org/repos/asf/felix/trunk/bundleplugin</url>  </scm>   <build>   <plugins>    <plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-compiler-plugin</artifactId>     <configuration>      <source>1.5</source>      <target>1.5</target>     </configuration>    </plugin>   </plugins>  </build>   <dependencies>         <!-- Provided APIs -->         <dependency>             <groupId>javax.servlet</groupId>             <artifactId>servlet-api</artifactId>         </dependency>      </dependencies>   <reporting>   <plugins>    <plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-plugin-plugin</artifactId>     <version>3.2</version>    </plugin>    <plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-changes-plugin</artifactId>     <version>2.9</version>     <configuration>      <component>12311143</component>      <versionPrefix>maven-bundle-plugin-</versionPrefix>      <statusIds>Resolved,Closed</statusIds>      <maxEntries>1000</maxEntries>      <issueManagementSystems>       <issueManagementSystem>JIRA</issueManagementSystem>      </issueManagementSystems>      <useJql>true</useJql>     </configuration>    </plugin>   </plugins>  </reporting>  </project> 

Thanks Anderson

like image 454
Anderson Avatar asked Jun 28 '13 16:06

Anderson


People also ask

How do I fix missing dependencies in Maven?

My problem solved by right click on project -> Maven -> Update project. Then the Maven Dependencies appear on the project explore. Save this answer.

What happens if Maven dependency version is not specified?

Each maven dependency defined in the pom must have a version either directly or indirectly for example, through dependencyManagement or parent. That being said, if the version is not given, then the version provided in the dependencyManagement or the parent pom will be used.

How do I override a dependency version?

Overriding Solved Dependency Versions By taking advantage of Maven's nearest definition logic, developers can override the version of a dependency by declaring it on the root pom. xml file. The example below shows an overridden version for checker-qual and how it was managed by Maven.

Why Maven dependencies are not getting downloaded?

If you run Maven and it fails to download your required dependencies it's likely to be caused by your local firewall & HTTP proxy configurations. See the Maven documentation for details of how to configure the HTTP proxy.


2 Answers

You haven't added the version tag in dependency.

<dependency>         <groupId>javax.servlet</groupId>         <artifactId>servlet-api</artifactId>         <version>1.0.0</version>   //Add the version. </dependency> 
like image 137
Rahul Bobhate Avatar answered Sep 28 '22 22:09

Rahul Bobhate


I had this same error for a slightly different reason.

My project uses dependency management (has 2 <dependencyManagement> sections for some reason) and has many modules and sub-modules.

Top level pom had:

    <dependencyManagement>         <dependency>             <groupId>org.apache.spark</groupId>             <artifactId>spark-core_2.10</artifactId>             <version>${spark.version}</version>         </dependency>     </dependencyManagement> 

Sub-level pom had

    <dependencyManagement>         <dependency>             <groupId>org.apache.spark</groupId>             <artifactId>spark-core_2.10</artifactId>             <scope>provided</scope>         </dependency>     </dependencyManagement> 

Leaf pom had

    <dependency>         <groupId>org.apache.spark</groupId>         <artifactId>spark-core_2.10</artifactId>     </dependency> 

To fix it I removed the <dependencyManagement> section from the mid-level pom and changed the leaf pom to have

    <dependency>         <groupId>org.apache.spark</groupId>         <artifactId>spark-core_2.10</artifactId>         <scope>provided</scope>     </dependency> 
like image 30
Harry Lime Avatar answered Sep 28 '22 21:09

Harry Lime