jeudi déc. 23, 2010

GlassFish Tip: log asadmin commands

This blog has moved to alexismp.wordpress.com
Follow the link for the most up-to-date version of this blog entry.

I don't think I've seen this tip mentioned before in blogs or documentation and yet have had the request from different users and customers. If you want to log all the asadmin commands, simply set the AS_LOGFILE environment variable to the name of a file.

% export AS_LOGFILE=/tmp/asadmin.log
% asadmin ...
% cat /tmp/asadmin.log
12/23/2010 14:31:33 EXIT: 0 asadmin list-domains
12/23/2010 14:32:39 EXIT: 1 asadmin start-domain
12/23/2010 14:33:27 EXIT: 0 asadmin start-domain
12/23/2010 14:33:58 EXIT: 0 asadmin list-domains
12/23/2010 14:34:04 EXIT: 0 asadmin list-applications
12/23/2010 14:34:21 EXIT: 0 asadmin undeploy org.beginningee6.tutorial_demo11_war_1.0
12/23/2010 14:38:13 EXIT: 0 asadmin stop-domain
12/23/2010 14:38:46 EXIT: 1 asadmin start-domain
12/23/2010 14:41:00 EXIT: 0 asadmin --verbose start-domain domain1
12/23/2010 14:41:58 EXIT: 0 asadmin get servers.\*
12/23/2010 14:42:14 EXIT: 0 asadmin get servers.server.server.resource-ref.jdbc/__TimerPool.enabled
12/23/2010 14:44:37 EXIT: 0 asadmin deploy ../../HelloHK2bis.war

If you think this should be the default behavior, file an issue (with "3.2" as the "Fix Version"). I'll vote for it!
If you're trying to troubleshoot asadmin (or simply curious) you can set export AS_DEBUG=true to obtain a chatty output.

mercredi sept. 01, 2010

asadmin common options (remote, secure, log)

With recent versions of GlassFish 3.0 (and beyond), the asadmin syntax has been cleaned up a bit and you might find your old syntax not working anymore for instance for doing remote operations on a given server and port.

asadmin now has a well-defined set of "common" options such as --host, --port, --terse that are independent of the subcommand used (start-domain, deploy, etc.). The full list of such options is documented here.

For instance, here's how to redeploy hello.war to a GlassFish server running on myserver.mydomain with admin port set to 4848 while preserving sessions :

      asadmin --host mymachine.myport --port 4848 redeploy --properties keepSessions=true hello.war

lundi mars 08, 2010

GlassFish without the IDE (quick survival guide)

This blog has moved to alexismp.wordpress.com
Follow the link for the most up-to-date version of this blog entry.

A lot of people experiment GlassFish for the first time via an IDE (most likely NetBeans, but maybe also with Eclipse) and feel a bit lost when it comes to use GlassFish without the tool driving it for them. So here are a few (mostly basic) CLI asadmin hints for GlassFish v3 :

* Start/Stop *
Start GlassFish (need this to access the admin console on default port http://localhost:4848) :
     % GLASSFISH_HOME/bin/asadmin start-domain     (assumes there's only one domain)
     % asadmin start-domain domain1     (explicitly reference a given domain)
     % asadmin start-domain -v domain     (will cause the log to be dumped to the standard output)
     % java -jar modules/glassfish.jar     (may be useful in certain circumstance (explicit java version for instance)

Stop GlassFish :
     % asadmin stop-domain {domain1}

List existing instances (including stopped/started status)
     % asadmin list-domains

You can also create additional domains with % asadmin create-domain ... (and I would suggest using the -portbase option).

* Resources *
If the IDE has created connection pools and datasources, you will certainly find the following create-jdbc-connection-pool and create-jdbc-resource commands useful. Note also that asadmin has a "closest match" feature for misspelled commands and extensive online documentation :
% ~/glassfishv3/bin/asadmin create
CLI001 Invalid Command: create
Closest matching local and remote command(s):
     create-admin-object
     create-audit-module
     create-auth-realm
     create-connector-connection-pool
     create-connector-resource
     create-connector-security-map
     create-connector-work-security-map
     create-custom-resource
     create-domain
     create-file-user
     create-http
     create-http-listener
     create-iiop-listener
     create-javamail-resource
     create-jdbc-connection-pool
     create-jdbc-resource
     create-jms-host
     create-jms-resource
     create-jmsdest
     create-jndi-resource
     create-jvm-options
     create-lifecycle-module
     create-message-security-provider
     create-network-listener
     create-password-alias
     create-profiler
     create-protocol
     create-resource-adapter-config
     create-resource-ref
     create-service
     create-ssl
     create-system-properties
     create-threadpool
     create-transport
     create-virtual-server

Almost every bits of configuration is located in the glassfish/domains/domain1/config/domain.xml config file but you really should be using asadmin or the admin console and not edit this by hand.

Starting with GlassFish 3.1, you can use "application-scoped resources" (see documentation, screencast). Such resources are created at deploy-time, usable only by the application they ship with and are destroyed upon undeploy.

* (auto)deployment *
The explicit deployment is based on the asadmin deploy app.{ear|war|jar} command. Listing deployed applications is as easy as asadmin list-application (notice how GlassFish tells you which containers are at work for a given app), and undeployment simply requires a asadmin undeploy app-name.

While these commands have lots of options (asadmin deploy --help for details), you may find it convenient to simply drop your application in the domain1/autodeploy directory. Deleting the file will trigger the undeployment.

All the details for the asadmin CLI can be found in the official "Using the asadmin Utility" documentation.

* JavaDB/Derby database *
If you'd like to move your tables and data from the JavaDB instance used in NetBeans to another one (maybe the one that ships with GlassFish), exporting the data and creating one from the backup is probably a good approach if you don't have SQL code to re-created it all. Look for "Backing up and restoring databases" in the Derby Admin Guide.

dimanche mars 08, 2009

Lastest episode of the GlassFish Podcast available - asadmin

The latest episode of the GlassFish podcast is an edited version of the GlassFish TV session (archive) from a couple of weeks ago.

For the sake of the length of the podcast, I've arbitrarily edited out parts of the session. I hope it does not degrade the value of the content. Feedback welcome.

About

This blog has moved

Alexis Moussine-Pouchkine's Weblog

GlassFish - Stay Connected

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today
Blogroll

No bookmarks in folder

News

No bookmarks in folder