jenblog

pageicon Thursday Feb 05, 2009

Use CommandExecutor to run asadmin commands in Embedded GlassFish

CommandExecutor is a general API to programmatically run asadmin commands in Embedded GlassFish.
See javadocs. I'll show how you can use it.

You will need the glassfish-embedded-all-v3-prelude-*.jar. You can download the latest nightly build and use latest.jar.

Before you use CommandExecutor, you must first start Server:

EmbeddedInfo ei = new EmbeddedInfo();
Server server = new Server(ei);
server.start();
CommandExecutor ce = server.getCommandExecutor();

Look-up a command you want to try from the Administration Commands section of the Sun GlassFish Enterprise Server v3 Prelude Reference Manual

Let's try create-system-properties.
The command name is create-system-properties.
The default operand is one or more name-value pairs.

If you are familiar with asadmin commands, it would like this if you were running from the asadmin command line.

asadmin create-system-properties HTTP_LISTENER_PORT=38080:HTTP_SSL_LISTENER_PORT=38181

Using the CommandExecutor, the above would translate to

Properties options = new Properties();
options.setProperty("DEFAULT", "HTTP_LISTENER_PORT=38080:HTTP_SSL_LISTENER_PORT=38181");
ce.execute("create-system-properties", options);

Always use "DEFAULT" as the property name of the default operand. In addition to the default operand, other commands may have additional required options. For example, create-jdbc-connection-pool has datasourceclassname as a required option and connectionpoolid as the default operand.

asadmin create-jdbc-connection-pool --datasourceclassname myDataSourceClass myConnPool

becomes

options.setProperty("datasourceclassname", "myDataSourceClass");
options.setProperty("DEFAULT", "myConnPool");
ce.execute("create-jdbc-connection-pool", options);

Use options.clear() between different command executions.

You can also deploy a war.

asadmin deploy c:\samples\hello.war

becomes

options.setProperty("DEFAULT", "c:\\samples\\hello.war");
ce.execute("deploy", options);

Run your test class that deploys your war. The default port is 8888.

java -cp latest.jar;TestCommandExecutor.jar testcommandexecutor.Main

Check your web application. http://localhost:8888/hello/

I haven't tested all the commands that are supported in GlassFish v3 Prelude, but most should work. I do know that start-database and stop-database will not work because Embedded GlassFish does not bundle JavaDB.

pageicon Thursday Nov 06, 2008

Monitor GlassFish v3 Prelude with the Admin Console

GlassFish v3 Prelude has just been released. Download it here.
Basic monitoring for the web has been added in this release. It is based on a new lightweight framework.
Go ahead and try it out. Here are the steps to monitor from the Admin Console.

1. Start up GlassFish

2. Open the Administration Console in a browser at http://localhost:4848

3. Turn on Monitoring by setting Monitoring Service levels for a component to HIGH and Save. (No difference between HIGH and LOW for this release)
Configuration > Monitoring > Monitoring Service tab

4. Deploy and launch a web application.
Applications > Web Applications > Deploy
Click on Launch link to launch the application

5. View the monitoring statistics
Application Server > Monitor
Web Container tab: request, session, servlet, and JSP statistics
HTTP Service tab: error counts
JVM tab: stats on memory, OS, compilation, garbage collectors, runtime

pageicon Friday May 16, 2008

Fish Stick Anyone?

GlassFish™:  Fast, Easy & Reliable
1 GB GlassFish stick was a hot item
at JavaOne and CommunityOne

About a week or so before JavaOne, my boss asked me to put together the GlassFish memory sticks. I said ok. I didn't know what I was getting into exactly, but it sounded simple enough - load it with GlassFish related bits and create a landing page that talks about GlassFish.

What and how much to put onto the sticks? Some felt less is better, so people wouldn't just delete everythying. Some felt it better to have more bits, in the hopes that people flying back home from JavaOne would start playing with GlassFish. This sounded good too. And also because my boss told me to, I went with the second option. And since we had 1 GB to work with we did end up loading everything but the kitchen sink, about 840 MB in total. It's chock full of goodies - installers/zips for GlassFish, NetBeans IDE, & MySQL, demo from Project WebSynergy, screencasts, and hands-on labs.

How to create the landing page? A savvy web designer I am not. So I started out with the landing page we had from last year - a basic html page with plain text. I dressed it up with a dash of orange and lots of fish for fun. I thought it was kinda cute, and maybe could capture people's attention. It was definitely amateurish and casual. Some liked it. But my boss didn't. He was like 'Can you reformat it better like the Sun Java site?'. Hmm.. ok. I'll try my best. I used the 'Save As' of the Sun site as my template. I was more comfortable editing the html manually then trying to learn how to use one of the fancier html editors. I'm sure somebody who knows how to use one of those tools could have whipped something up in no time. I used StarOffice and edited the html in the HTML Source View. It took many hours wading through the hairy html code to make it look decent. I ended up with something that looks almost professional - an accomplishment for me considering my lack of web design skills. See my landing page below.

I had hoped to have content finalized by Wednesday evening, so we could copy the content onto the sticks on Thursday and Friday. But a critical piece - the GlassFish installer/zip, along with other demos and screencasts, were not ready yet until late Thursday evening. Needless to say I was a bit antsy about getting all the copying done. We were suppose to copy 1000 sticks!! And when we timed it, it took 15 minutes for a single stick. You do the math - my weekend was looking very busy. On Friday, we got a bit of a reprieve - we only had 500 sticks. And of course Nazrul and I were still making edits to the landing page up until the last minute on Friday. After we were done editing, we decided to do spell check. Spell check messed up the entire page! yikes!. For a second, we thought we had lost everything. But fortunately, I had a recent back-up. phew! We started copying around 2 on Friday. Nazrul went all around the office looking for people to help copy. It took about 18 people, 20-30 sticks each. Done by 6 pm Friday. yay! Thank you!

I enjoyed talking to people at the GlassFish booth. We had no problem, of course, handing out all the memory sticks. It was a popular item.

Here's the landing page I created for the memory sticks. I made all the links work here too.


 

GlassFish™:  Fast, Easy & Reliable

GlassFish is the fastest open-source application server, with clustering and centralized administration. Deploy using GlassFish v2 UR2, a production-ready Java EE 5 compatible application server. Join our community to learn more about the new features in Java EE 6 and GlassFish v3 TP2.

» GlassFish at a Glance    » GlassFish @ JavaOne    » Create a plugin for a chance to win a digital camera!


What's New

 
  • Supports OSGi
  • Provides an open, modular, and extensible platform
  • Supports dynamic languages such as Ruby and Groovy
  • Reference Implementation for Java EE 6
  • Currently available as a technology preview
 

Install

 
GlassFish v2 UR2 with NetBeans 6.1
  • Fastest open-source application server, with clustering and centralized administration
  • Includes EJB 3.0, JSF 1.2, JSP 2.1, Java Servlet 2.5, JAX-WS 2.1, and JAXB 2.1 specifications
  • Commercially supported
  • Provides next-generation Web features with Ajax, Scripting, and REST-based services
  • Includes a complete Web services stack with Microsoft .NET 3.0 interoperability
»  Windows installer
»  Linux installer
»  Mac installer

GlassFish v3 Technology Preview 2
Highly Modular and Lightweight!
»  Windows installer
»  Multi-platform zip

MySQL 5.0
The world's most popular open source database
»  Windows installer
»  Linux installer
»  Mac installer

Download sites:
»  GlassFish
»  NetBeans 6.1
»  MySQL 5.0
 

Licensing

 
Available under both the Common Development and Distribution License (CDDL) and GNU Public License (GPL V2 with the Classpath Exception) to maximize compatibility with other open source middleware projects and with GNU/Linux distributions.

 
    

Try it Out

 
Featured App
 
Project WebSynergy on GlassFish - Try this executable demo of our next generation application aggregation and presentation platform!
    »  More Info
    »  Project Links


Watch Screencasts

 

Support & Services

 
Get the most out of your GlassFish software with Sun's enterprise-class support and services!
 
»  Special Offer - Buy a subscription and get 1 year of Developer Expert Assistance at no extra charge!
 

Training

 
Develop your skills! See application server Course List.
 
Thrive with proper direction.
»  Java EE Training and Certification
GlassFish logo
 
GlassFish logo
 
 
 



pageicon Friday Feb 01, 2008

Glassfish V3 - Getting Started, Setting up the Environment

Sreeni gave me instructions on how to get started and setup with Glassfish V3. It worked like a charm so I thought I would post it here. Thanks Sreeni!

1. Download and install Java SE 6.latest:
http://java.sun.com/javase/downloads/index.jsp
• Set the system/user variable JAVA_HOME=C:\Program Files\Java\jdk1.6.0_04
• Add %JAVA_HOME%\bin to your system path.

2. Download and install SVN:
http://downloads.open.collab.net/collabnet-subversion.html
http://wiki.glassfish.java.net/attach/V3BrownBags/GFV3Intro2svn.pdf
• Add the svn directory to your system path.

3. Download and install Maven2:
http://maven.apache.org/download.html
• Add the system/user variable M2_HOME
• Add $M2_HOME/bin directory to your system path.
• Type the following:
mvn –version
You should see: Maven version: 2.0.8
http://wiki.glassfish.java.net/attach/V3BrownBags/GFv3Intro2Maven2.pdf

4. Checkout code:
svn checkout https://svn.dev.java.net/svn/glassfish-svn/trunk/v3

5. Build:
cd ${GFSRCDIR}/v3
mvn -U install

6. Install app server:
Expand glassfish.zip $GFv3\v3\distributions\glassfish\target\glassfish.zip

7. Start app server
cd /glassfish/bin
./asadmin start-domain

For additional info.
http://wiki.glassfish.java.net/Wiki.jsp?page=V3FullBuildInstructions


« October 2009
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
31
       
Today

Feeds

Search this blog

Links

Weblog menu

Today's referrers

Today's Page Hits: 12