Category Archives: Maven

SQLServer JDBC Driver and Maven

com.microsoft.sqlserver
sqljdbc41
4.1
runtime

The issue is that Maven can’t find this artifact in any of the configured maven repositories.

Unfortunately Microsoft don’t make this available via any maven repository. You need to download the jar from the Microsoft website, and then manually install it into your local maven repository.

You can do this with the following maven command:

mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar

Then next time you run maven on your POM it will find the artifact.

How To Install Apache Maven on CentOS/RHEL 7/6/5

Step 1 – Install Apache Maven

After verifying java version on you system. Download Apache maven from its official website or use following command to download Apache Maven 3.3.9.

$ cd /opt
$ wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

Now extract downloaded archive using following command.

$ sudo tar xzf apache-maven-3.3.9-bin.tar.gz
$ sudo ln -s apache-maven-3.3.9 maven

Step 2 – Setup Environment Variables

As you have downloaded pre compiled Apache Maven files on your system. Now set the environments variables by creating new file /etc/profile.d/maven.sh.

$ sudo vi /etc/profile.d/maven.sh

and add following content.

export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Now load the environment variables in current shell using following command.

$ source /etc/profile.d/maven.sh

Step 4 – Check Version

Apache Maven has been successfully configured on your system. Use following command to check version of Maven.

$ mvn -version 

Maven

Web Application/RESTful service

https://jersey.java.net/documentation/latest/index.html

mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp \
                -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
                -DgroupId=com.welgg -DartifactId=jointforces -Dpackage=com.welgg.jointforces \
                -DarchetypeVersion=2.19

Upon deployment attempt in Glasfish you may get: “An error has occurred Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Set<Service> with qualifiers @Default at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject com.google.common.util.concurrent.ServiceManager(Set<Service>) at com.google.common.util.concurrent.ServiceManager.<init>(ServiceManager.java:0) . Please see server.log for more details.

Modify important version numbers in pom.xml

  • maven-compiler-plugin: 3.1
  • jersey.version: 2.19

 
Sample App

mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes  -DgroupId=nl.welgg.sample   -DartifactId=sample

Replace generated pom.xml
Replace generated App.java

mvn install
java -cp .\target\sample-1.0-SNAPSHOT.jar nl.welgg.sample.App

Make Eclipse ready

mvn eclicpse:eclipse -DdownloadSources
del .project
del .classpath
del .settings
mvn install

Import in Eclipse

Screen Shot 03-21-16 at 02.09 PM