Issue Details (XML | Word | Printable)

Key: CARGO-416
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Marie
Votes: 9
Watchers: 11
Operations

If you were logged in you would be able to see more operations.
Cargo

JMX deployer currently uses the same path on the local filesystem and on the server one

Created: 26/Sep/06 01:22 AM   Updated: 25/Feb/09 04:11 PM
Component/s: JBoss, Maven2
Affects Version/s: 0.3-maven2
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File CARGO-416.patch (28 kB)
2. Text File jboss-remote-deploy.patch (20 kB)
3. Java Source File JettyHTTPFileServerTest.java (0.7 kB)


Complexity: Intermediate
Tested on JDKs: 1.5


 Description  « Hide
I have trouble deploying to a remote JBoss server using the cargo-maven2 plugin from my local PC. I have posted on the cargo newsgroup and received this answer:

"Your configuration looks good. I've just checked the source code the JBoss remote deployer (JBossRemoteDeployer.java class) and there are 2 things:

  • We're using the JBoss JMX deployer which requires the deployable to be deployed to be present on the server filesystem.
  • The location used by our JMX deployer currently uses the same path on the local filesystem and on the server one. This is a bad limitation (I'm surprised nobody raised this before). I'd suggest you create a JIRA issue for this.

The current solution I can think of would be to create a JBossDeployable class that extends Deployable and adds a setRemoteFile(String) method. For a m2 user this would mean configuring it like this:

<deployable>
[...]
<properties>
<remoteFile>...</remoteFile>
</properties>
</deployable>

However we really need to find a way to deploy a local file to a remote JBoss server. This would remove the need for this JBossDeployable class and would be much easier.

Thanks

-Vincent
"

I also think there should be an improvement to this plugin to allow remote deployments from local PCs.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Randal Cobb added a comment - 30/Apr/07 03:37 PM
I'm seeing this same problem with JBoss 4.0.4. In my case, Continuum is running a nightly m2 build that does nothing more than a cargo:redeploy of an ear file. I see in the logs that it is in the process of deploying the WAR file inside the EAR when it happens to me. The wrapper class (mentioned above) doesn't seem to help in my case.

If it matters, this is a linux workstation with jboss installed locally and using the following pom configuration:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>jboss4x</containerId>
<type>remote</type>
<timeout>240000</timeout>
</container>
<configuration>
<type>runtime</type>
</configuration>
<deployer>
<deployables>
<deployable>
<groupId>com.company.projectGroup</groupId>
<artifactId>projectEAR</artifactId>
<type>ear</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>


Matt Wringe added a comment - 11/Jun/08 01:09 PM
The problem here is that the jmx deployer doesn't accept a file as a parameter, but a url. This makes it difficult to upload a file to the server remotely.

We are going to have to either to create an http/ftp server and make the war available so that the jmx deployer can grab it from the url (this is probably the easiest solution, but opens up some security issues), or completely rethink how we are going to handle remote deployment for JBoss (perhaps using something like the Tomcat Manager).


Thor Åge Eldby added a comment - 19/Jan/09 09:28 AM
Hi
I've created a patch for jboss remote deploy (see attached jboss-remote-deploy.patch). It implements some changes to the Carge Core JBoss Container and may be patched at core/containers/jboss. It is done by setting up an ad-hoc Jetty resource handler and instruct JBoss to retrieve the deployable from that. I've only had opportunity to test it with JBoss 4.0.5.

Matt Wringe added a comment - 19/Jan/09 09:38 AM
my only concern with this is that it should be done in a secure manner, or the user should be able to make it secure themselves.

I think it should be fine as long as we make sure its well documented that its not being sent in a secure manner. Its at least better than the broken way we have now.


Adrian Cole added a comment - 19/Jan/09 01:29 PM
I've read through the implementation and it seems to be a valid and clever workaround to the JBoss limitation as noted in thread http://www.jboss.com/index.html?module=bb&op=viewtopic&t=128025

That said, it increases complexity, spawning a server thread that could die unexpectedly. It also opens configuration management of the listen host/port of jetty, which could easily collide on multi-purpose build machines. I suggest we leave this as a temporary measure until we get the design right.

I think Vincent's original idea is doable: remoteFile. I might name it destination or the like, and have it optional. If present, it will accept a VFS url, which opens us up to local, cifs, sftp, ftp, webdav and other implementations of file systems. In this regard, we don't have to write/test file system code.

Thoughts?


Gabriele Columbro added a comment - 03/Feb/09 10:51 AM
I'm applying this fix locally to be able to deploy to a remote build server in the CI environment.

Any idea to apply a fix version? I'd really go for it, as for now it will solve many infrastructural problems and allow cargo to be much more widespread in enterprise jboss based environments.

In addition to that, it's not easy to maintain a patched snapshot (or with a classifier) version of cargo until this gets applied just for your development community.

My 0.2€.

Ah, and thanks for the great patch. Genius.


Nicolas Jouanin added a comment - 20/Feb/09 07:46 AM
My 0.2€ comment :
I've successfully applied the patch to the current SVN trunk version. Now deployable file is correctly downloaded to the server and successuflly deployed.
I hope this patch can be integrated soon in the main trunk.

Thanks again for this patch.


Adrian Cole added a comment - 21/Feb/09 03:05 PM
I will clean up a few parameters in order to harden this for our 1.0 release. Here are the changes:

rename property: DEPLOYABLE_HOST_PORT = "cargo.jboss.port" to
REMOTEDEPLOY_PORT = "cargo.jboss.remotedeploy.port";
-> change default from 18080 to 1+whatever the http port is. This will help reduce the number of configuration items needed in order to avoid port conflicts

add property:
REMOTEDEPLOY_ADDRESS = "cargo.jboss.remotedeploy.address";
-> default is the local machine name, but as this isn't always preferred, we will allow an override

Other changes:

  • Remove test cases that start an httpd process. These sort of test cases make things brittle and are better done with mocks.
  • Change to FileHandler() api as opposed to java.io. This is because FileHandler can be unit tested more easily.

Adrian Cole added a comment - 21/Feb/09 06:29 PM
Here is a more cleaned-up version of the patch. It is better then before, but needs a lot better test coverage before we commit.

Adrian Cole added a comment - 21/Feb/09 06:31 PM
the current patch is in better shape then the last. I'm looking for a volunteer to help increase the quality and test coverage on this before we commit to trunk.

Nicolas Jouanin added a comment - 23/Feb/09 03:21 AM
I've some difficulties to include CARGO-416.patch as some path segments are unmatched when trying to apply the patch from Eclipse.
Could you give me instructions on how to include it ? Should I apply this patch directly over the last checked out trunk version or should I first apply jboss-remote-deploy.patch ?

Adrian Cole added a comment - 23/Feb/09 04:10 AM
repaired patch. Please apply this in the following fashion.

1. download to location you checked out trunks
2. apply via "patch --binary -p0 -i CARGO-416.patch"

note that if you don't have cygwin, and you are using windows, you can download patch.exe here: http://gnuwin32.sourceforge.net/packages/patch.htm


Nicolas Jouanin added a comment - 23/Feb/09 07:45 AM
Hi,
I could apply the corrected patch successfully.
First feedback :
There seems to have an issue with the management of the URL in JettyHTTPFileServer because here is the error message I got back from JBoss when deploying :
org.codehaus.cargo.container.ContainerException: Failed to deploy to [http://10.156.216.147:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jb
oss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=http%3A%2F%2F10.156.220.90%3A18080paruemas-1.0-SNAPSHOT.war]
You can see that there's an encoded '/' missing 18080 and paruemas-1.0-SNAPSHOT.war at the end of the URL.
I will send a test case for this as attachement to this issue.
Also note that it seems that this error only gets back when the deployable is declared with groupId and artifactId. When the deployable is a location (something like <location>target/cactified-${project.build.finalName}.war</location>) , I have no feedback from jboss until URL invocation timeout.
Here my modified version of JettyHTTPFileServer.buildUrl:
protected URL buildUrl(InetSocketAddress listenSocket, String fileName)
{
try
{
String fullFileName = "";
if (!fileName.startsWith("/")) { fullFileName = "/" + fileName; }

else

{ fullFileName = fileName; }

return new URL("http", listenSocket.getHostName(), listenSocket.getPort(),
fullFileName);
}
catch (MalformedURLException e)

{ throw new CargoException("Could not create a url for " + listenSocket + " and file: " + fileName, e); }

}

With this correction, the deployable is successfully deployed on Jboss.


Nicolas Jouanin added a comment - 23/Feb/09 07:46 AM
Stupid test case to show the URL management error in JettyHTTPFileServer.

Nicolas Jouanin added a comment - 24/Feb/09 02:59 AM
Hi,

Regarding my last comment saying that is the deployable was a location there were no feeback from Jboss, it seems that things are a bit different.
In fact, whether the deployable is a location or an artifact, it is deployed remotelly only if maven is run in offline mode (-o). I don't know why, but if maven is not run with -o option, JbossRemoteDeployer.invokeUrl() doesn't return from the call to this.connection.connect(url, username, password); In offline mode this call comes back when correctly when the war has been deploed remotelly. Strange ...


Nicolas Jouanin added a comment - 25/Feb/09 07:47 AM
In complement to the previous comment, invokeURL only works if I don't have a proxy defined in settings.xml or if I run maven with the -o option.
Otherwise I get the following exception, which only comes after some kind of timeout:

2009-02-25 14:35:34.250::INFO: Started SocketConnector@10.156.220.90:18080
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to deploy to http://10.156.216.147:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=http%3A%2F%2F10.156.220.90%3A18080%2Fcactified-paruemas-1.0-ice-SNAPSHOT.war
Server returned HTTP response code: 504 for URL: http://10.156.216.147:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=http%3A%2F%2F10.156.220.90%3A18080%2Fcactified-paruemas-1.0-ice-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.codehaus.cargo.container.ContainerException: Failed to deploy to http://10.156.216.147:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=http%3A%2F%2F10.156.220.90%3A18080%2Fcactified-paruemas-1.0-ice-SNAPSHOT.war
at org.codehaus.cargo.container.jboss.internal.JdkHttpURLConnection.connect(JdkHttpURLConnection.java:58)
at org.codehaus.cargo.container.jboss.JBossRemoteDeployer.invokeURL(JBossRemoteDeployer.java:275)
at org.codehaus.cargo.container.jboss.JBossRemoteDeployer.invokeRemotely(JBossRemoteDeployer.java:200)
at org.codehaus.cargo.container.jboss.JBossRemoteDeployer.deploy(JBossRemoteDeployer.java:164)
at org.codehaus.cargo.maven2.DeployerDeployMojo.performDeployerActionOnSingleDeployable(DeployerDeployMojo.java:79)
at org.codehaus.cargo.maven2.AbstractDeployerMojo.performDeployerActionOnAllDeployables(AbstractDeployerMojo.java:104)
at org.codehaus.cargo.maven2.AbstractDeployerMojo.doExecute(AbstractDeployerMojo.java:47)
at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo.java:266)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.io.IOException: Server returned HTTP response code: 504 for URL: http://10.156.216.147:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=http%3A%2F%2F10.156.220.90%3A18080%2Fcactified-paruemas-1.0-ice-SNAPSHOT.war
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1290)
at org.codehaus.cargo.container.jboss.internal.JdkHttpURLConnection.connect(JdkHttpURLConnection.java:51)
... 25 more
java.io.IOException: Server returned HTTP response code: 504 for URL: http://10.156.216.147:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jb
oss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=http%3A%2F%2F10.156.220.90%3A18080%2Fcactified-paruemas-1.0-ice-SNAPSHOT
.war
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1290)
at org.codehaus.cargo.container.jboss.internal.JdkHttpURLConnection.connect(JdkHttpURLConnection.java:51)
at org.codehaus.cargo.container.jboss.JBossRemoteDeployer.invokeURL(JBossRemoteDeployer.java:275)
at org.codehaus.cargo.container.jboss.JBossRemoteDeployer.invokeRemotely(JBossRemoteDeployer.java:200)
at org.codehaus.cargo.container.jboss.JBossRemoteDeployer.deploy(JBossRemoteDeployer.java:164)


Nicolas Jouanin added a comment - 25/Feb/09 04:11 PM
Finally I think this proxy problem is not related specifically to cargo but to the way the proxy manages local address. I can workaround this problem by using nonProxyHosts, so that's just a matter of maven proxy settings.
Now, i've been able to test the patch for several days and it's working fine. There's still the bug I mentioned on a previous comment concerning a missing '/' in the invoked URL, but this should be easy to fix.