Deploying on tomcat using maven - maven-2

i am deploying an application on apache-tomcat7 using maven but it gives dependency error, like this
com.moteve:moteve-server-core:jar:0.1-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.moteve -DartifactId=moteve-server-c
ore -Dversion=0.1-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.moteve -DartifactId=moteve-server-cor
e -Dversion=0.1-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -Drepo
sitoryId=[id]
Path to dependency:
1) com.moteve:moteve-server-webapp:war:0.1-SNAPSHOT
2) com.moteve:moteve-server-core:jar:0.1-SNAPSHOT
1 required artifact is missing.
for artifact:
com.moteve:moteve-server-webapp:war:0.1-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
here is my pom.xml file
<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">
<modelVersion>4.0.0</modelVersion>
enter code here
<parent>
<groupId>com.moteve</groupId>![enter image description here][1]
<artifactId>moteve-server-parent</artifactId>
<version>${moteve-server-parent-version}</version>
<relativePath>../moteve-server-parent/pom.xml</relativePath>
</parent>
<groupId>com.moteve</groupId>
<artifactId>moteve-server-webapp</artifactId>
<packaging>war</packaging>
<version>${moteve-server-webapp-version}</version>
<name>Moteve Web Application</name>
<url>http://moteve.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.moteve</groupId>
<artifactId>moteve-server-core</artifactId>
<version>${moteve-server-core-version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-webmvc-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>moteve-server-webapp</finalName>
</build>
</project>

Add deploy dependency in maven and try to run
mvn clean install

Related

Status HTTP 404: with a Spring Boot api web service developed with Intellij via remote Tomcat server

I created a spring boot initializer type web service under Intellij.
I can access my api in localhost via the ide server.
Example of api: http://localhost:8088/indicatorMissing/api/listCircuits
But when I create a war package that I deploy in a remote tomcat server, I have the window:
HTTP Status 404 – Not Found
Status Report Type
message /flagMissing/api/listCircuits
description The requested resource is not available.
Apache Tomcat/8.5.14 (Debian).
I tried the addresses:
:8080/missingflag/api/listCircuits
Where
:8080//MissingIndicator/api/listCircuits
Voici mon POM.xml :
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.sbvb</groupId>
<artifactId>indicateur_manquant</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>indicateur_manquant</name>
<description>indicateur_manquant</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Can anybody help me ?
Thank you

Maven configuration error : repo.maven.apache.org

I am trying to create a simple java project using maven.
But I am getting one error in the problems tab with the maven configuration.
The error description is "repo.maven.apache.org"
The error type is "maven configuration" problem.
Can any one help ?
Here is my pom.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bhawani.sample.maven</groupId>
<artifactId>FirstSimpleSpringProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FirstSimpleSpringProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
</dependencies>
</project>
In case you have not already tried, try to build your project from command prompt, you will get what exactly you are missing. Additionally, need to verify if provided local repository path has been provided and if you are building it offline/behind company proxy server, add proper proxy setting as well.

Unable to Deploy war using maven 3.x

I am trying to deploy my web-application to tomcat using maven 3.x here is the snap shot of the pom.xml file
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>demoapp</artifactId>
<version>2.2.3</version>
<packaging>war</packaging>
<name>Blank Webapp</name>
<properties>
<struts2.version>2.2.3</struts2.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>${struts2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
<url>http://localhost:8080/manager/html</url>
<server>localhost</server>
<path>/WebApp</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
i tried the following goal in maven mvn deploy but i got the following build fail with following error
Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
after doing some googling i added the following entry to my pom.xml
<distributionManagement>
<repository>
<id>myRepoId</id>
<name>myCompanyReporsitory</name>
<!-- <url>scp://nothing/</url>
<url>${user.home}/m2/repository</url> -->
</repository>
</distributionManagement>
but i am not sure what should be the URL since using ${user.home}/m2/repository gave another error with build failure
Failed to deploy artifacts/metadata: No connector available to access repository myRepoId (C:\Users\admin/m2/repository) of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1]
How to solve the problem?
The mvn deploy tries to send the result of the package goal to the url of repository described in your POM.
I aims not at deploying a Web application on its server but to share the library produced with other.
If what you need is to deploy you webapp, then the tomcat plugin is a solution.
BTW: The connector issue when trying to deploy is due to the fact that to enable SCP you need to add the wagon-scp connector.

Error in maven while downloading dependencies

My project1 and project2 were working fine with maven builds. Recently I upgraded from maven2 to maven3 using this tutorial (I checked it on maven2,but it didn't work either). Everything worked and is working fine for project2 which has a private (self hosted) Nexus repo.
But, now I am getting error while downloading dependencies for my project1 (using public maven repo).
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dds.server.DDSStartup</groupId>
<artifactId>storage</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>storage</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r07</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>com.sleepycat</groupId>
<artifactId>je</artifactId>
<version>3.3.75</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups-all</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>oracleReleases</id>
<name>Oracle Released Java Packages</name>
<url>http://download.oracle.com/maven</url>
<layout>default</layout>
</repository>
</repositories>
</project>
Where am I going wrong, this is the error I get when I do a : mvn clean package
[ERROR] Failed to execute goal on project storage: Could not resolve dependencies for project com.dds.server.DDSStartup:DynamicDistributedStorage:jar:1.0-SNAPSHOT: Failed to collect dependencies for [junit:junit:jar:3.8.1 (test), com.google.guava:guava:jar:r07 (compile), log4j:log4j:jar:1.2.16 (compile), com.sleepycat:je:jar:3.3.75 (compile), com.google.protobuf:protobuf-java:jar:2.3.0 (compile), jgroups:jgroups-all:jar:2.4.1 (compile)]: Failed to read artifact descriptor for log4j:log4j:jar:1.2.6: Could not transfer artifact log4j:log4j:pom:1.2.6 from/to oracleReleases (http://download.oracle.com/maven): /Users/username/.m2/repository/log4j/log4j/1.2.6/log4j-1.2.6.pom.ahc65d8d087349b4a46 (No such file or directory) -> [Help 1]
UPDATE:
I deleted everything (workspace), imported the project again and it worked like a charm. Nothing can beat that solution! ;)
This shouldn't be working with maven2 either.
From the error message, it looks like maven is trying to download dependencies from the repository specified in your pom - oracleReleases (http://download.oracle.com/maven) and not the public maven repo. This appears to be an invalid repository url.
Perhaps you should try removing the section and retry.
This is covered by another stackoverflow question which boils down to the Oracle repo not allowing directory listings.
I had the dependencies versions externalized as properties. Like:
<properties>
[...]
<hibernate-core.version>4.1.3.Final</hibernate-core.version>
[...]
</properties>
And:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
I closed the project, changed the version declaration to be explicit as
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.3.Final</version>
</dependency>
it worked!
The URL in orcacleReleases seems wrong, it does point to a 404, maybe oracle did move it ?

JSF 1.1 to 1.2 migration

I'm currently using JSF 1.1 on Apache Tomcat 6.0.13, with maven 2.
I'm planing to migrate from JSF 1.1 to 1.2. Could someone point me at:
- what JSF implementation is best to use
- is this implementation available at maven central repository
- what part of code will I need to adjust (I'm using custom tags in my project, but besides that it's all plain JSF)
etc.
Any info would be helpful... Thanx!
[edit 1]:
Hm, it haven't worked for me. Dependencies cannot be downloaded from the repository you've specified. Maybe it's because this is link for maven 1 repository. I'm using following pom settings instead:
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/jsf-api.jar</systemPath>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/jsf-impl.jar</systemPath>
</dependency>
I hope this approach is the correct one. If someone has a more maven-friendly solution, please advise. Thanx!
[edit 2]:
After I've changed my JSF jar from 1.1. to 1.2, following error occurred during application startup:
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory:
javax.faces.context.FacesContextFactory
To fix this error, additional listener need to be added in web.xml:
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
Have a look at the following release notes that has a migration guide from 1.1 to 1.2
http://java.sun.com/javaee/javaserverfaces/docs/ReleaseNotes.html
The maven2 artifacts for JSF 1.2 have found their way in the standard maven2 repository located at http://http://repo1.maven.org/maven2
JSF Implementation
http://repo2.maven.org/maven2/javax/faces/jsf-impl/1.2-b19/
JSF API
http://repo1.maven.org/maven2/javax/faces/jsf-api/1.2-b19/
As such, you shouldn't require any special repository setup in your pom.xml or settings.xml
The dependencies can be defined like this in the pom (1.2-b19 is the latest version at the time of writing) :
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2-b19</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2-b19</version>
</dependency>
Included below is a full pom.xml that should contain the basic dependencies for starting a JSF 1.2 project
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ecs.sample.jsf</groupId>
<artifactId>SampleJsfPom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<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>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2-b19</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2-b19</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>