Tuesday Nov 18, 2008

Screencast #28: Simple Web Application using Eclipse and GlassFish v3 Prelude


GlassFish v3 Prelude is now available! Some of the cool features are:
  • Modularity using OSGi
  • Rapid deployment using retain session data across HTTP redeploys and deploy-on-save
  • Embeddability
  • Dynamic languages and frameworks
  • Faster start up time
  • Integrated NetBeans and Eclipse tooling
  • Comet and Cometd
This screencast shows how you can create a simple Web application using JSP and Servlets in Eclipse 3.4, deploy it directly on GlassFish v3, use rapid deployment, and debug the application.


The GlassFish plugin for Eclipse has many more features than demonstrated in this screencast and are explained here.

A complete list of GlassFish related screencasts is available here. Other screencasts published on this blog are available here.

Also see GlassFish v3 running using Equinox, Rails and Merb applications using GlassFish Gem, and Embeddable GlassFish.

Submit your bugs Eclipse/GlassFish bugs here, talk to us using GlassFish Plugins Forum, and get the latest information on glassfishplugins.dev.java.net.

Technorati: screencast glassfish v3 eclipse jsp servlets deployonsave deployment

Sunday Nov 09, 2008

Screencast #27: Simple Web Application using NetBeans 6.5 IDE and GlassFish v3 Prelude


GlassFish v3 Prelude is now available!

It contains a Java EE 5-based Web stack. A comprehensive tooling by NetBeans IDE allows to easily develop Web applications and deploy directly on GlassFish v Prelude. Rapid deployment feature of GlassFish allows to redeploy applications without losing session state. Using the deploy-on-save feature of NetBeans the complete development cycle is reduced to edit-save-refresh. There is no longer a need to wait for explicit deployment any more, cool isn't it ?

And you can even purchase enterprise support as well!

This screencast shows how you can create a simple Web application using JSP and Servlets in NetBeans IDE, deploy it directly on GlassFish v3 and then debug it.


Are you still doing the conventional edit-save-deploy-refresh conventional development cycle ? Use NetBeans and GlassFish together to liberate yourself :)

File GlassFish related bugs here using "web_container" sub-component. File NetBeans related bug here using "glassfish_v3" sub-component. Ask your GlassFish related questions on webtier@glassfish.dev.java.net or NetBeans related questions on nbusers@netbeans.org.

All other GlassFish related screencasts are available here.

Technorati: glassfish v3 netbeans jsp servlets deployonsave deployment screencast

Wednesday Jul 23, 2008

Job Opportunity in GlassFish Web Container Team

What's common between
You are right - GlassFish is the answer!

If you are a fresh graduate, then apply for GlassFish Scripting team. However if you have
  • Experience in Developing Web container and related web-tier technologies such as JSP, Servlets, Java Server Faces and Java Standard Tag Libraries
  • Like to define the direction of Web container in Java EE platform and GlassFish Application Server
  • Worked in the Open Source & distributed teams
  • Like to play "follow the leader" where you are the leader :)
Then GlassFish team needs you. Apply now!

Technorati: glassfish webtier jsp servlets jstl javaserverfaces job

Wednesday Jul 09, 2008

Getting Started with GlassFish in IntelliJ IDEA


IntelliJ IDEA 7.0.x include plugins that provide support for configuring GlassFish. This blog provides clear instructions on how to get started by developing and deploying a JSP, Servlet and Web services using GlassFish in IntelliJ. The instructions are using IntelliJ 7.0.3 Build #7757 (with no additional plugins).
  1. Create a new project
    1. Clicking on "Create New Project" or "File", "New Project". Take the default as shown below:



      and click on "Next >".
    2. Enter the project name as "GlassFishRocks" and take all defaults as shown:



      and click on "Next >".
    3. Take another default for the source directory as shown:



      and click on "Next >".
    4. For the first time use, JDK needs to be specified. Click on "+" in top-left corner as shown here:



      Take the default option of "JSDK" and specify the Home Directory as shown:



      Click on "OK" and then click on "Next >".
    5. Let's create a Web application. Select the list of technologies as shown:



      and finally (phew!) click on "Finish". The expanded project looks like:

  2. Create a GlassFish configuration
    1. Select "Run", "Edit Configurations" as shown:


    2. Click on "+" on top-left corner and select GlassFish as shown below:


    3. Specify the location of GlassFish Application server at:



      by clicking on "Configure" button and enter the values as shown:



      and click on "OK". You can download and install GlassFish v2 UR2 from here.
    4. Enter the "Name" and select the "Server Domain" as shown:



      and click on "OK".
  3. Deploy the Web application
    1. Click on the green button in the toolbar:


    2. Click on the "Fix" button on the bottom and then click "Run". The recently created Web module is selected to be deployed as shown:

    3. This starts the GlassFish v2 UR2 Application Server and deploys the Web application showing the console as:



      and also shows the default page at "http://localhost:8080/GlassFishRocksWeb/". You can edit "index.jsp", re-deploy the Web facet and refresh the page to see the updated message.

      Notice, even though project's name is "GlassFishRocks", the application context root is "GlassFishRocksWeb".
  4. Now lets create/deploy a new Servlet.
    1. Create a new project as described above and name it "KillerServlet".
    2. Right-click on the project and select "New", "Servlet" as shown:

    3. Enter the values as shown:



      and click on "OK".
    4. The "Java EE: Structure" shows the project as:


    5. Double-click on "HelloServlet" (nested one) and add the following fragment to "doGet" method:

              java.io.PrintWriter out = response.getWriter();
              try {
                  out.println("<html>");
                  out.println("<head>");
                  out.println("<title>Servlet NewServlet</title>");
                  out.println("</head>");
                  out.println("<body>");
                  out.println("<h1>Servlet NewServlet at " + request.getContextPath () + "</h1>");
                  out.println("</body>");
                  out.println("</html>");
              } finally {
                  out.close();
              }

      NetBeans IDE auto-generates this code for a Servlet ;-) And add the following to "doPost" method:

             doGet(request, response);
    6. Double-click on "web.xml" and then select "Assembly Descriptor" tab.
    7. Click on "+" in Servlet Mappings and specify the values as:


    8. Deploy the project (as described above) and output from Servlet is displayed at "http://localhost:8080/KillerServletWeb/hello". Read more details in Creating Java EE Apps and Servlets with IntelliJ IDEA.

      Remember the weird context root, it's "KillerServletWeb" instead of "KillerServlet". Now there may be a good reason to do so but nothing obvious.
  5. Now lets create a simple Web service using the Metro Web services stack (the stack baked into GlassFish)
    1. Create a new project with name "GlassFishWS" following the instructions given above.
    2. Select the list of technologies as shown:

    3. The default generated Web service looks like:

    4. The default generated Web service uses light-weight Endpoint API to host the endpoint. Run the Web service by right-clicking in the editor pane and selecting "Run" as shown or default shortcut of Ctrl+Shift+F10:

    5. The WSDL is now available at "http://localhost:9000/HelloWorld?wsdl".
    6. Right-click on the project and select "New", "Web Service Client" as shown:



      enter the value as "WSClient" and click on "OK".
    7. In the next dialog, enter the values as shown:

    8. The generated client code has some errors as shown:



      Change the code to:

            client.HelloWorld service = new client.HelloWorldService().getHelloWorldPort();
            //invoke business method
            System.out.println(service.sayHelloWorldFrom("Duke"));

      and run WSClient.main to see the result as:



      Now you deployed a Metro Web service using light-weight Endpoint API.  The bundled plugin version is 0.9 build 2 and the steps are so much cleaner from 0.7 version of the plugin.

      Read more about Web Services support in IntelliJ IDEA.
    9. Deploying this Web service on GlassFish is really simple.
      1. Create a new GlassFish configuration as explained above.
      2. Run the project using this configuration and the Web service is now hosted at "http://localhost:8080/GlassFishWSWeb/services/HelloWorld?wsdl".
      3. Generate a client using the steps described above.
Here are few issues filed:
  • JEEAS-180 does not allow an application to be re-deployed to GlassFish and that's why the examples above use different projects.
  • JEEAS-181  asks for better integration of GlassFish logs in the IDE.
  • JEEAS-182 require support for GlassFish v3 in the GlassFish plugin. Please help by voting for this issue.
  • WSVC-61 reports the errors generated in Web services client code
So whether you are using Eclipse, IntelliJ or NetBeans - you can easily configure GlassFish and deploy your applications directly from within the IDE. Here are some related links:
However of all the IDEs, NetBeans IDE still provides the most comprehensive coverage in terms of development and deployment of Java EE applications (JSP, Servles, Java Server Faces, SOAP-based .NET 3.0-interoperable Web service, RESTful Web services, JPA, EJBs) and server plug-ins (GlassFish, Tomcat, JBoss, WebLogic, WebSphere, OC4J, SAP BusinessOne and JOnAS).


Technorati: glassfish intellij idea jsp servlets metro webservices
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

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