How to Run Asadmin Commands in Embedded GlassFish

You can leverage your experience and knowledge about the GlassFish command line tool,  asadmin, with Embedded GlassFish servers.

Here is a use case:

You want an  Embedded GlassFish server that uses a JavaDB database.  You need to setup a few things in the server configuration.  You can do this configuration in your code every time you start using the CommandExecutor.  Another possibility is to do the following:

  1. start the Embedded GlassFish server -- making sure autodelete is off
  2. Run asadmin commands for configurationmbedded GlassFish server
  3. Stop the Embedded GlassFish server
  4. Always set the install-root to the root of the generated file system from steps 1,2.

Here is how to run asadmin in Embedded GlassFish (embedded.jar is the Embedded GlassFish all-in-one jar file that you have downloaded or built)

Windows:

java -cp final.jar com.sun.enterprise.admin.cli.AsadminMain %\*

\*NIX:

java -cp final.jar com.sun.enterprise.admin.cli.AsadminMain $\*


Comments:

I wonder whether I can use this to write unit tests for EJBs..

Posted by blah on July 13, 2009 at 08:32 PM PDT #

For EJB testing, GlassFish v3 implements the now standard EJBContainer.createEJBContainer() API. You'll need to have glassfish/lib/embedded/glassfish-embedded-static-shell.jar in your classpath (or a bunch of maven dependencies). See http://blogs.sun.com/kensaks/entry/embeddable_ejb for an intro.

Posted by Alexis MP on September 23, 2009 at 04:51 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

ByronNevins

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
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