4

I am able build my java project on my local machine, it builds successfully using maven. However, when I build it on a Jenkins machine, i get a compile error:

package javax.jms does not exist

What does this mean? Where is it looking for javax.jms? In local m2 repo, classpath?

I had to make the following changes to my pom.xml to get it to work on Linux:

a) Explicitly stated maven-site-plugin version to 2.1. org.apache.maven.plugins maven-site-plugin 2.1

b) Changed maven-surefire-plugin version from 2.4.3 to 2.18.1 maven-surefire-plugin 2.18.1

c) Added the following dependencies :

     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <version>1.4</version>
     </dependency>

     <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.2</version>
      </dependency>

      <dependency>
            <groupId>com.xx.yyy</groupId>
            <artifactId>jms</artifactId>
            <version>1.1</version>
      </dependency>

      <dependency>
            <groupId>com.xx.yyy</groupId>
            <artifactId>orm</artifactId>
            <version>3.1.0.5</version>
       </dependency>

       <dependency>
            <groupId>org.springframework.ldap</groupId>
            <artifactId>spring-ldap-core</artifactId>
            <version>1.3.0.RELEASE</version>
       </dependency>

Why do I have to change the pom.xml on Linux. The build works on my Windows 7 machine without changing the pom.xml.

user518066
  • 1,277
  • 3
  • 23
  • 35
  • Can you put the goals you are using for building with Maven? And also what dependencies are you using for javax.jms? – yyunikov Dec 24 '14 at 13:53
  • Generally, when you build locally, Maven will pull down the required dependencies from the Internet. For a more official build in, say, a corporate environment, the dependencies will be pulled from a standard internal maven repo. It might just be a matter of adding the dependency to that repo. – unigeek Dec 24 '14 at 13:57
  • You might also look into Maven's settings.xml configuration file on the Jenkins box to see about repository locations. See http://maven.apache.org/settings.html – unigeek Dec 24 '14 at 14:18

1 Answers1

1

First, try to check if you have correct dependency for Maven to get javax.jms packages. You can try Apache Geronimo dependency or JavaEE API. (Reference :What is the right Maven dependency for javax.jms.* classes?)

For Apache Geronimo

  <dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-jms_1.1_spec</artifactId>
    <version>1.1.1</version>
  </dependency>

For JavaEE API

   <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>

Also, make sure you are building your application on Jenkins with the following goals:

mvn clean install

After you build your application with Maven on Jenkins machine, the package should appear in local m2 repo for Jenkins.

Community
  • 1
  • 1
yyunikov
  • 5,719
  • 2
  • 43
  • 78
  • Thanks for your help. The javax.jms resides on my local repository on the Jenkins box. Why is it not picking it up? Can i debug the maven command to see where it is looking? – user518066 Dec 24 '14 at 14:19
  • Yes, you can check your dependency tree with this command http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html – yyunikov Dec 24 '14 at 14:22
  • On my local windows machine, the maven build worked fine. On Jenkins Linux, I had to update the pom.xml(add additional dependencies); this updated the classpath, including the javax.jms jar. This fixed the compile/build error. Why does it work on my local windows machine, why did I have to update the pom.xml on Linux to the add the necessary jars to classpath? Is it a potential firewall issue on the Linux machine? – user518066 Dec 29 '14 at 15:34
  • No, this should not be the firewall and I don't see the reason you need to change your dependencies, jars or pom.xml depending on OS. Could you post what you have changed in pom.xml and which jars did you added/excluded? – yyunikov Dec 29 '14 at 21:01
  • I have updated the question with the changes in the pom. – user518066 Jan 05 '15 at 17:40