user2318316
user2318316

Reputation: 1

java ignores proxy in command line argument

I am trying to build some .jar package with maven. Since I am connected to the Internet thru proxy server, my command looks like this:

mvn -DargLine="-Dhttp.proxyHost=my.proxy.com -Dhttp.proxyPort=8080" install

so that all other processes created by this will use those settings.

However, during the TESTS phase fork process tries to download some packages and even though it has proxy settings in its arguments (ps ax | grep java shows that), I can see with netstat -ntp that this process is connecting directly to the repository ignoring the proxy settings.

tcpdump shows no connections to 8080.

Any ideas?

UPD:

So, basically I am trying to build JBoss. As far as I understand it consists of different subsystems which should be build separately. For example, I want to build jboss-as-cmp. My commands without DargLine:

cd /root/jboss/jboss-eap-6.1.0.Alpha/jboss-eap-6.1-src/cmp
mvn install

to my mvn settings.xml in /root/.m2 I added

<proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>my.proxy.com</host>
      <port>8080</port>
   </proxy>
</proxies>

Ive read, that surefire plugin can be configuried to use proxy as well, so in my pom.xml for jboss-as-cmp I added

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
           <includes>
                <include>org/jboss/as/cmp/**/*TestCase.java</include>
            </includes>
                <systemPropertyVariables>
                   <http.proxyHost>my.proxy.com</http.proxyHost>
                   <http.proxyPort>8080</http.proxyPort>
                </systemPropertyVariables>
        </configuration>
    </plugin>

My mvn version

Apache Maven 3.0.5 (rNON-CANONICAL_2013-04-24_16-52_root; 2013-04-24 16:52:00+0300)
Maven home: /usr/share/apache-maven-3.0.5
Java version: 1.7.0_19, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.8.6-203.fc18.x86_64", arch: "amd64", family: "unix"

Environment variables:

M2_HOME=/usr/share/apache-maven-3.0.5
PATH=/usr/share/apache-maven-3.0.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

I have not changed any other settings in pom.xml for jboss-as-cmp.

Upvotes: 0

Views: 1574

Answers (1)

Jeremy Unruh
Jeremy Unruh

Reputation: 649

Typically to use proxies you should be defining them in your settings.xml found in user-home-dir/.m2/settings.xml

Example is:

<settings>
  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.somewhere.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
    </proxy>
  </proxies>
  </settings>

See http://maven.apache.org/guides/mini/guide-proxies.html

Upvotes: 2

Related Questions