type=page
status=published
title=undeploy
next=unfreeze-transaction-service.html
prev=stop-local-instance.html
~~~~~~

= undeploy

[[undeploy-1]][[GSRFM00244]][[undeploy]]

== undeploy

Removes a deployed component

[[sthref2189]]

=== Synopsis

[source]
----
asadmin [asadmin-options] undeploy [--help]
[--target target] [--droptables={true|false}]
[--cascade={false|true}] name
----

[[sthref2190]]

=== Description

The `undeploy` subcommand uninstalls a deployed application or module
and removes it from the repository.

This subcommand is supported in remote mode only.

[[sthref2191]]

=== Options

asadmin-options::
  Options for the `asadmin` utility. For information about these
  options, see the link:asadmin.html#asadmin-1m[`asadmin`(1M)] help page.
`--help`::
`-?`::
  Displays the help text for the subcommand.
`--cascade`::
  If set to `true`, deletes all the connection pools and connector
  resources associated with the resource adapter being undeployed. If
  set to `false`, the undeploy fails if any pools and resources are
  still associated with the resource adapter. Then, either those pools
  and resources must be deleted explicitly, or the option must be set to
  `true`. If the option is set to `false`, and if there are no pools and
  resources still associated with the resource adapter, the resource
  adapter is undeployed. This option is applicable to connectors
  (resource adapters) and applications. Default value is false.
`--droptables`::
  If set to true, drops the tables that the application created by using
  CMP beans during deployment. If set to false, tables are not dropped.
  If not specified, the value of the `drop-tables-at-deploy` entry in
  the `cmp-resource` element of the `glassfish-ejb-jar.xml` file
  determines whether or not tables are dropped. Default value is true.
`--target`::
  Specifies the target from which you are undeploying. Valid values are:

  `server`;;
    Undeploys the component from the default server instance `server`
    and is the default value.
  `domain`;;
    Undeploys the component from the domain.
  cluster_name;;
    Undeploys the component from every server instance in the cluster.
  instance_name;;
    Undeploys the component from a particular stand-alone server
    instance.

[[sthref2192]]

=== Operands

name::
  Name of the deployed component. +
  The name can include an optional version identifier, which follows the
  name and is separated from the name by a colon (`:`). The version
  identifier must begin with a letter or number. It can contain
  alphanumeric characters plus underscore (`_`), dash (`-`), and period
  (`.`) characters. To delete multiple versions, you can use an asterisk
  (`*`) as a wildcard character. For more information about module and
  application versions, see "link:application-deployment-guide/overview.html#GSDPG00324[
  Module and Application Versions]" in {productName} Application
  Deployment Guide.

[[sthref2193]]

=== Examples

[[GSRFM769]][[sthref2194]]

==== Example 1   Undeploying an Enterprise Application

This example undeploys an enterprise application named `Cart.ear`.

[source]
----
asadmin> undeploy Cart
Command undeploy executed successfully.
----

[[GSRFM770]][[sthref2195]]

==== Example 2   Undeploying an Enterprise Bean With Container-Managed Persistence (CMP)

This example undeploys a CMP bean named `myejb` and drops the
corresponding database tables.

[source]
----
asadmin> undeploy --droptables=true myejb
Command undeploy executed successfully.
----

[[GSRFM771]][[sthref2196]]

==== Example 3   Undeploying a Connector (Resource Adapter)

This example undeploys the connector module named `jdbcra` and performs
a cascading delete to remove the associated resources and connection
pools.

[source]
----
asadmin> undeploy --cascade=true jdbcra
Command undeploy executed successfully.
----

[[sthref2197]]

=== Exit Status

0::
  subcommand executed successfully
1::
  error in executing the subcommand

[[sthref2198]]

=== See Also

link:asadmin.html#asadmin-1m[`asadmin`(1M)]

link:deploy.html#deploy-1[`deploy`(1)],
link:list-components.html#list-components-1[`list-components`(1)],
link:redeploy.html#redeploy-1[`redeploy`(1)]

link:application-deployment-guide.html#GSDPG[{productName} Application Deployment
Guide]


