Tech-Today
Deploy a j2ee ear in glassfish using maven
The ff code will explain how a j2ee ear project can be deploy by invoking a maven goal.
The plugin: http://maven-glassfish-plugin.java.net/deploy-mojo.html
To deploy to a glassfish server using maven, invoke (inside your ear project):
mvn glassfish:deploy
You need to add the ff plugin to your ear's pom.xml
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<glassfishDirectory>${local.glassfish.home}</glassfishDirectory>
<user>${local.glassfish.user}</user>
<passwordFile>${local.glassfish.passfile}</passwordFile>
<autoCreate>true</autoCreate>
<debug>true</debug>
<echo>false</echo>
<terse>true</terse>
<domain>
<name>${local.glassfish.domain}</name>
<adminPort>4848</adminPort>
<httpPort>8080</httpPort>
<httpsPort>8443</httpsPort>
<iiopPort>3700</iiopPort>
<jmsPort>7676</jmsPort>
<reuse>false</reuse>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>
${project.build.directory}/${project.build.finalName}.ear
</artifact>
</component>
</components>
</configuration>
</plugin>
Take note that the plugin reads a password file that can be save anywhere you want as long as you have access to it. I've placed mine inside the glassfish's home directory for easier reference. It contains the glassfish's admin password. If you forgot to set this you'll get authentication error.
AS_ADMIN_PASSWORD=my_glassfish_admin_password
Also by default glassfish:deploy goal is calling asadmin, so it works perfectly on linux but not on windows. To be able to do so simply delete or rename asadmin to asadmin.sh. This way the plugin will read asadmin.bat for windows.
-
How To Generate Jax-rs Documentation Using Maven
To generate the jax-rs documentation automatically using maven, we need to add some plugins in the build section of the project's pom file. To avoid running this plugin every time you invoke mvn install, you can create a separate profile for it. Here's...
-
How To Get Git Build Id Using Maven
There are times when git's build number is important for a release. Specially in development mode, when there are frequent releases. So if we want to append the build number on our page, how do we automate it? For us to achieve this we will need 2...
-
A Maven Project That Have Multiple Property Files Via Maven Antrun Plugin
This tutorial will answer several questions (below) within a maven project that has several configuration files (dataset, property, persistence). 1.) How to have multiple persistence, datasource and property files depending on the profile or environment...
-
Persist Jms Message In A Database In Glassfish
This tutorial will guide you on how to configure Java Messaging Service in Glassfish to store JMS message in a postgresql database. What you need (configured and running): 1.) Glassfish 3.1.2.2 2.) Postgresql 9.1 3.) JMS Broker (integrated with Glassfish)...
-
Deploy A Javaee6 War In Tomcat7 Using Maven
Recently, I'm trying to deploy a simple web application (war) in tomcat7 but it seems the old maven way of deploying a war will not work on it. The plugin I used to use for tomcat6 is: <plugin> <groupId>org.codehaus.mojo</groupId>...
Tech-Today