I am using eclipse JUNO integrated with websphere 8.5.My problem is that,my project is in MAVEN module so each time i have to clean and install the MAVEN Project to generate the EAR.
After EAR generation, I have to remove the ibm related xml's inside the META-INF folder and WEB-INF folder and then I have to open the administrative console in websphere to deploy the EAR.This alone is taking huge amount of time.
Could any one please suggest a script to deploy and run the MAVEN project in websphere.
<?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>
<groupId>com.sample.app</groupId>
<artifactId>SAMPLE_APP</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>SAMPLE APP</name>
<modules>
<module>SAMPLE_APP_Props</module>
<!-- Changes to UI Framework -->
<module>SAMPLE_APP_UIFile</module>
<module>SAMPLE_APP_Web</module>
<module>SAMPLE_APP_EAR</module>
<module>SAMPLE_APP_Forms</module>
<module>SAMPLE_APP_Filters</module>
<module>SAMPLE_APP_Logging</module>
<module>SAMPLE_APP_Security</module>
</modules>
<build>
<pluginManagement>
<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>
</pluginManagement>
</build>
</project>
The below 2Files i have to remove before i deploy the generated ear in websphere.
ibm-application-bnd.xmi
ibm-application-ext.xmi
Related
I have a simple Java Spring MVC web app. I build the WAR file using a Maven pom.xml file.
When I do a "maven install", it produces a WAR file with my compiled Java classes in the /WEB-INFO/classes folder.
My maven pom.xml looks like this (dependencies commented out) ...
<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>mycompany.com</groupId>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>My Application</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- .... -->
</dependencies>
<build>
<finalName>myapp</finalName>
</build>
</project>
Next I want to obfuscate my Java classes (I'll be using Allatori obfuscater), so I'm thinking the easiest thing would be if my Java classes were all put into their own JAR file and stored in the /WEB-INF/lib folder with the rest of the JARs.
Is there a way to modify my Maven pom.xml file so it will package of my classes up in a JAR and put the JAR in the /WEB-INF/lib folder?
UPDATE:
Adding this to the 'build' section (as suggested by "JF Meier" worked) ...
<build>
<finalName>myapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
</plugins>
</build>
You can use the <archiveClasses> configuration (set it to true) to generate an additional jar with the classes.
Also see:
https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html
Move your Java classes in a separate Maven module and add that as a dependency to your WAR project. Then you can do whatever is necessary creating the jar in that module.
Recently, I wrote a Spring-Boot project and I wanted that Maven will be able to create a jar file that I'll be able to run by the command "java -jar ".
This is the pom.xml I wrote:
<?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>SpringBootGame</groupId>
<artifactId>SpringBootGame</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.3.RELEASE</version>
<configuration>
<mainClass>com.game.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
In order to build the jar file, I had to run the command: "mvn clean package spring-boot:repackage".
My questions are:
Why must I add spring-boot-maven-plugin? I already have spring-boot-starter-web dependency that adds spring-boot as a dependency and maven-compiler-plugin that builds a jar file from the code?
Can you think about a way to configure pom.xml file that I'll be able to get the jar file using the "native" command "mvn clean package" and not the cumbersome "mvn clean package spring-boot:repackage"?
Thanks
Why must I add spring-boot-maven-plugin? I already have spring-boot-starter-web dependency that adds spring-boot as a dependency and maven-compiler-plugin that builds a jar file from the code?
Because the plugin is what adds Maven support for Spring Boot
Can you think about a way to configure pom.xml file that I'll be able to get the jar file using the "native" command "mvn clean package" and not the cumbersome "mvn clean package spring-boot:repackage"?
It looks like you are missing the <packaging>jar</packaging> element in between your <project> </project> element.
The reason you had to run that lengthy command, is because you did not include the <executions></executions> element when including the plugin. Please see section 71.1 of the following docs:
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html#build-tool-plugins-include-maven-plugin
71.2 elaborates on the <packaging> element.
In the configuration of the maven plugin you have already in place, you need to add the executable block like :
<configuration>
<executable>true</executable>
</configuration>
this will create in the target folder the runnable jar that can be run by using java -jar command.
I have a multi-module maven project that is used to produce a single spring boot fat jar. My project looks something like this.
- Parent Module Aggergator
- A
- B
- C
- app <-- app.jar is the only thing I want to publish
In my case module A, B, C are only ever used by app and should not be published into maven repo. I have split up the app into multi-module project because it's a lot of code in the app and it's to work with that way.
Currently the app.jar will contain inside it a.jar, b.jar c.jar.
Is there a way to tell maven that the compiled classes from module A, B, C should just be inserted into app.jar classes folder without ever producing A.JAR, B.JAR, C.JAR?
I use the Maven Shade Plugin for my multi-module project; it creates a single JAR and extracts each module into it rather than creating multiple JAR files:
Parent 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>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<groupId>...</groupId>
<artifactId>pipeline</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>firehose</module>
<module>gson</module>
<module>lambda</module>
<module>mapper</module>
<module>model</module>
<module>receiver</module>
<module>redshift</module>
<module>reloader</module>
<module>s3</module>
<module>sns</module>
<module>sqs</module>
<module>systemstests</module>
<module>transaction</module>
<module>utility</module>
</modules>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Child pom.xml (the JAR):
<?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>
<groupId>...</groupId>
<artifactId>pipeline</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>lambda</artifactId>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<finalName>MyJar</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
Here is a non answer.
Is there a way to tell maven that the compiled classes from module A,
B, C should just be inserted into app.jar classes folder without ever
producing A.JAR, B.JAR, C.JAR?
You could use the repackage goal of the spring boot maven plugin that flatten the dependencies into classes in the uber jar.
In my case module A, B, C are only ever used by app and should not be
published into maven repo.
Adding the modules in a local repository is really wanted to have a efficient and standard build.
Without that, you will need to compile systematically each module at each time you want to run your spring boot app.
While actually sometimes you need to build dependencies, but other times you don't need because these are already updated.
Or else you will be constraint to twist the default Maven way of work by adding manual tasks to compile from the spring boot module the other modules and to move the compiled classes into the spring boot module. Really not a gift for the people that will have to read/maintain this configuration.
Goal: Create an executable uber jar with maven shade plugin that can be executed during the mvn compile of another pom.
Repro steps:
Create a pom.xml for the "publisher" component using below pom.
Use a Jenkins build to mvn deploy it (mvn install will work as well)
Add dependency to pom.xml for "consumer" (pom below)
mvn compile the consumer
Expected behavior:
Uber jar for publisher is downloaded somewhere in consumer/target directories
Actual:
Uber jar does not appear in consumer directory
Component 1: Publisher
<?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.mec.experiment</groupId>
<artifactId>publisher</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.6.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.mf</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Component 2: Consumer
<?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.mec.experiment</groupId>
<artifactId>consumer</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.mec.experiment</groupId>
<artifactId>publisher</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
The answer from the possible duplicate I linked to in the comments has a link to a dead example page. Here's a supplement for you. The plugin configuration would belong inside the consumer pom.
exec:java
Full name:
org.codehaus.mojo:exec-maven-plugin:1.5.0:java
Description:
Executes the supplied java class in the current VM with the enclosing project's dependencies as classpath.
Attributes:
Requires a Maven project to be executed.
Requires dependency resolution of artifacts in scope: test.
The goal is thread-safe and supports parallel builds.
Since version: 1.0.
See especially executableDependency for your use case. That looks like it will allow you to reference producer according to its group id and artifact instead of hard-coding a path.
I would like to create an ear containing only dependency jar files using maven.
<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">
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
</dependency>
......
......
......
</dependencies>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<jarModule>
<groupId>groupId</groupId>
<artifactId>artifcatId</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
</modules>
...............
...............
</configuration>
</plugin>
</plugins>
</project>
Maven created application.xml automatically which has entries for these jars but still, when deploying, I am getting message in console - "No modules found in ear."
Could you help me out what am I missing here.
An EAR file should contain WARs, RARs, SARs, and EJB JARs. Anything else, including basic library JARs, are unimportant as far as the EAR is concerned and and EAR with just those kind of files is useless as far as a Java EE Application Server is concerned.