How to set NetBeans 7 internet connection? - java

I am using NetBeans 7. Tried to create a Maven Java project, failed.
In NetBeans
mvn.bat -DarchetypeVersion=1.1 -Darchetype.interactive=false -DgroupId=com.mycompany -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeRepository=http://repo1.maven.org/maven2/ -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.maven.archetypes -Dbasedir=F:\\NetBeansProjects -Dpackage=com.mycompany.mavenproject1 -DartifactId=mavenproject1 "-Dmaven.repo.local=C:\\Documents and Settings\\xxx\\.m2" --batch-mode archetype:generate
It failed, because
Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: connect
Then copy that command into DOS, it works.
Looks like NetBeans can't connect to internet. Eclipse on the same machine can connect to remote internet.

The issue is that NetBeans 7 comes bundled with an embedded version of Maven. This means that any proxy settings you may have configured under your downloaded Maven distribution are not used by NetBeans.
You have two options:
Tools > Options > Miscellaneous > Maven > Maven Home -- point NetBeans to your existing Maven download; that is, where you have configrued settings.xml with your proxy settings;
Edit path/to/nb7/java/maven/conf/settings.xml with your proxy settings.

Well it is not necessarily internet issue
If you are behind proxies you need to tell maven in settings.xml about proxy
If that lib ins't available on the maven repos download it from official sitre and install it manually

Either
Disable antivirus firewall protection for a while.
Or
Add netbeans in exception list of the firewall.
In my case Avast firewall had blocked connection and I've disabled it for a while and it worked.
That's it !!!

Related

Jenkins - Unable to access to repository

I am trying to configure Jenkins to download code from SVN repository and to prepare builds.
Jenkins is on one linux machine - version 1.651.1
Subversion Plug-in 2.5.7
SVN repository is set on another linux machine.
A set repository URL to eg: http://abcsvn/svn/project/branches/branch_a/HEAD/
Unfortunately I get: 'Unable to access to repository' message from Jenkins.
I also tried to put IP instead of abcsvn.
From terminal on linux machine where the Jenkins is installed I can ping IP successfully.
What may be the reason of that kind of problem? The URL is correct, because I paste that in Chrome on my machine and it worked correctly.
I also installed Jenkins on my computer with Windows. I set the same parameters and I am still not able to connect to svn repo. In Eclipse I don't have any problem to commit and checkout from svn repo.
If you need any more information to diagnose this problem I will try to complete this post.
Exception says that you have not provided credentials of your svn repository. In newer version of svn we can provide this credential while we configure workspace. In your version it can be provided from manage Jenkins menu.

How to configure maven without internet access

While converting dynamic web project into maven project I'm getting this error:
"CoreException: Could not calculate build plan:
Plugin org.apache.maven.plugins:maven-compiler-plugin"
I can't access the internet to download any jars and plugins while converting because I'm on a restricted network with no internet access. Is there is any way to make a Maven project with no internet access?
I'm using:
Eclipse kepler
Maven 3.0.4
JDK 1.6
You can manually download or some how find required artifacts.(jars) Then copy them into your local maven repository.
Now you can use
mvn clean install -o // off-line build
to build your project without internet.
About half year ago, when I worked as an intern in a company, we also encountered with virtually the same problem as you ------ we were in the restricted network, and our computers couldn't access the internet, but we still needed to use maven to update the project dependencies. Here is our solution:
Find a server that can access the internet, and also you can access
the server in your restricted network.
Establish a sonatype nexus server on the server you found above.
The sonatype nexus serer is just a private repository in your environment. You can upload your own packages into the repository, and also the nexus server can download required packages from the central maven repository.
The last thing you need to do is to change the repository address in your pom.xml to the nexus server address
Hopefully, this can help you. And if you have any questions, please feel free to ask me again.
mvn clean -o install
Running in Offline Mode
If you ever need to use Maven without having access to a network, you should use the following option to prevent any attempt to check for updates to plugins or dependencies over a network:
-o, --offline
When running with the offline option enabled, Maven will not attempt to connect to a remote repository to retrieve artifacts.
refer here and here for more options
I think without internet you can not download it, initially you need an internet connection because maven need bunch of dependency and it all depend on your project. if you download them manually one by one there is some chance that you could miss some dependency and error will resolve one by one it will take more time and research to search dependency over internet and fix them one by one.
so I prefer instead of downloading manually go for internet connection it will download all the dependency automatically.
if you have restricted access download it at home and replace that folder with your work area folder
Maven is a dependency management system which downloads the required dependencies from the internet or a mirror of the central maven repository. Incase you do not have both - connection to internet (Central Maven Repository) or a local mirror (Nexus is the most used replicator of the central maven repository in a Enterprise setting) - then maven is bound to get the dependencies off your local hard disk from the .m2 folder under your logged in user directory.
Hence, in order for maven to work, manually register all dependencies which you have listed in the pom(s) as described in the maven guide :
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
You can try copying your .m2 folder to the machine without internet... and then running maven offline.

m2e with ssl certificate-based authentication

TL;DR
How to make Eclipse's built-in Maven connect to an HTTPS repository that uses certificate-based authentication?
It seems that m2e is able to find the keystores, but unable to connect. Command-line Maven works like a charm using exactly the same keystores. Run as -> Maven build works with external Maven and not with the embedded one.
Problem
I have a Maven project with a dependency. That dependency is available in a repository that uses SSL certificate-based authentication in addition to regular username-password combination. I need to make it work in Eclipse Luna, with the built-in Maven. All I am able to get is handshake_failure. Investigation of the logs shows that the built-in Maven is unable to find a matching certificate.
When I use Run as -> Maven build with an external Maven, or command-line Maven, it successfully connects to the repository and fetches the artifact exactly as needed.
The interesting thing is, both external and embedded Mavens have the same version (3.2.3).
Setup
I pass these parameters through eclipse.ini:
-Djavax.net.ssl.trustStore=java.cacerts
-Djavax.net.ssl.trustStorePassword=******
-Djavax.net.ssl.keyStore=private.cacerts
-Djavax.net.ssl.keyStorePassword=******
-Djavax.net.debug=ssl,handshake
The trustStore file contains:
the whole certificate chain for the repository I connect to (the chain ends with a self-signed certificate), one of them being stored under the alias repository.location.url (literal repository location here, e.g. myrepository.com)
certificate for maven central
The keyStore file contains an imported PKCS certificate under an alias of the repository.
There seems to be no problem at all with the setup, as the command-line Maven works. If I use external Maven or command-line one, it works. If I swich to embedded one (which is always used for resolving dependencies), handshake error shows up.
What am I doing wrong? I might be missing something completely obvious. Any help would be appreciated.
Options that didn't work for me
Installing certificate to java > jre > lib > security > cacerts
Providing cacerts in java run configuration vm arguments
Updating eclipse to latest versions like mars or neon
Updating maven plugin for eclipse to 1.7.0
Steps that resolved the issue for me
Download certificate file & add in eclipse at Preferences > Remote Systems > SSL > Add
Clear .m2 > repository folder of all existing files
Open eclipse, right-click on project and Select Maven > Update Project. Choose Force Update of Snapshots/Releases
updated on 9/19/2017
If nothing else works, Installing the certificate to Java on your machine # java > jre > lib > security > cacerts can help
I had exactly the same problem: Eclipse could not connect to external maven repository using embedded maven installation in case the repository requires a client SSL certificate.
The problem was solved by upgrading to latest jvm (in my case - 1.8.0u52) and upgrading Eclipse m2e plugin to version 1.6.1 (with Eclipse version 4.4.0).
In your run configurations select your maven build and then select the JRE tab at the top of the dialog. Put your SSL parameters into the VM arguments text-area.
that's what fixed it for me.
I managed to fix it by setting external maven in eclipse.
Eclipse->Window->Preferences->Maven->Installations->Add

Resolve/Download dependencies after deployment to remote server

I have a big war file over-sized due to lots of external dependencies & also I have internet connection speed issues because of which I don't want to keep the dependency jars in my war, so that I could reduce war size & do faster uploads of my updated wars from dev machine to remote server.
I would like the maven project to instead download the dependencies on the remote tomcat server itself when it has been uploaded there & starts running. How do I configure maven to do that ?
There is a pretty simple solution: Build the project on the server.
An easy way to do this is to put all the sources into a version control system like Mercurial or Git.
In addition to giving you a history and an automated backup, DVCS have insanely efficient algorithms to update remote copies (they just transfer the changes, so if you change a single line, only one line is sent over the wire).
Building on your server also means that you get the very fast download of dependencies on the server (which has probably very good download rates). And local deployment will be very, very fast.
Last but not least: When you use version control, you will be able to go back to the last stable version quickly when something goes wrong.
As Aarom says you should build the project on the server directly.
There are two requirements:
You need to have a command line access on the remote server.
Maven must be installed on the remote server.
Then you can upload the sources of your project on the remote server (without dependencies).
Go in the root directory of your project and run your build command (mvn package or whatever custom build command that you use).
So that's it, you have the .war on the remote server loaded with all the dependencies; you can then remove the source files.
#user01
Install all desired 3rd-party jars to Tomcat's lib folder.
Set the scope of those dependencies to "provided" in you Maven pom.xml.
Install Maven on your remote server.
Install a CI server such as Jenkins, Continuum, Bamboo, Hudson, CruiseControl, etc. I'd suggest Jenkins.
Hopefully, you are using revision control software such as SVN, Git, Mercurial, Bazaar, or CVS. If not, then I'd suggest setting up
Git or SVN for your source code repository.
Configure the scm tag in your pom.xml to point to your project's location within your source code repository.
Configure your CI server to get your pom.xml from your source code repository. Your CI server will read the scm tag, and the
URL's you've configured within the scm tag, and will check your
project out. Your CI server will then build your project.
You can either have Jenkins deploy your built war artifact to Tomcat via the Jenkins Deploy Plugin, or you can use a Maven plugin such as the
tomcat7-maven-plugin or Cargo.

Intellij Community can't use http proxy for Maven

I have Intellij IDEA Community installed on a Linux box that needs to use an authenticated proxy to get to the Internet. I have a system-wide proxy on the box that works, and I have the proxy configured in ~/.m2/settings.xml. Maven correctly uses the proxy when I run try it from the command-line.
I have the same proxy configured within Intellij and it gives me the plugins listing correctly. But when I try to sync with the Maven repository withing Intellij I keep getting this:
[WARNING] Unable to get resource 'org.codehaus.mojo:hibernate3-maven-plugin:pom:2.2'
from repository restlet (http://maven.restlet.org): Authorization failed: Not
authorized by proxy.
I went to Settings->Maven and put in the proxy info as properties and that didn't work. I can see by looking at those settings that Intellij is reading my ~./m2/settings.xml fine because it knows where my local repo is (it's in a non-standard place).
Anyone know how I can get this working?
Navigate to Maven > Importing1. inside the IntelliJ IDEA Settings (which is found under File > Settings).
The second last option in Maven > Importing is a field named "VM options for importer". Append the following to whatever already exists there:
-DproxySet=true -DproxyHost=myproxy.com -DproxyPort=3128
Here, replace myproxy.com with your proxy server, (e.g. http://myproxyserver.com). Replace 3128 with your proxy port (e.g. 8080).
Do the same under Maven > Runner1
Apply and close the settings window.
It should work now.
1 This may be nested under Build, Execution, Deployment > Build Tools >, depending on the version of IntelliJ you're using.
I had the same problem running maven inside IntelliJ whilst behind an NTLM proxy. The working solution was as follows:
Download and install CNTLM. Excellent post here on how to do this https://stackoverflow.com/a/23962313/3298801
Set and test your local proxy settings in IntelliJ via Settings >> System Settings >> HTTP Proxy.
In Intellij set the maven runner. Within Settings >> Maven >> runner set VM options to:
-DproxySet=true -DproxyHost=localhost -DproxyPort=3132
Restart Intellij
Note within ~/.m2/settings.xml I also added my proxy config as:
<proxies>
<proxy>
<active>true</active>
<protocol>https</protocol>
<host>localhost</host>
<port>3132</port>
</proxy>
</proxies>
A little update for memo. I don't have a standalone maven installed, so finally I fixed this by modifying the maven plugin settings. settings.xml is located at :
IntelliJ IDEA Community Edition 2017.3.4\plugins\maven\lib\maven3\conf\settings.xml
You can find proxy settings and change it as mentioned above.
I meet the same problem.By ShadowsocksR,I can visit some websites that i can't visit without ShadowsocksR. I use Intellij , the error is "Connection timed out: connect -> [Help 1]".At last, I also added my proxy config as:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>localhost</host>
<port>1080</port>
<username>***.***.**.***:****</username>
<password>*******</password>
<nonProxyHosts>www.baidu.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
</settings>
My computer environment is win10. http://maven.apache.org/guides/mini/guide-proxies.html
Can you try either removing the proxy setting in settings.xml or the setting in IntelliJ itself.
And then try to sync with the maven repo from within Intellij.
I commented out the proxy config in my ~/.m2/settings.xml file, let the Intellij Proxy info alone, and then supplied the properties in Setting->Maven. Not sure why that worked (nor why the settings.xml wasn't working right) but it's working now.
I just add it in the VM option in the run configuration, and it works
-DproxySet=true -DproxyHost=proxy.com -DproxyPort=3132
inside the IntelliJ IDEA -> edit configuration ->click on modify option -> Add VM options and add it, replace "proxy.com" with your proxy server (e.g. http://myproxyserver.com)
I Have found similar issues with the Maven 2.2 integration in intellij 9.
I am using 9.0.1
I use intellij behind a corporate firewall/proxy.
If I point Intellij's maven conf to use external Maven and maven conf that has the proxy settings inside, intellij fails to download artifacts from any remote repositories.
Had no problems with intellij-8, this only started after the upgrade. The Maven conf has not changed either.
I have to do a Maven build from command line to get any new dependent artifacts into my local repo then use intellij-9.
The Maven 2.2 integration has issues behind proxy servers.
I have had the same issue. However, my proxy settings were stored under the environment variable *M2_OPTS*.
As per the above posts, deleting the environment variables stopped IDEA from hanging.
This is under Windows 7, using IntelliJ IDEA CE 12.3
If anyone notices an open bugfix for this please respond with a link.

Categories

Resources