Spring + OpenAPI3 getting Swagger 404 when using static openApi.yaml file - swagger-ui

I have a simple spring application setup, with an openAPI dependency, in my pom file I added:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.6</version>
</dependency>
and I put a sample openapi.yaml file in the static resource folder, I then followed the instructions in the document:
Turn off auto-generation in the project property file:
springdoc.api-docs.enabled=false
Put your yaml file in src/main/resources/static such as src/main/resources/static/myApiFile.yaml
Set the swagger-ui URL for the file:
springdoc.swagger-ui.url=/myApiFile.yaml
Enable the minimal beans configuration:
#Configurationpublic class SpringDocsConfiguration {
#Bean
SpringDocConfiguration springDocConfiguration() {return new SpringDocConfiguration();}
#Bean
public SpringDocConfigProperties springDocConfigProperties() {return new SpringDocConfigProperties();}}
When I run the application and go to the URL: localhost:8080/swagger-ui.html, it shows that the .yaml file can not be fetched:
Here is my 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.dao.diy</groupId>
<artifactId>ADO-Diy</artifactId>
<version>1.0</version>
</parent>
<!-- <groupId>org.dao.diy</groupId>-->
<artifactId>backend</artifactId>
<name>backend</name>
<!-- <version>0.0.1-SNAPSHOT</version>-->
<packaging>war</packaging>
<!-- <name>backend</name>-->
<description>backend</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-data-mongodb</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</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>
<!-- <dependency>-->
<!-- <groupId>org.springframework.security</groupId>-->
<!-- <artifactId>spring-security-test</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.6</version>
</dependency>
</dependencies>
<build>
<finalName>ADO-DIY-TESTING</finalName>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>./src/main/resources/static/</outputDirectory>
<resources>
<resource>
<directory>../frontend/dist/frontend/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<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>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
My debugging steps include:
Following the documentation
Googling for existing solutions
Changing file locations
Trying different configuration combinations

Make sure to use the following structure for your resources folder:
resources -> static -> myAPIFile.yaml
Found the answer here: How to point Springdoc Swagger UI to my own YAML file instead of the auto-generated one?

Related

Lettuce 6.0.2 with elasticache through wildfly 10(customized for OSGI deployment)

I am trying to deploy the lettuce 6.0.2 on wildfly 10(which is customized to deploy OSGI bundle), which connects AWS elasticache. The connection URL looks as follows:
RedisURI redisURI = RedisURI.Builder.redis(configProperties.getProperty("ECclusterhost"), Integer.parseInt(configProperties.getProperty("ECclusterport"))).withPassword(pswdcharArray).withSsl(true).build();
The standalone program executes well, but when I tried to deploy on wildfly it gives me following error at the call: RedisClusterClient.create(redisURI);
Caused by: org.apache.felix.log.LogException:
java.lang.NoClassDefFoundError: javax/net/ssl/SSLParameters ... 42
more Caused by: java.lang.ClassNotFoundException:
javax.net.ssl.SSLParameters from [Module
"deployment.elasticache-1.0.0.jar:main" from Service Module Loader]
The pom.xml has the following dependencies:
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.0.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.9.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>4.1.59.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.59.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>4.1.59.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.3.14.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.3</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Since javax.net.ssl is a part of JDK 8, why it is not available at the time of deployment with the wildfly-10. To speed up the response time, I have asked same question at the lettuce group.
Update:
after few tweaks the original error is gone.
But still OSGI is not able to deploy reactor API, now I am getting following error:
ERROR [com.icare.elasticacheclient] (Thread-91) [MSC service thread 1-7] Invocation of 'init' failed.: java.lang.NoClassDefFoundError: Failed to link reactor/core/publisher/DirectProcessor (Module "deployment.elasticacheclient-1.0.0.jar:main" from Service Module Loader): Failed to link reactor/core/publisher/FluxProcessor (Module "deployment.elasticacheclient-1.0.0.jar:main" from Service Module Loader): org/reactivestreams/Processor
This is how the import package looks in pom.xml
<Import-Package>
org.slf4j;version="1.7.7",javax.net.ssl,javax.security.cert
</Import-Package>
<Embed-Dependency>lettuce-core,commons-pool2,netty-transport,netty-common,netty-handler,reactor-core,org.reactivestream</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
Not sure if there is a problem with OSGI integration of reactor.
After running the marathon for several days, I am able to fix this issue.
One of the reason is the version of log4j2 API, as I was using higher version, but after the version 2.8.2, the log4j-api.jar file contains compiled for Java 9 also and the older version of OSGI is not able understand the split package system. Also somehow javax package is not directly taken from JVM.
My final pom.xml file looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<parent>
<artifactId>master</artifactId>
<groupId>com.companyname.projectmaster</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
<artifactId>elasticache</artifactId>
<groupId>com.companyname</groupId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<log4j2Version>2.8.2</log4j2Version>
<slf4j-api.version>1.7.7</slf4j-api.version>
<io.netty.version>4.1.59.Final</io.netty.version>
</properties>
<dependencies>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.0.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.9.0</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${io.netty.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${io.netty.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>${io.netty.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound</artifactId>
<version>1.0.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.3.14.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2Version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2Version}</version>
<scope>runtime</scope>
</dependency>
<!-- SLF4J Bridge -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2Version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>standalone</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<redisclusterhost>ElasticacheClusterName</redisclusterhost>
<redisclusterport>6380</redisclusterport>
<authpassword>password</authpassword>
<minidleconnection>2</minidleconnection>
<maxidleconnection>5</maxidleconnection>
<maxtotalconnection>5</maxtotalconnection>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>1.0.0</Bundle-Version>
<Bundle-Activator>com.companyname.ElastiCacheActivator</Bundle-Activator>
<Bundle-Vendor>Company Name</Bundle-Vendor>
<Bundle-Category>osgi</Bundle-Category>
<Export-Package>
custom packages to be exported
</Export-Package>
<Import-Package>
org.slf4j;version="1.7.7",javax.net.ssl,javax.security.cert,javax.management
</Import-Package>
<Embed-Dependency>lettuce-core,commons-pool2,netty-transport,netty-common,netty-handler,reactive-streams,blockhound,reactor-core,log4j-api,log4j-core</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
<inherited>true</inherited>
<configuration>
<skip>false</skip>
<filename>${project.build.finalName}.jar</filename>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<log4j2Version>2.8.2</log4j2Version>
<slf4j-api.version>1.7.7</slf4j-api.version>
<io.netty.version>4.1.59.Final</io.netty.version>
</properties>
<dependencies>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.0.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.9.0</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${io.netty.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${io.netty.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>${io.netty.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound</artifactId>
<version>1.0.4.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.3.14.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2Version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2Version}</version>
<scope>runtime</scope>
</dependency>
<!-- SLF4J Bridge -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2Version}</version>
<scope>runtime</scope>
</dependency>
<profile>
<id>standalone</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<redisclusterhost>ElasticacheClusterName</redisclusterhost>
<redisclusterport>6380</redisclusterport>
<authpassword>password</authpassword>
<minidleconnection>2</minidleconnection>
<maxidleconnection>5</maxidleconnection>
<maxtotalconnection>5</maxtotalconnection>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>1.0.0</Bundle-Version>
<Bundle-Activator>com.companyname.ElastiCacheActivator</Bundle-Activator>
<Bundle-Vendor>Company Name</Bundle-Vendor>
<Bundle-Category>osgi</Bundle-Category>
<Export-Package>
custom packages to be exported
</Export-Package>
<Import-Package>
org.slf4j;version="1.7.7",javax.net.ssl,javax.security.cert,javax.management
</Import-Package>
<Embed-Dependency>lettuce-core,commons-pool2,netty-transport,netty-common,netty-handler,reactive-streams,blockhound,reactor-core,log4j-api,log4j-core</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
<inherited>true</inherited>
<configuration>
<skip>false</skip>
<filename>${project.build.finalName}.jar</filename>
</configuration>
</plugin>
</plugins>
</build>

maven site plugin issue on jenkins server

I developed a project with spring boot when I run maven build locally it worked fine and when I deploy on Jenkins server , the builds are failing when documenting.Here is my pom file.
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.services</groupId>
<artifactId>sample project</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>sample project</name>
<description>Demo project </description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
<scm>
// git urls
</scm>
<distributionManagement>
<snapshotRepository>
<id>xyz-snapshots</id>
<name>xyz-snapshots</name>
<url>urlname</url>
</snapshotRepository>
<repository>
<id>xyz-releases</id>
<name>xyz-releases</name>
<url>urlname</url>
</repository>
<site>
<id>app-site-deploy</id>
<url>dav:http://xyzcomzpny.com/projects/doc/</url>
</site>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
when we deploy on jenkins it showing the following error:
Unsupported protocol: 'dav' for site deployment to dav:http://xyzcomzpny.com/projects/doc/. when I use the site tag in other projects it worked. what is causing the builds fail? Do I have to add any tag in my pom file?
Source: https://www.mkyong.com/maven/how-to-deploy-site-with-mvn-site-deploy-webdav-example/
Did you try to declare the Wagon Dav extension ?
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
</build>

Maven - optional dependencies not being included in WEB-INF/lib

I've a maven war module that have several optional dependencies declared in pom.xml. In eclipse, those options dependencies are showing as part of the build path, which is what I expected. But during packaging of war file, maven is not including those dependencies in the WEB-INF/lib folder, which is not correct according to maven doc: https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html. Any idea why that is the case?
Below is the complete 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dhive</artifactId>
<groupId>com.boss</groupId>
<version>1.0</version>
</parent>
<artifactId>Boss</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>uk.com.robust-it</groupId>
<artifactId>cloning</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.sf.jt400</groupId>
<artifactId>jt400</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.qoppa</groupId>
<artifactId>jPDFProcess</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.arch</groupId>
<artifactId>multivalent</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.arch</groupId>
<artifactId>multivalentArch</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jpedal</groupId>
<artifactId>jpedal</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.arch</groupId>
<artifactId>invoiceTool</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>BossClient</id>
<configuration>
<ejbVersion>3.1</ejbVersion>
<generateClient>true</generateClient>
<clientIncludes>
<clientInclude>/com/**</clientInclude>
</clientIncludes>
</configuration>
<goals>
<goal>ejb</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Created an issue to Maven WAR Plugin for this, https://issues.apache.org/jira/browse/MWAR-351.
To get around this issue, I ended up have to removed the
<optional>true</optional>
from the ejb war module for it to work. For all other projects/Modules that needs the ejb-client from this war module, I ended up have to do exclusion to avoid its dependencies from being added to those projects/modules (See below).
<dependency>
<groupId>com.boss</groupId>
<artifactId>Boss</artifactId>
<version>1.0</version>
<type>ejb-client</type>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
I guess you need to change you plugin in pom.xml try adding following plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>

Including a jar in maven local repository

I want to include a jar in my local repository(google-api-java-client 1.6.0-beta). To include that we need to write in the pom.xml, but while I try to include it , its not getting included in local Repository. Below is the pom.xml of my project:
<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- The Basics -->
<groupId>com.google.tryPredictionJava</groupId>
<artifactId>gae-java</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>try-prediction-java</name>
<pluginRepositories>
<pluginRepository>
<id>maven-gae-plugin-repo</id>
<name>maven-gae-plugin repository</name>
<url>http://maven-gae-plugin.googlecode.com/svn/repository</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>google-api-services</id>
<url>http://mavenrepo.google-api-java-client.googlecode.com/hg</url>
</repository>
<repository>
<id>maven-gae-plugin-repo</id>
<name>maven-gae-plugin repository</name>
<url>http://maven-gae-plugin.googlecode.com/svn/repository</url>
</repository>
</repositories>
<dependencies>
<!-- 8th Apr <dependency> <groupId>com.google.api-client</groupId> <artifactId>google-api-client</artifactId>
<version>1.13.2-beta</version> </dependency> -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.14.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.6.0-beta</version>
</dependency>
<!-- <dependency> <groupId>com.google.api-client</groupId> <artifactId>google-api-client</artifactId>
<version>1.4.0-beta</version> </dependency> -->
<!-- 8th Apr <dependency> <groupId>com.google.oauth-client</groupId> <artifactId>google-oauth-client</artifactId>
<version>1.13.1-beta</version> </dependency> <dependency> <groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-servlet</artifactId> <version>1.13.1-beta</version>
</dependency> <dependency> <groupId>com.google.api.client</groupId> <artifactId>google-api-client-http</artifactId>
<version>1.2.3-alpha</version> </dependency> <dependency> <groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId> <version>1.13.2-beta</version>
</dependency> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client-jackson2</artifactId>
<version>1.13.0-beta</version> </dependency> -->
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.14.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-servlet</artifactId>
<version>1.14.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.api.client</groupId>
<artifactId>google-api-client-http</artifactId>
<version>1.2.3-alpha</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.14.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.14.1-beta</version>
</dependency>
<!-- <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client-jackson2</artifactId>
<version>1.13.0-beta</version> </dependency> <dependency> <groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId> <version>1.13.0-beta</version>
</dependency> -->
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.14.1-beta</version>
</dependency>
<!-- -->
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson</artifactId>
<version>1.13.1-beta</version>
</dependency>
<!-- -->
<!-- Google App Engine meta-package -->
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<!-- Java EE Servlet API. We need it to compile IndexServlet class. You can
probably remove it, if you don't explicitly use Servlets -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<!-- Make use of JSP tags. Remove, if you don't use JSPs -->
<dependency>
<artifactId>standard</artifactId>
<groupId>taglibs</groupId>
<version>1.1.2</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<!-- These dependencies are here just for enabling logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.24</version>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<!-- GAE libraries for local testing as described here: http://code.google.com/appengine/docs/java/howto/unittesting.html -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<!-- <dependency> <groupId>com.google.api-client</groupId> <artifactId>google-api-client</artifactId>
<version>1.4.1-beta</version> </dependency> -->
<!-- 8th Apr <dependency> <groupId>com.google.api-client</groupId> <artifactId>google-api-client</artifactId>
<version>1.13.2-beta</version> </dependency> -->
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.14.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-prediction</artifactId>
<version>v1.4-1.3.0-beta</version>
</dependency>
<!--<dependency> <groupId>com.google.apis</groupId> <artifactId>google-api-services-plus</artifactId>
<version>v1-rev22-1.8.0-beta</version> </dependency> -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-plus</artifactId>
<version>v1-rev62-1.14.1-beta</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo2-api</artifactId>
<version>2.3-eb</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>transaction-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${gae.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${gae.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.14.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.14.1-beta</version>
</dependency>
<!--<dependency> 8th Apr <groupId>com.google.http-client</groupId> <artifactId>google-http-client-jackson2</artifactId>
<version>1.13.0-beta</version> </dependency> <dependency> <groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId> <version>1.13.0-beta</version>
</dependency> -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>0.8.4</version>
<configuration>
<port>8080</port>
<address>127.0.0.1</address>
</configuration>
<executions>
<execution>
<id>start-gae</id>
<goals>
<goal>stop</goal>
<goal>unpack</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-gae</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- This plug-in "enhances" your domain model objects (i.e. makes them
persistent for datanucleus) -->
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>1.1.4</version>
<configuration>
<!-- Make sure this path contains your persistent classes! -->
<mappingIncludes>**/model/*.class</mappingIncludes>
<verbose>true</verbose>
<enhancerName>ASM</enhancerName>
<api>JDO</api>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>transaction-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>${datanucleus.version}</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-enhancer</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo2-api</artifactId>
<version>2.3-ec</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/appengine-web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<!-- The actual maven-gae-plugin. Type "mvn gae:run" to run project, "mvn
gae:deploy" to upload to GAE. -->
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>0.9.0</version>
<dependencies>
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
<!-- Upload application to the appspot automatically, during release:perform -->
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<goals>gae:deploy</goals>
</configuration>
</plugin>
<!-- Java compiler version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<!-- Specify hard-coded project properties here -->
<properties>
<!-- Sets the project's default encoding. http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- This is just for "eclipse:eclipse" goal to always attempt downloading
sources -->
<downloadSources>true</downloadSources>
<!-- Specify AppEngine version for your project. It should match SDK version
pointed to by ${gae.home} property (Typically, one used by your Eclipse plug-in)
<gae.version>1.6.1</gae.version> -->
<gae.version>1.6.3</gae.version>
<!-- Upload to http://test.latest.<applicationName>.appspot.com by default -->
<gae.application.version>test</gae.application.version>
<datanucleus.version>1.1.5</datanucleus.version>
</properties>
<profiles>
<!-- We can configure our integration server to activate this profile and
perform gae:deploy, thus uploading latest snapshot to the http://1.latest.<applicationName>.appspot.com
automatically -->
<profile>
<id>integration-build</id>
<properties>
<gae.application.version>stage</gae.application.version>
</properties>
</profile>
<!-- This profile will activate automatically during release and upload
application to the http://2.latest.<applicationName>.appspot.com (We might
want to set the 2nd version as our applications Default version to be accessible
at http://<applicationName>.appspot.com) -->
<profile>
<id>release-build</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<properties>
<!-- During release, set application version in appengine-web.xml to
2 -->
<gae.application.version>release</gae.application.version>
</properties>
</profile>
</profiles>
Latest version in central repo is 1.4.1-beta
<dependency>
<groupId>com.google.api.client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.4.1-beta</version>
</dependency>
Download newest JAR and install in local repository
mvn install:install-file -Dfile=google-api-client.jar -DgroupId=com.google.api.client \
-DartifactId=google-api-client -Dversion=1.6.0-beta -Dpackaging=jar

change generated war name using maven jetty plugin

I am using maven Struts2 blank artifact to create my web application. Here is my 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.website.my</groupId>
<artifactId>MyArtifact</artifactId>
<version>3</version>
<packaging>war</packaging>
<name>My Artifact</name>
<properties>
<struts2.version>2.3.12</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>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>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.7.v20120910</version>
<configuration>
<war>C:\Users\pranay\Documents\GitHub\MyArtifact\target\myWeb.war</war>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>/Users/lukaszlenart/Projects/Apache/STRUTS_2_3_12/target/checkout/archetypes/struts2-archetype-blank/src/main/resources/log4j.properties</value>
</systemProperty>
<systemProperty>
<name>slf4j</name>
<value>false</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>/Users/lukaszlenart/Projects/Apache/STRUTS_2_3_12/target/checkout/archetypes/struts2-archetype-blank/src/main/webapp/</webAppSourceDirectory>
<webApp>
<contextPath>/MyArtifact</contextPath>
<descriptor>C:\Users\Pranay\Documents\GitHub\MyArtifact\src\main\webapp\WEB-INF</descriptor>
</webApp>
</configuration>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
above pom.xml uses jetty server for creating war file.So when I run mvn jetty:war-run then it creates war file with name MyArtifact-3.war(artifactId-version), but I want my war file name to be myWeb.war. I used war tag in configuration of pom.xml to specify the war name I want(according to this link http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#running-assembled-webapp-as-war). But, it is not working. Please let me know how can I change generated war file name.
Simple enough, just override the <finalName> value.
<project>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>

Resources