dev@glassfish.java.net

Re: GlassFish V3 / Web Beans

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 30 Apr 2009 15:23:08 +0200

On Apr 30, 2009, at 3:07 PM, Roger Kitain wrote:

> Hi Paul -
>
> I believe the Web Beans jars have been propagated to the maven
> repository. Jane may be able to help you with that.
>

OK. I will wait for Jane's reply on that.

Another question/issue :-)

I just downloaded promoted build 47. Created a simple Web application
in NetBeans, added the webbeans jar to the library (for compilation
purposes not to be included in the war) and modified the servler to
inject a Manage instance, but it is not getting injected, thus i get
an NPE:

[#|2009-04-30T15:12:52.901+0200|SEVERE|glassfish|
javax.enterprise.system.container.web.com.sun.enterprise.web|
_ThreadID=17;_ThreadName=Thread-1;|StandardWrapperValve[NewServlet]:
PWC1406: Servlet.service() for servlet NewServlet threw exception
java.lang.NullPointerException
        at foo.NewServlet.processRequest(NewServlet.java:38)
        at foo.NewServlet.doGet(NewServlet.java:64)

Code is below.

Is there anything i have to do to explicitly enable WebBeans support?


I know samples are work in progress, but something very simple and
small to iterate on would be extremely useful. I want to investigate
JAX-RS/Jersey/299 integration so the early i start the earlier i can
find out issues and fix 'em or inform others.

Thanks,
Paul.

package foo;

/*
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */


import java.io.IOException;
import java.io.PrintWriter;
import javax.inject.Current;
import javax.inject.manager.Manager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
  *
  * @author paulsandoz
  */
public class NewServlet extends HttpServlet {

     @Current Manager m;

     /**
      * Processes requests for both HTTP <code>GET</code> and
<code>POST</code> methods.
      * @param request servlet request
      * @param response servlet response
      * @throws ServletException if a servlet-specific error occurs
      * @throws IOException if an I/O error occurs
      */
     protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
     throws ServletException, IOException {
         response.setContentType("text/html;charset=UTF-8");
         PrintWriter out = response.getWriter();
         try {
             WebBean b = m.getInstanceByType(WebBean.class);
             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("<h1>WEB BEAN " + b.get() + "</h1>");
             out.println("</body>");
             out.println("</html>");
         } finally {
             out.close();
         }
     }

     // <editor-fold defaultstate="collapsed" desc="HttpServlet
methods. Click on the + sign on the left to edit the code.">
     /**
      * Handles the HTTP <code>GET</code> method.
      * @param request servlet request
      * @param response servlet response
      * @throws ServletException if a servlet-specific error occurs
      * @throws IOException if an I/O error occurs
      */
     @Override
     protected void doGet(HttpServletRequest request,
HttpServletResponse response)
     throws ServletException, IOException {
         processRequest(request, response);
     }

     /**
      * Handles the HTTP <code>POST</code> method.
      * @param request servlet request
      * @param response servlet response
      * @throws ServletException if a servlet-specific error occurs
      * @throws IOException if an I/O error occurs
      */
     @Override
     protected void doPost(HttpServletRequest request,
HttpServletResponse response)
     throws ServletException, IOException {
         processRequest(request, response);
     }

     /**
      * Returns a short description of the servlet.
      * @return a String containing servlet description
      */
     @Override
     public String getServletInfo() {
         return "Short description";
     }// </editor-fold>

}



> Thanks, Roger.
>
> Paul Sandoz wrote:
>> Are there any artifacts on the java.net maven repo we can use to
>> compile against when referring to classes of JSR 299?
>>
>> Or do we have to explicitly utilize:
>>
>> glassfish/modules/webbeans-osgi-bundle.jar
>>
>> Paul.
>>
>> On Apr 29, 2009, at 9:08 PM, Roger Kitain wrote:
>>
>>> Folks -
>>>
>>> Meant to send this out earlier..
>>> Web Beans has been integrated into GlassFish v3 Milestone 2. You
>>> should be able to pick it up:
>>> - in GlassFish v3 promoted builds (b46 or later)
>>> - in GlassFish v3 nightly builds (b46 - April 23 / or later builds)
>>> or building GlassFish v3 from source.
>>>
>>> What is in this release:
>>> - Basic Web Beans support - Simple Web Bean discovery (WAR
>>> deployment).
>>>
>>> What is not in this release:
>>> - EAR deployment / EJB support.
>>>
>>> Web Beans with EJB support will be integrated at a later time.
>>> Samples are a work in progress.
>>>
>>> -roger
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>