Intellij 2018.1.6 deploy glassfish application name contains .ear extension - maven

Created a Run/Debug configuration to deploy to a payara glassfish server.
It is deploying the built .ear file MyApp.ear built with maven to the server but when you look at the application in the Admin console the name is MyApp.ear.
What am I missing that would deploy it with the application name of just MyApp?
If I deploy the MyApp.ear file using the admin console the application name defaults to MyApp, so what do I need to do so Intellij does the same?
Update 7-23-2018:
I already had finalName here in my ear pom.xml:
<build>
<finalName>MyApp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<modules>
<webModule>
<groupId>com.example.myapp</groupId>
<artifactId>war-module</artifactId>
<contextRoot>/MyApp</contextRoot>
</webModule>
<ejbModule>
<groupId>com.example.myapp</groupId>
<artifactId>ejb-module</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
So I tried moving it to with in configuration with same results:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<finalName>MyApp</finalName>
<modules>
<webModule>
<groupId>com.example.myapp</groupId>
<artifactId>war-module</artifactId>
<contextRoot>/MyApp</contextRoot>
</webModule>
<ejbModule>
<groupId>com.example.myapp</groupId>
<artifactId>ejb-module</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
This is something specific to Intellij when it deploys it, it's like it doesn't use these values and just uses the file name for the application name.

Related

create spring boot native image in a multi module project

i am trying to build an native image with graalvm and spring boot.
my project has several modules.when i try to build native image i got this error:
Error: Please specify class (or <module>/<mainclass>) containing the main entry point method. (see --help)
and when i define mainClass path(org.example.api.Application) in properties in parent pom file i got this error:
Error: Main entry point class 'org.example.api.Application' neither found on the classpath nor on the modulepath.
how can i define the module that contain main class for graalvm?
In your parent pom (the one where you declare all your modules) using the syntax
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
use the latest Spring Boot BOM as parent
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
then override the native profile
<profiles>
<profile>
<id>native</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<executions>
<execution>
<id>build-image</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
At this point in your modules (where you need native builds) you can set this build configuration:
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
At this point you will be able to compile the project(s) using the mvn -Pnative clean package

How to Run Command-line main class separately without including existing main-class present in Application in maven based Springboot App?

I am facing bizarre situation. when i run existing main application it also include another commandLine main-class while running.
I have create 2 profile in pom.xml- and also setup mainClass tag.
1- unit-test
2- integration-test
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${commandLineMainClass}</mainClass>
</configuration>
</plugin>
in integration-test, i have created separate main-class with command-line runner to test the application deployed on another server by just hitting.
i have two issue-
1- when i run existing main-class application, it boot with command-line mainclass also. which should be excluded until this is not run manually by command-line.
when i run command line main class, i m not able to access custom application-{env}.properties, although it is not including existing application main-class which is good.
I am using springBoot maven-plugin also.
please help.
<project>
<parent>
<groupid>org.springframework.boot</groupid>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/>
</parent>
<properties>
<java.version>1.8</java.version>
<start-class>thisisCommandLineProp</start-class>
<environment>thisisCommandLineProp</environment>
</properties>
<profiles>
<profile>
<id>unittest</id>
<build>
<filename>${project.artifactId}</filename>
</build>
</profile>
<profile>
<id>integrationtest</id>
<build>
<filename>${project.artifactId}</filename>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupid>org.springframework.boot</groupid>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<workingDirectory>${project.basedir}\src\integration-test\</workingDirectory>
<mainClass>${project.basedir}\src\integration-test\${start-class}</mainClass>
<arguments>
<argument>
spring.config.location=${project.basedir}\src\main\resources\application-${environment}.properties</argument>
</arguments>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<project>
**Command - ** spring-boot:run -Denvironment=dev -Dstart-class=com.abc.xyz.Integrationtest -Pintegrationtest

Maven: How to Add JPA Project in EAR using Pom.xml

How can I add JPA Project in the EAR pom.xml file? I don't see the JPA Module in the Maven.
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<earSourceDirectory>EarContent</earSourceDirectory>
<generateApplicationXml>false</generateApplicationXml>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<jarModule>
<groupId>artifactGroupId</groupId>
<artifactId>artifactId</artifactId>
<bundleDir>APP-INF/lib</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>

deployment of an ejb maven project from eclipse

I'm facing a weird problem and was not able to find somebody out there having the same behaviour creating a maven ear-ejb project in eclipse.
I have a parent pom that looks like this:
<modules>
<module>ear</module>
<module>ejb</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
the pom.xml from the ejb project:
<build>
<sourceDirectory>ejbModule</sourceDirectory>
<resources>
<resource>
<directory>ejbResources</directory>
</resource>
<resource>
<directory>ejbModule</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.4.RELEASE</version>
<scope>provided</scope>
</dependency>
</dependencies>
and finally the pom.xml of the ear project:
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<ejbModule>
<groupId>com.coba.test</groupId>
<artifactId>jms-test-ejb</artifactId>
<uri>jms-test-ejb.jar</uri>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.coba.test</groupId>
<artifactId>jms-test-ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
When running mvn eclipse:eclipse on the projects I am able to import them as existing projects and all natures and references are ok. When I run mvn clean package and deploy the ear to the server (tested on a websphere 8, jboss 7 and 8) the application (a single mdb) starts and acts as expected. BUT when I try to run the project from within eclipse no class from the shipped dependencies is found. When looking into the deployment assembly of the projects then (how it should be) all dependencies are listed in the ear project and the none of them appears in the ejb project. I had a look at the maven-eclipse-plugin and it does explicitly write the to deployed components to the ear project, so I think this is the way it should be. But when I manually add the classpath entries to the deployment assembly to the ejb project the application gets deployed and starts without any Problems.
Is this a Problem of my project setting or a maven-eclipse-plugin bug? Does anybody had this problem himself?
Thx for reading
Markus
EDIT:
I dot not use the m2eclipse plugin.

maven EAR plugin packages war-file twice when using bundleFileName

I want to package two .war files into an .ear file using the Maven EAR plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>package-mae</id>
<phase>package</phase>
<configuration>
<version>6</version>
<modules>
<webModule>
<groupId>de.ast</groupId>
<artifactId>mae-mobile</artifactId>
<contextRoot>/mobile</contextRoot>
<bundleFileName>/mae-mobile.war</bundleFileName>
</webModule>
<webModule>
<groupId>de.ast</groupId>
<artifactId>mae-rest</artifactId>
<contextRoot>/api</contextRoot>
<bundleFileName>/mae-rest.war</bundleFileName>
</webModule>
</modules>
</configuration>
<goals>
<goal>generate-application-xml</goal>
<goal>ear</goal>
</goals>
</execution>
</executions>
</plugin>
It works nicely apart from the fact that the war files are packages twice each, i.e. the ear file contains:
mae-rest.war
mae-rest-0.0.1-SNAPSHOT.war
mae-mobile.war
mae-mobile-0.0.1-SNAPSHOT.war
How can I avoid this duplication?
Thanks,
Ronald
I would suggest to change the configuration which you have into the following:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<version>6</version>
<modules>
<webModule>
<groupId>de.ast</groupId>
<artifactId>mae-mobile</artifactId>
<contextRoot>/mobile</contextRoot>
<bundleFileName>mae-mobile.war</bundleFileName>
</webModule>
<webModule>
<groupId>de.ast</groupId>
<artifactId>mae-rest</artifactId>
<contextRoot>/api</contextRoot>
<bundleFileName>mae-rest.war</bundleFileName>
</webModule>
</modules>
<generateApplicationXml>true</generateApplicationXml>
</configuration>
</plugin>
...
</plugins>
</build>
This should solve your problem.

Resources