Results 1 to 3 of 3
  1. #1
    Shikatsu is offline Member
    Join Date
    Nov 2011
    Posts
    49
    Rep Power
    0

    Default Problem building first JSF application sample on "Core JSF 3th"

    Greetings EveryOne ;D

    I'm making my first steps toward learning JSF. I found this interesting book called "Core JavaServer Faces Third Edition".

    At page 10, the book gives you instructions to build your first JSF application. Here quoting those instructions:

    Here are the build instructions for the sample JSF application.
    1. Launch a command shell.
    2. Change to the corejsf-examples directory—that is, the directory that contains
    the sample code for this book.
    3. If you use GlassFish or another Java EE 6 compliant application server,
    change to the javaee subdirectory. If you use Tomcat, change to the tomcat
    subdirectory.
    4. Change to the source directory and make the directory for holding the
    class files:
    cd ch01/login/src/java
    mkdir ../../web/WEB-INF/classes
    On Windows, use backslashes as file separators.
    5. If you use GlassFish, run
    javac -d ../../web/WEB-INF/classes -classpath .:glassfish/modules/\*
    com/corejsf/UserBean.java

    On Windows, use a semicolon in the classpath, and don’t escape the *
    wildcard:
    javac -d ..\..\web\WEB-INF\classes -classpath .;glassfish\modules\*
    com\corejsf\UserBean.java
    If you use Tomcat, use the following command to compile your code:
    javac -d ../../web/WEB-INF/classes -classpath .:jsf-ref-impl/lib/jsf-api.jar
    com/corejsf/UserBean.java
    6. If you use Tomcat, you need to include the JSF libraries:
    mkdir ../../web/WEB-INF/lib
    cp jsf-ref-impl/lib/*.jar ../../web/WEB-INF/lib
    Skip this step if you use a Java EE 6 compliant application server.
    7. Run the following commands (and note the period at the end of the jar
    command, indicating the current directory):
    cd ../..
    jar cvf login.war .
    At this moment i'm working on windows, when i implement the 5th instruction, this is a snap of my cmd:

    Problem building first JSF application sample on "Core JSF 3th"-jsf-prob.jpg

    Can you tell me why javac complaining about "no source file"?

    Thank You In Advance ;D

    P.S: - I had created a directory called "class" not "classes", just to tell you that my path is correct.
    - Please ignore the snap bellow, i can't remove it.
    Attached Thumbnails Attached Thumbnails Problem building first JSF application sample on "Core JSF 3th"-jsf-prob.jpg  
    Last edited by Shikatsu; 09-02-2012 at 07:57 PM.
    Knowledge Is Power! Don't give me a fish but teach me how to catch one
    I am not asking you to code it for me, what i need is guidance so i can learn

  2. #2
    Shikatsu is offline Member
    Join Date
    Nov 2011
    Posts
    49
    Rep Power
    0

    Default Re: Problem building first JSF application sample on "Core JSF 3th"

    Any Advice? Any Suggestion? Please I Need Help with this.
    Knowledge Is Power! Don't give me a fish but teach me how to catch one
    I am not asking you to code it for me, what i need is guidance so i can learn

  3. #3
    Shikatsu is offline Member
    Join Date
    Nov 2011
    Posts
    49
    Rep Power
    0

    Default Re: Problem building first JSF application sample on "Core JSF 3th"

    Greetings EveryOne ;D

    I found an answer to my problem and i want to share it with whom it may concern, you can find the answer here:

    java - package javax.inject does not exist - Stack Overflow

    After successfully compiling the source code, creating the WAR file (web archive), deploying it with glassfish i was getting this error, when submitting the user name and hitting the login button:

    Java Code:
    /index.xhtml @15,55 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null
    This is the UserBean.java:

    Java Code:
    package com.corejsf;
    
    import java.io.Serializable;
    import javax.inject.Named; 
       // or import javax.faces.bean.ManagedBean;
    import javax.enterprise.context.SessionScoped; 
       // or import javax.faces.bean.SessionScoped;
    
    @Named("user") // or @ManagedBean(name="user")
    @SessionScoped
    public class UserBean implements Serializable {
       private String name;
       private String password;
    
       public String getName() { return name; }   
       public void setName(String newValue) { name = newValue; }
    
       public String getPassword() { return password; }
       public void setPassword(String newValue) { password = newValue; }   
    }
    After a lot of thoughts, I found out my problem was in the directory structure of the WAR file:

    The wrong structure:

    Java Code:
    login.war
    |
    |--- index.xhtml
    |--- welcome.xhtml
    |
    |--- WEB-INF
              |
              |--- beans.xml
              |--- web.xml
              |--- classes
                        |
                        |--- UserBean.class
    In an enlightenment moment i said maybe the problem was in not respecting the package structure of the source code, and i was right it worked perfectly.

    This is the right directory structure of the WAR file:

    Java Code:
    login.war
    |
    |--- index.xhtml
    |--- welcome.xhtml
    |
    |--- WEB-INF
              |
              |--- beans.xml
              |--- web.xml
              |--- classes
                        |--- com
                               |--- corejsf
                                       |--- UserBean.class
    I hope this would make it easier for someone else.
    Last edited by Shikatsu; 09-10-2012 at 01:28 AM.
    Knowledge Is Power! Don't give me a fish but teach me how to catch one
    I am not asking you to code it for me, what i need is guidance so i can learn

Similar Threads

  1. Replies: 1
    Last Post: 02-01-2012, 09:37 PM
  2. problem with argument list and precedence "(" and ")"
    By helpisontheway in forum Advanced Java
    Replies: 6
    Last Post: 12-24-2009, 08:50 AM
  3. Replies: 2
    Last Post: 01-24-2009, 07:56 PM
  4. Replies: 1
    Last Post: 10-20-2008, 08:35 AM
  5. <core:forEach var="" begin="+<%=j%>+">???
    By freddieMaize in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2008, 02:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •