1 2 Previous Next 23 Replies Latest reply: Jun 28, 2011 5:06 PM by 872014 Go to original post RSS
      • 15. Re: First Cup Problem
        843833
        found some evidence: at least one big difference is in web.xml. the one delivered with glassfish seems to be the original/generated one (in pages only "index.html" appears). if i overwrite my web.xml (modifiedexactly as tutorial states) the application seem to work (no blank screen). instead of "index.html"(this file doesn't exist) under "pages" and there "welcome files" an empty entry also works.

        so if you select the correct file "greetings.xhtml" this file is not displayed (empty page) but if you select a that doesn't exists greetings.xhtml is displayed!

        the next problem is: the greetings.xhml is dispülayed but the app doesn't work (in my case: dukes age is -1 and any input yields to an resource not found error).
        could you please try the same and say if your app works after the modifications to web.xml?


        edit1: one problem solved - i forgot to deploy the webservice. now the first page works fine but i get an error(java.lang.nullpointerexception) if i put in a date and submit it.

        Edited by: dermoritz1 on Jan 27, 2010 1:08 AM
        • 16. Re: First Cup Problem
          782681
          i get an error(java.lang.nullpointerexception) if i put in a date and submit it.
          did you check the server log? If yes, were there any details on NPE (error message, stack trace)?
          • 17. Re: First Cup Problem
            843833
            "you are not allowed to edit", so it is a reply:i got it! the null pointer exception was because the entity manager was null:
            private EntityManager em;
            - obvious
            i forgot to add:
            @PersistenceContext-->
            @PersistenceContext
                private EntityManager em;
            (and the include: import javax.persistence.PersistenceContext;)

            now it is working nearly perfect - the only bug remaining is - the date put in differs to date written in database (Day-1)-

            two questions for the java ee experts: why web.xml doesn't work with the correct welcom page and works with a welcom page that doesn't exists?

            2nd: why the entity manager isn't null anymore after i add @PersistenceContext ?

            edit: the problem with the wrong displayed date is a very strange one: the subtraction of 1 day from each date occurs at the very end:
            <h:outputText value="#{DukesBDay.youngestUserBirthday.getTime()}">
                    <f:convertDateTime pattern="MM/dd/yyyy" />
                </h:outputText>
            with this code the day isn't displayed properly. but if i use
            <h:outputText value="#{DukesBDay.youngestUserBirthday.getTime().toString()}"/>
                    
            all is fine! so why "convertDateTime" subtracts 1 day from each date? probably some timezone issue?

            Edited by: dermoritz1 on Jan 27, 2010 2:09 AM

            Edited by: dermoritz1 on Jan 27, 2010 2:15 AM

            Edited by: dermoritz1 on Jan 27, 2010 2:33 AM
            • 18. Re: First Cup Problem
              843833
              Hi all,

              I've started to play with this example as well and I had the same result - blank screen. The problem is not related to browser but probably to server part (FacesServlet). So after some study about JSF and its configuration on application server I've changed web.xml following way (added some configuration):
              ....
              <context-param>
              <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
              <param-value>*.xhtml</param-value>
              </context-param>
              ....
              ....
              <servlet-mapping>
                  <servlet-name>Faces Servlet</servlet-name>
                  <url-pattern>/first/*</url-pattern>
                   <url-pattern>*.xhtml</url-pattern>
              </servlet-mapping>
              ......
              .....

              Now when I redeployed the firstcup on GlassFish this started to work - use following URL:

              http://localhost:8082/firstcup/first/greeting.xhtml

              Please change port number (and URL pattern part "first" in web.xml) according your configuration. "firstcup" is Web application context.

              Regards

              Edited by: Behemoth0 on Feb 11, 2010 3:58 AM
              • 19. Re: First Cup Problem
                843833
                thx behemoth, now my workaround is obsolet.

                do you also have the second problem i described?: the wrong displayed time?
                • 20. Re: First Cup Problem
                  843833
                  dermoritz1

                  Thank you for helping me sort my issues.

                  Gnat,

                  Thanks for all your replies, I've started working commercially on this now and there is no IDE in sight to build and deploy so your point about using ANT was spot on.

                  I'm finding it alot easier to have actual work on an App rather than creating the app this tutorial but I'm sure i'll be back for help at some point

                  Thanks,
                  Mitch
                  • 21. Re: First Cup Problem
                    782681
                    ...I'm finding it alot easier to have actual work on an App rather than creating the app this tutorial...
                    Consider yourself lucky then. My professional experience started with things even more buggy than firstcup. And more complicated of course. Looking back, I doubt now that I could make it without help from teammates.

                    By the way given your note I wonder if you are working with JBoss now? I ask because my encounter with it was (unfortunately) brief but quite pleasant. And their tutorial is really better than firstcup. Oh it's more (much more) complicated, and if memory serves it is all command line but (but!) it's reliable.

                    With JBoss tutorial, I slowly crawled through lengthy complicated instructions but after making it precisely as required, things were guaranteed to work exactly as expected.
                    • 22. Re: First Cup Problem
                      843833
                      Also had the problem. The problem seems to be that the URL pointed out at the end of the tutorial
                      http://localhost:8080/firstcup
                      is wrong. It should logically be:
                      http://localhost:8080/firstcup/firstcupWeb/greeting.xhtml
                      Another way to get this URL is to not simple select greeting.xhtml as welcome file, but instead you enter:
                          <welcome-file-list>
                              <welcome-file>firstcupWeb/greeting.xhtml</welcome-file>
                          </welcome-file-list>
                      In that case I could use again the simple URL (http://localhost:8080/firstcup). I don't know if this is an acceptable way of working regarding specifications but it works for me. By the way something really odd is that when the greeting.xhtml page is shown the response URL is in the browser's address field, and when the reponse.xhtml page is shown the greeting URL is in the address field. This page navigation in JSF has always been a bit brittle to me.

                      Can anyone of Oracle update this? It is so wrong thinking that people should struggle their way through their first cup that is not very tasty after all.

                      PS: also the wizard for creating the composite component gives a nullpointer exception in Netbeans 6.8...
                      PS: the explanation of composite components is very confusing. Try to explain it as reusable JSF code (callable from other JSF pages). The sentence "A composite component is a set of user-defined JSF and Facelets components located in a resource." really didn't help me at all.
                      • 23. Re: First Cup Problem
                        872014
                        840830 wrote:
                        thx behemoth, now my workaround is obsolet.

                        do you also have the second problem i described?: the wrong displayed time?
                        I too noticed the "date stored in database less by 1 compared to the input date" issue. The following 2 sources provided info pointing to the fix that worked for me.

                        1. A discussion on stackoverflow.com, titled "f:convertDateTime displays wrong Date".
                        http://stackoverflow.com/questions/2689245/fconvertdatetime-displays-wrong-date


                        2. In the book Core JavaServer Faces 3rd Edition, on Page 252 (Table 7-2) it says the following regarding the timeZone attribute of the f:convertDateTime tag.
                        As of JSF 2.0, you can change the default to TimeZone.getDefault() by setting javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE to true in web.xml.

                        The fix that worked for me:
                        Changed the default timeZone to TimeZone.getDefault() by setting javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE to true in web.xml.
                        The following post (BalusC, May 24) gives more clarity on what exactly to add to web.xml:
                        http://stackoverflow.com/questions/2689245/fconvertdatetime-displays-wrong-date/6110127#6110127

                        The rest of the [Java EE 6 Firstcup (March 2011)|http://download.oracle.com/javaee/6/firstcup/doc/] tutorial was easy to follow. There was no need to deviate from their instructions.

                        Edited by: user1138435 on Jun 28, 2011 3:06 PM
                        1 2 Previous Next