dependencies.dependency.version' is missing error
Asked Answered
S

4

39

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

Slub answered 28/6, 2013 at 16:46 Comment(2)
Please show us your pom.xml. You obviously missed the <verion> for the <dependency> servlet-api.Maure
Please find my pom.xmlSlub
T
25

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>
Thedathedric answered 28/6, 2013 at 17:2 Comment(0)
E
11

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>
Expenditure answered 21/9, 2016 at 9:5 Comment(0)
W
4

The message is quite clear: inside the dependencies element of your pom, you have a dependency element with the artefact javax.servlet:servlet-api.jar. And inside this dependency element, there must be a version element, but you didn't provide it.

<dependencies>
    <!-- Provided APIs -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>

        <!-- missing version here: -->
        <version>3.0</version>
    </dependency>
</dependencies>

Note that 3.0 is just an example. Provide the right version.

Weird answered 28/6, 2013 at 17:0 Comment(3)
Thanks..Actually i have more than 20 dependencies in my POM. i knew groupid,artifactId but i dont know the version exactly. Is there any way to include?Slub
any way to include what? You really should know which version of the servlet API you want to use. Nobody can guess for you.Weird
I have found all the version except two version one is <dependency> <groupId>com.day.cq</groupId> <artifactId>cq-commons</artifactId> <version>5.5.0</version> </dependency> I knew the above version is correct. But maven unable to find it. But it gave alternate way to import it as mvn deploy:deploy-file -DgroupId=com.day.cq -DartifactId=cq-commons -Dversion=5.5.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] what does it url, /path/to/file, id? Please guide meSlub
P
0

You have to add the dependency and along with that version and scope is optional. the latest version of javax.servlet is 3.0-alpha-1 at this point of time.

<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
   <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>3.0-alpha-1</version>
      <scope>provided</scope>
   </dependency>
Prohibit answered 29/9, 2023 at 6:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.