Using cargo to deploy war to remote Jboss7 server - jboss7.x

I would like to use Cargo to deploy my maven generated war file to a remote JBoss Server that is already running.
I have configured my pom.xml like this:
...
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-controller-client</artifactId>
<version>7.1.0.Final</version>
</dependency>
</dependencies>
<configuration>
<!-- Container configuration -->
<container>
<timeout>300000</timeout> <!-- 5 minutes -->
<containerId>jboss71x</containerId>
<type>remote</type>
</container>
<!-- Configuration to use with the container -->
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname><myIP></cargo.hostname>
<cargo.jboss.management.port>9999</cargo.jboss.management.port>
<cargo.remote.username><myUser></cargo.remote.username>
<cargo.remote.password><myPass></cargo.remote.password>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
</deployer>
<!-- Deployables configuration -->
<deployables>
<deployable>
<groupId>de.<myGroup></groupId>
<artifactId><myArtifact></artifactId>
<type>war</type>
<pingURL>http://<myIP>:8080/<myContextPath></pingURL>
<pingTimeout>60000</pingTimeout>
</deployable>
</deployables>
</configuration>
</plugin>
...
Of course all variables of the form <my...> are filled out with the real values.
If I run this with the maven command:
mvn -X cargo:deploy
The maven console says:
...
Sep 12, 2012 5:06:12 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Sep 12, 2012 5:06:12 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.2.GA
[DEBUG] [swordCallbackHandler] Responded to a RealmCallback
[DEBUG] [swordCallbackHandler] Responded to a NameCallback
[DEBUG] [swordCallbackHandler] Responded to a PasswordCallback
[INFO] [Boss7xRemoteDeployer] The deployment has failed: org.codehaus.cargo.util.CargoException: Cannot deploy deployable org.codehaus.cargo.container.jboss.deployable.JBossWAR[myWar.war]
...
On the running JBoss server I can see a logging message in the console like this:
17:07:24,197 ERROR [org.jboss.remoting.remote.connection] (Remoting "pc09:MANAGEMENT" read-1) JBREM000200: Remote connection failed: java.io.IOException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen.
(sorry for the german inside of the log. It basically says: An existing connection was closed by the remote host.)
Does anybody have an idea what could be wrong or how I could get more debug info from cargo to find out what exactly the problem is?
BTW: I have used the JBoss CLI access to that Jboss Server for Arquillian tests so I am pretty confident that the access to that Jboss server via CLI should be ok.
EDIT:
Seems like I have to undeploy first. To reassure that the access to the CLI works I just connected to it using the jboss-cli.bat. Then I just coincidentally undeployed the existing war and after that the deployment via cargo started to work.
(Can I close this question or mark it as resolved in any way?)

Related

Connecting GlassFish/Payara to MySQL 8.x

I had a maven JSF/JPA web application that was connected to MySQL 5.x developed using Netbeans 12. The application was running fine until I updated the MySQL version from 5.x to 8.x. Since that update, I can not configure the database to connect to the JSF application. The connection to MySQL 8.x is working within Netbeans, but not working when deploying the application.
The current configuration include EclipseLink 2.7.7, MySQL 8.0.23, and GlassFish 5(5.0.1) / Payara 5(5.2021.1). It is not possible to make a successful connection to MySQL. I also failed to establish connection inside JDBS Connection Pool of GlassFish and Payara admin consoles. Can someone please direct me to a source where MySQL version 8 is linked to Payara or GlassFish?
The error displayed in the Payara admin console is as follows.
An error has occurred Ping Connection Pool failed for pooConnection.
Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. Please check the server.log for more details.
The log file contains the following.
[javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors.service] [tid: _ThreadID=161 _ThreadName=admin-thread-pool::admin-listener(3)] [timeMillis: 1613549343463] [levelValue: 900] [[
RAR8054: Exception while creating an unpooled [test] connection for pool [ pooConnection ], Connection could not be allocated because: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.]]
[2021-02-17T13:39:03.472+0530] [Payara 5.2021.1] [SEVERE] [] [org.glassfish.admingui] [tid: _ThreadID=139 _ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1613549343472] [levelValue: 1000] [[
RestResponse.getResponse() gives FAILURE. endpoint = 'http://localhost:4848/management/domain/resources/ping-connection-pool.json'; attrs = '{id=pooConnection}']]
In order to connect to Payara Server, the only effective way I found was creating a Connection Pool directly in the Domain Admin Console.
It may seem a long way now, but after completing it will become second nature:
Download MySQL8 Java Connector available at https://dev.mysql.com/downloads/connector/j/
and unzip to any folder:
It will extract to something like:
mysql-connector-java-8.0.23 2/mysql-connector-java-8.0.23.jar
1) Make sure you have Payara Server up and running:
cd PATH_TO_PAYARA/bin
2) Start/Restart it
./asadmin start-domain
Note: This will start domain1 by default
3) Install the MySQL8 Connector
./asadmin add-library PATH_TO_MYSQL_CONNECTOR.jar
4) (required) Restart Payara
./asadmin restart-domain
5) Access Admin Console at http://localhost:4848/common/index.jsf
6) In the sidebar navigate to "JDBC" -> "JDBC Connection Pools" menu
7) From there, click "New" to add new Connection Pool
You can have as many as you want. So if you have tried before, you may keep your pools there.
8) In: New JDBC Connection Pool (Step 1 of 2)
Pool Name: MySQL8Pool (or whatever you want)
Resource Type: javax.sql.DataSource
Database Driver Vendor: MySQL8
Click "Next"
9) Scroll down to "Adicional Properties"
Select all and "Delete Properties"
10) Add 6 Properties with the keys/values as:
DatabaseName YOUR_DB_NAME
User YOUR_DB_USER
Password YOUR_DB_PASSWORD
ServerName localhost
PortNumber 3306
UseSSL false
Click "Save"
11) In the sidebar navigate to "JDBC" -> "JDBC Resources" menu
12) From there, click "New" to add new JDBC Resource
And fill:
JNDI Name: jdbc/MySQL8App
PoolName: MySQL8Pool
Click "Save"
From now own I assume you are using Maven.
13) In you pom.xml make sure you have Eclipse Persistence
In you tag:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.asm</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.antlr</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.1</version>
</dependency>
14) Create a persistence unit in
In persistence.xml file:
<persistence-unit name="mysql8PU" transaction-type="JTA">
<jta-data-source>jdbc/MySQL8App</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<shared-cache-mode>NONE</shared-cache-mode>
<!--properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create OR create OR complete remove this line"/-->
</properties>
</persistence-unit>
Note that in jta-data-source it points to jdbc/MySQL8App and from now own it can be used any where in your code so that after built Payara is able to now we injected it.
PersistenceService.java
package com.your.package.services
import javax.enterprise.context.ApplicationScoped;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
#ApplicationScoped
public class PersistenceService {
#PersistenceContext(unitName = "mysql8PU")
EntityManager entityManager;
}
Now rebuild and rerun you project and everything should be fine!
Configure your connecion just in four steps:
Copy Mysql JDBC driver JAR to $PAYARA_HOME/glassfish/domains/$YOUR_DOMAIN/lib/ e. g.
cp mysql-connector-java-8.0.22.jar /opt/payara5/glassfish/domains/domain1/lib/
Create XML resources descriptor file, name it glassfish-resources.xml. Specify apprpriate params:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool connection-creation-retry-interval-in-seconds="30" connection-validation-method="auto-commit" datasource-classname="com.mysql.cj.jdbc.MysqlDataSource" wrap-jdbc-objects="false" res-type="javax.sql.DataSource" name="mysql_mydb_rootPool" is-connection-validation-required="true" connection-creation-retry-attempts="10" validate-atmost-once-period-in-seconds="60">
<property name="User" value="root"/>
<property name="Password" value="secret"/>
<property name="URL" value="jdbc:mysql://localhost:3306/voyager?zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=false"/>
<property name="driverClass" value="com.mysql.cj.jdbc.Driver"/>
<property name="characterEncoding" value="utf-8"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="jdbc/mydb" object-type="user" pool-name="mysql_mydb_rootPool"/>
</resources>
Add resources to Payara
$PAYARA_HOME/bin/asadmin add-resources glassfish-resources.xml
Restart your domain
$PAYARA_HOME/bin/asadmin restart-domain

remote deployment to wildfly using cargo fails

I am trying to deploy an application to a remote wildfly 8.1.0.Final using the cargo maven plugin and it fails with error Operation failed: Could not connect to remote://10.0.0.165:9990 in 5000ms.
The application is the default application generated by the maven archetype cargo-archetype-remote-deployment. This application can be successfully deployed to jboss 7.1.1.Final without modification to the pom. I have added the following profile to the pom
<profile>
<id>wildfly8x</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>wildfly8x</containerId>
</container>
<properties>
<!--<cargo.jboss.management-native.port>9999</cargo.jboss.management-native.port>-->
<cargo.jboss.management-http.port>9990</cargo.jboss.management-http.port>
</properties>
</configuration>
<!--
The JBoss remote deployer requires some additional dependencies. Read more on:
http://cargo.codehaus.org/JBoss+Remote+Deployer
-->
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-controller-client</artifactId>
<version>7.0.2.Final</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
which is a copy of the jboss7x profile with the changes for wildfly.
The properties at the beginning have been changed to correct hostname and username and passwords. I can log into the 10.0.0.165:9990 using http and access the web interface I can also us the jboss-cli interface to login to 10.0.0.165:9990 and deploy the application to the server using the command line. I have also increased the time out as recommended but without success.
It would appear that the remote:// protocol is not available in wildfly or the name is incorrect and cargo is expecting to be able to connect using it.
I have had problems with wildfly and the changes made to interfaces in the past when I connected Netbeans 8 to it. I did eventually find the solution to that by adding back the native management interface which was removed in one of the beta versions.
Does anybody have any knowledge on how to get this working? A copy of a pom from a working example would be good. Before replying please make sure that your reply is relevant to the versions specified as jboss/redhat make changes between dot point releases with very little documentation.
Hy,
I just have the same issue, i gues you copy the example from:
http://cargo.codehaus.org/JBoss+Remote+Deployer
And I found that the example is for JBOSS 7...
For Wildfly this is what worked for me:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.12</version>
<configuration>
<container>
<containerId>wildfly8x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>consoleUser</cargo.remote.username>
<cargo.remote.password>consolePassword</cargo.remote.password>
<cargo.hostname>IP_ADDRESS</cargo.hostname>
<cargo.jboss.management-http.port>9990</cargo.jboss.management-http.port>
</properties>
</configuration>
</configuration>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-controller-client</artifactId>
<version>8.2.0.Final</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
The shame on this is the documentation and that no java people community have answer this post... have to be a .NET guy... what a shame....

Deploying maven liferay project to remote Jboss based Liferay portal

I'm new with Liferay portal.
here is my config
--Liferay 6.1 deployed on JBoss AS 7.1.1 Final
--Maven 3.1.1
I can easily deploy my portlet(maven project) in local Liferay instance
but i'm trying to deploy this portlet to a remote instance
here is a part of my pom.xml
<properties>
<liferay.version>6.1.2</liferay.version>
<liferay.parent.server>C:\DEV\Env\JBoss</liferay.parent.server>
<liferay.auto.deploy.dir>${liferay.parent.server}\deploy</liferay.auto.deploy.dir>
<liferay.app.server.deploy.dir>${liferay.parent.server}\jboss-as-7.1.1.Final\standalone\deployments</liferay.app.server.deploy.dir>
<liferay.app.server.lib.global.dir>${liferay.parent.server}\jboss-as-7.1.1.Final\modules\com\liferay\portal\main</liferay.app.server.lib.global.dir>
<liferay.app.server.portal.dir>${liferay.parent.server}\jboss-as-7.1.1.Final\standalone\deployments\ROOT.war</liferay.app.server.portal.dir>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.version}</version>
<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
<liferayVersion>${liferay.version}</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
</plugin>
...
</build>
I would " liferay.parent.server " to target the remote directory something like 192.168.1.2/Env/JBoss
I have been working on for a long time
i will really appreciate your helps
Thank you
You need to install the Remote IDE Connector plugin to the remote instance of Liferay portal.
There are both CE version and EE version
Now you can deploy it via your Eclipse: tutorial
Or you can use Jenkins plugin, but be aware this issue (you need to download the source, fix it, and build it)
I remember that Liferay not support remote connector for JBoss.You can see this documents regard enter link description here Maven plugin for JBoss.
Sure, you can do remote deploy by maven plugin. You can read this guide http://www.dontesta.it/blog/en/blog-2/cms/liferay/liferay-maven-come-fare-il-deploy-remoto-dei-plugin/
In this article we will see a possible solution for remotely deploying the artifact of a Liferay project based on the maven
The plugin maven wagon-maven-plugin (or wagon) is what will allow you copy the WAR of our portlet on the remote server and then the hot deployment of Liferay (of which I recommend reading the hot deployment versus auto deploy) will carry out the actual installation. Listing 1 shows the wagon plugin configuration included within the plugins section of our project pom.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<fromDir>${project.build.directory}/</fromDir>
<includes>*.war</includes>
<url>scp://${jboss.deploy.username}:${jboss.deploy.password}#${jboss.deploy.hostname}/</url>
<toDir>${jboss.deploy.liferay.dir}</toDir>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.8</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Unable to deploy Mule app on mule standalone server

While using the Mule Maven plug-in to deploy the deployable archive on the Mule standalone server I receive this error intermittently.
Error : Caused by: org.apache.maven.plugin.MojoExecutionException:
Could not rename C:\mule-standalone\mule-ee-distribution-standalone-3.4.0\mule-enterprise-standalone-3.4.0\apps\**MyProject.zip**.temp
to C:\mule-standalone\mule-ee-distribution-standalone-3.4.0\mule-enterprise-standalone-3.4.0\apps\**MyProject.zip**
I am using the following Maven plug-in:
<plugin>
<groupId>org.mule.tools</groupId>
<artifactId>maven-mule-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<copyToAppsDirectory>true</copyToAppsDirectory>
</configuration>
</plugin>
This happens when you have a file opened in the mule apps folder. The maven-mule plugin is not able to rename /delete the older app and as a result the build fails.

Cargo not working over proxy integrated with maven 2

I have integrated Cargo plugin in my maven 2 project POM.xml.
During hot deployment I am unable to connect to my Tomcat container that is available across a proxy. My maven settings.xml already contain proxy setting but cargo is not picking it up.
I tried defining proxy settings for Cargo plugin expilicitly but that too didn't worked.
My plugin xml for Cargo is as:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<!--<version>1.0.1-alpha-1</version>-->
<version>1.0-beta-1</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.proxy.host>xxx.xxx.xxx.xxx</cargo.proxy.host>
<cargo.proxy.port>xxxx</cargo.proxy.port>
<cargo.hostname>xxx.xxx.xxx.xxx</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>80</cargo.servlet.port>
<cargo.tomcat.manager.url>http://xxx.xxx.xxx.xxx/manager</cargo.tomcat.manager.url>
<cargo.remote.username>xxxxxxx</cargo.remote.username>
<cargo.remote.password>xxxxxxx</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>Test</groupId>
<artifactId>Test</artifactId>
<type>war</type>
<!--
<properties> <context>optional root context</context>
</properties> <pingURL>optional url to ping to know if deployable
is done or not</pingURL> <pingTimeout>optional timeout to ping
(default 20000 milliseconds)</pingTimeout>
-->
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
Please help.
Thanks in advance.
Ashish
I may be wrong but I don't think Cargo support this. But, as the remote deployer for Tomcat uses the manager application and thus HTTP, try to set proxy settings at the JVM level by passing properties on the command line when invoking maven:
mvn cargo:deploy -Dhttp.proxyHost=<hostname> -Dhttp.proxyPort=<port>
Or use the environment variable MAVEN_OPTS:
export MAVEN_OPTS="-Dhttp.proxyHost=<hostname> -Dhttp.proxyPort=<port>"
Hopefully this issue with proxy will be fixed in Cargo 1.1.0