1 Reply Latest reply on Oct 20, 2014 11:50 AM by puradawid

    How to handle Not Found in ExternalContext as a Resource?

    puradawid

      Hello everyone!

      I have a problem with my existing maven EAR project. I decided to add some JSF (anyway, any html compontent, cause recenlty i'm using webservice only with this project). I configure web descriptor:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
      <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
      </context-param>
      <context-param>
          <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
          <param-value>true</param-value>
        </context-param>
        <context-param>
          <param-name>com.sun.faces.allowTextChildren</param-name>
          <param-value>true</param-value>
        </context-param>
        <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>*.xhtml</url-pattern>
          <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
      </web-app>
      
      

       

      Create faces-config.xml as well:

       

      <?xml version="1.0"?>
      <faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
          <application />
      </faces-config>
      
      

       

      I want to mention that webservice isn't configured at all at web.xml descriptor, but it's working well.

       

      Also i had a problem with loading JSF page at all related to problem Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0 but i removed beans.xml from ejb module file and everything looks okay, i think .

       

      Anyway, i don't know what is cause of problem.

       

      Tree of my project:

       

      ./BlinkLink-web/src
      ├── main
      │   ├── java
      │   │   └── pl
      │   │       └── edu
      │   │           └── pb
      │   │               └── blinklink
      │   │                   └── webservice
      │   │                       ├── BlinkLinkService.java
      │   │                       ├── handlers
      │   │                       │   └── LoginHandler.java
      │   │                       ├── login-handler.xml
      │   │                       └── model
      │   │                           ├── BlinkGroupWebservice.java
      │   │                           ├── BlinkUserWebservice.java
      │   │                           ├── LinkWebservice.java
      │   │                           ├── package-info.java
      │   │                           ├── RateWebservice.java
      │   │                           └── UserLinkWebservice.java
      │   └── webapp
      │       ├── problem.html
      │       ├── Test.xhtml
      │       └── WEB-INF
      │           ├── faces-config.xml
      │           ├── jboss-web.xml
      │           └── web.xml
      └── test
          ├── java
          │   └── pl
          │       └── edu
          │           └── pb
          │               └── blinklink
          │                   └── webservice
          │                       └── BlinkLinkServiceTest.java
          └── resources
              └── arquillian.xml
      
      

       

      jboss-web.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
        <context-root/>
      </jboss-web>
      

       

       

      Added any static element to webapp folder causing only 404 error, i can't get to this resources by browser.

       

      Please, help me, i would be grateful.

       

      Thanks,

      Dawid.

        • 1. Re: How to handle Not Found in ExternalContext as a Resource?
          puradawid

          I solve this problem:

           

          Actually it's not related to any files i posted above. It was a war plugin:

           

                      <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-war-plugin</artifactId>
                          <version>2.1.1</version>
                          <configuration>
                              <failOnMissingWebXml>false</failOnMissingWebXml>
                              <packagingIncludes>**/*.xml,**/*.properties,**/*.class,**/*.html,**/*.xhtml,**/*.png,**/*.css,**/*.js,**/*.jsp</packagingIncludes>
                          </configuration>
                      </plugin>
                      
          
          

           

          What was wrong? packaingIncludes attribute was without **/*.xhtml and **/*.html.

           

          Anyway, other problem still exists: can i use JSF 2.2 with AS7 and maven? I just add a dependency:

           

                  <dependency>
                      <groupId>com.sun.faces</groupId>
                      <artifactId>jsf-api</artifactId>
                      <version>2.2.2</version>
                  </dependency>
                  <dependency>
                      <groupId>com.sun.faces</groupId>
                      <artifactId>jsf-impl</artifactId>
                      <version>2.2.2</version>
                  </dependency>
                  <dependency>
                      <groupId>javax.servlet</groupId>
                      <artifactId>javax.servlet-api</artifactId>
                      <version>3.0.1</version>
                  </dependency>
                  <dependency>
                      <groupId>org.gatein</groupId>
                      <artifactId>cdi-portlet-integration</artifactId>
                      <version>1.0.0.Final</version>
                  </dependency>
                  <dependency>
                      <groupId>org.gatein</groupId>
                      <artifactId>cdi-portlet-integration</artifactId>
                      <version>1.0.0.Final</version>
                      <scope>provided</scope>
          
          

           

          But still it isn't working. Output is raw xhtml file. Can someone help me?

           

          Thanks,

          Dawid.

          1 of 1 people found this helpful