0

I am working on panelgroup select menu that would only be visible if the first select Menu wasn't set as a "P" or as a "N". I found an example but before i can try it, I got an error stating

java.lang.NoClassDefFoundError: javax/servlet/jsp
/jstl/core/Config

Which is strange because I am sure i am using jsf 2.2 . the only jar file i have my project library is:

javax.faces-2.2.5.jar

Below is the section of new code i wrote based on a example I found.

<!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://xmlns.jcp.org/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core" >


<h:body>
<h:form>    
<b>Blue tooth test: </b>  
     <h:selectOneMenu value="#{qcFormBean.dliStickerValue}">
     <f:selectItem itemValue="P" itemLabel="Pass" />
     <f:selectItem itemValue="N" itemLabel="N:A" />
     <f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
     <f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
     <f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
     <f:selectItem itemValue="S" itemLabel="FAIL-Software" />
     <f:ajax event="change" execute="@this" render="perfbyDliSticker" />
</h:selectOneMenu>

<h:panelGroup id="perfbyDliSticker">
    <h:selectOneMenu value="#{qcFormBean.stickerFreq}"
                 rendered="#{!qcFormBean.dliStickerValue eq 'P' or !qcFormBean.dliStickerValue eq 'N'}">
<f:selectItem itemValue="O" itemLabel="Often" />
<f:selectItem itemValue="S" itemLabel="Seldom" />                
</h:selectOneMenu>


Is there something i am doing wrong or is the way i am trying to render this not JSF-ish or am i missing more files because I added these files before

jsf-api.jar jstl-1.2.jar jsf-impl.jar

but then i got a tomcat error in eclipse saying that the file is now a jsp file instead of a jsf file and needs to be added to the web.xml. So there must be some other way about this.

------Update------

Made changes to my code here is the update:

<h:selectOneMenu value="#{qcFormBean.dliStickerValue}">
<f:selectItem itemValue="P" itemLabel="Pass or Not applicable" />
<f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
<f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
<f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
<f:selectItem itemValue="S" itemLabel="FAIL-Software" />
<f:ajax event="change" execute="@this" render="perfbyDliSticker" />
</h:selectOneMenu>

<h:panelGroup id="perfbyDliSticker">
<h:selectOneMenu value="#{qcFormBean.performedByRoleID}"
                 rendered="#{!qcFormBean.dliStickerValue eq  'P'}">
<f:selectItem itemValue="A" itemLabel="Always" />                
<f:selectItem itemValue="O" itemLabel="Often" />
<f:selectItem itemValue="S" itemLabel="Seldom" />                
</h:selectOneMenu>

--update 2_----- adding my web.xml to see if it helps.

 <?xml version="1.0" encoding="UTF-8"?>
 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://java.sun.com/xml/ns/javaee"  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                                               http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
     version="3.0">
  <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <context-param>
  <param-name>javax.faces.PROJECT_STAGE</param-name>
  <param-value>Development</param-value>
  </context-param>
  <context-param>
  <description>State saving method: 'client' or 'server' (default). See JSF Specification section 2.5.2</description>
  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  <param-value>client</param-value>
  </context-param>
 <welcome-file-list>
<welcome-file>index.jsf</welcome-file>
<welcome-file>welcome.jsf</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Gilbert V
  • 1,050
  • 5
  • 16
  • 43
  • it seems the name of jar file wrong `javax.faces-2.2.5.jar` rename it to `javax.faces.jar` – Husam Feb 05 '14 at 16:16
  • I renamed the Jar but the error is still there. – Gilbert V Feb 05 '14 at 16:22
  • ok try to import and add the jar file to project classpath `/WEB-INF/lib` ? – Husam Feb 05 '14 at 16:27
  • its been added on my there already, All i did was change the name of it on the /WEB-INF/lib path. I think i could have the render syntax for the panelgroup incorrect or something. – Gilbert V Feb 05 '14 at 16:32
  • The value in the second `selectOneMenu` has a compilation syntax error `#{qcFormBean.}` you need to determine which value in `qcFormBean` managed bean take it after the render success? – Husam Feb 05 '14 at 16:43
  • Sorry about that I forgot to add that here. I edited it back in on the question but yes the value is there. Should i use rich Faces or something for this ajax or no? – Gilbert V Feb 05 '14 at 16:48
  • you get this error only with ajax or with all your jsf xhtml? – Rami.Q Feb 05 '14 at 18:38
  • This error is sadly with it all the ajax and the panelgroup remove that option and it becomes normal. Not sure why. – Gilbert V Feb 05 '14 at 19:30
  • possible duplicate of [java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config](http://stackoverflow.com/questions/20268095/java-lang-noclassdeffounderror-javax-servlet-jsp-jstl-core-config) – BalusC Feb 05 '14 at 20:46

2 Answers2

2

The error tells that the class javax.servlet.jsp.jstl.core.Config is missing. This class is part of JSTL and is not provided by default on Tomcat.

You have to make sure the jstl-1.2.jar is present in your /WEB-INF/lib (together with the JSF api and impl jars).

See also:

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • I added that and now i get the same errors as before and it doesn't even show it as a jsf file: WARNING: JSF1091: No mime type could be found for file /QcFormDean.jsp. To resolve this, add a mime-type mapping to the applications web.xml. – Gilbert V Feb 05 '14 at 19:40
  • Maybe you can add your `web.xml` to the question. – unwichtich Feb 05 '14 at 19:47
  • The new problem is unrelated. Open a new question. The current problem is solved. – BalusC Feb 05 '14 at 20:42
0

a good structured xhtml could be something like this(<h:head>...</head> is important for jsf ajax):

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      >
<h:head>
    <meta charset="UTF-8" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <h:outputStylesheet name="stylesheet.css"/>
    <title>Test</title>    
</h:head>
<body>
<f:view> 
<h:outputText value="hello"></h:outputText>
.....
</f:view>
</body>
</html>

if you still have that error, try the following:

create a new Dynamic web Project in eclipse (Kepler EE):

1) menu item file -> new -> Dynamic web Project

2) then enter name for your Project

3) Target runtime (your tomcat server)

4) Modul Version 3.0

5) Configuration: Java Server Faces 2.2 Project

6) next-> next->, then select the checkbox "generate web.xml ..."

7) next -> JSF Implementation Library (Type: user Library): at the right side you see an icon for download(click it, and wait, you will get Mojarra 2.2 ...), select and install it, finish!

after that copy my above xhtml and test it in your Pages (don't forget to add your Faces Servlet pattern in the URL as in your web.xml)

Rami.Q
  • 2,486
  • 2
  • 19
  • 30
  • Sadly it does have a head, i just didn't think it was important to show it here as it was simple like what you showed. – Gilbert V Feb 05 '14 at 19:14
  • @GilbertV: create a new Projct as i showed above, eclipse will add the libraries correctly! – Rami.Q Feb 05 '14 at 19:15
  • But if i deleted the panel group information and the rendereing information the page shows up fine which leads me to think that the part of the code i am using is wrong or incorrect. – Gilbert V Feb 05 '14 at 19:41
  • I don't know wasn't me, I ended up doing what you said and just made a new dynamic web project in eclipse to get rid of that error. – Gilbert V Feb 06 '14 at 15:17