glassfish
  1. glassfish
  2. GLASSFISH-20492

[fishcat] Glassfish latest (1 may) : JSF and @Inject doesn't print output

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 4.0_b87_RC3
    • Fix Version/s: None
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      Description

      I use Netbeans to generate a simple sample.

      I use a servlet to test @Inject, a CDIManagedBean and a @Stateless EJB.

      if I enter the URL :

      http://localhost:8080/TestCDI/PerformanceGate

      I got this output :

      Output from class com.demo.CDIManagedBean at : 519201693741621
      Output from class com.demo.EJBManagedBean at : 519201693763646

      and I test the JSF page with :

      http://localhost:8080/TestCDI/

      and got :

      from JSF :

      I should get something like this

      from JSF : Message from Output from class com.demo.CDIManagedBean at : 519347151889153 and Output from class com.demo.EJBManagedBean at : 519347151924821

      My JSF is

      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
      <h:head>
      <title>Facelet Title</title>
      </h:head>
      <h:body>
      from JSF : #

      {index.message}

      </h:body>
      </html>

      package com.demo;

      import javax.enterprise.inject.Model;
      import javax.inject.Inject;

      /**
      *

      • @author sdionne1
        */
        @Model
        public class Index {

      @Inject
      CDIManagedBean bean;

      @Inject
      EJBManagedBean ejb;

      public String getMessage()

      { return "Message from " + bean.getOutput() + " and " + ejb.getOutput(); //return "test"; }
      }


      I can provide a 7z file if requested.

      here the others files

      package com.demo;

      /**
      *
      * @author sdionne1
      */
      public class CDIManagedBean {

      public String getOutput(){ return "Output from " + CDIManagedBean.class + " at : " + System.nanoTime(); }
      }




      package com.demo;

      import javax.ejb.Stateless;

      /**
      *
      * @author sdionne1
      */
      @Stateless
      public class EJBManagedBean {

      public String getOutput(){ return "Output from " + EJBManagedBean.class + " at : " + System.nanoTime(); }
      }


      package com.demo;

      import javax.enterprise.inject.Model;
      import javax.inject.Inject;

      /**
      *
      * @author sdionne1
      */
      @Model
      public class Index {

      @Inject
      CDIManagedBean bean;

      @Inject
      EJBManagedBean ejb;

      public String getMessage(){ return "Message from " + bean.getOutput() + " and " + ejb.getOutput(); //return "test"; }

      }

      package com.demo;

      import java.io.IOException;
      import java.io.PrintWriter;
      import javax.inject.Inject;
      import javax.servlet.ServletException;
      import javax.servlet.annotation.WebServlet;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;

      /**
      *

      • @author sdionne1
        */
        @WebServlet(name = "PerformanceGate", urlPatterns = {"/PerformanceGate"}

        )
        public class PerformanceGate extends HttpServlet {

      @Inject
      CDIManagedBean bean;

      @Inject
      EJBManagedBean ejb;

      /**

      • 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
        Unknown macro: { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE html>"); out.println(bean.getOutput()); out.println("<br />"); out.println(ejb.getOutput()); } 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>

      }

        Activity

        Hide
        jjsnyder83 added a comment -

        I need an application with source code that I can deploy in order to help you. Please send it to me: j.j.snyder@oracle.com

        Show
        jjsnyder83 added a comment - I need an application with source code that I can deploy in order to help you. Please send it to me: j.j.snyder@oracle.com
        Hide
        jjsnyder83 added a comment -

        It seems that it was a NetBeans issue in that the application that was deployed did not contain the correct artifacts.

        Show
        jjsnyder83 added a comment - It seems that it was a NetBeans issue in that the application that was deployed did not contain the correct artifacts.

          People

          • Assignee:
            jjsnyder83
            Reporter:
            survivant
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: