java.lang.NoClassDefFoundError

Hi All,

Can anyone help me with my issue. I am getting this error even if all of the classes are in the project.

[#|2007-03-06T10:38:26.765+0000|INFO|sun-appserver-pe8.2|javax.enterprise.system.stream.out|_ThreadID=13;|10:38:26,750 ERROR InvokeApplicationPhase:80 - #{userBean.checkPass}: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError

javax.faces.FacesException: #{userBean.checkPass}: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError

at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)

at javax.faces.component.UICommand.broadcast(UICommand.java:312)

at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)

at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)

at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)

at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:225)

at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:193)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)

at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)

at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)

at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)

at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)

at java.security.AccessController.doPrivileged(Native Method)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)

at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)

at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)

at java.security.AccessController.doPrivileged(Native Method)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at com.fetac.dao.AuthorizationServletFilter.doFilter(Unknown Source)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)

at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)

at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)

at java.security.AccessController.doPrivileged(Native Method)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)

at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)

at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)

at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)

at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)

Caused by: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError

at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)

at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)

... 50 more

Caused by: java.lang.NoClassDefFoundError

at com.fetac.dao.UserDAO.findUser(Unknown Source)

at com.fetac.dao.UserBean.checkPass(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)

... 51 more

|#]

I am not having this problem when I am running the web app under Apache Tomcat.

Thanks,

Karim

[5908 byte] By [karrumaa] at [2007-11-26 20:35:54]
# 1

You said it works under tomcat, but you never said what web server it didn't work under. You should also post your web.xml and faces-config.xml for us.

A few guesses at what the problem is:

1) userBean isn't resolved properly in the managed-bean section of your faces-config.xml.

2) You're missing a JAR file on your class path. Make sure you have: jsf-api.jar, and jsf-impl.jar. And if you're using an earlier version of JSF 1.1 or less: commons-beanutils, commons-collections, commons-digester, commons-logging. Additionally, you will need any other JARs containing classes you use. Some may even be specific to tomcat, or whatever web server you are using.

3) Make sure the above JARs are also in your WEB-INF/lib directory.

4) Are you doing something strange in your checkPass method? Could you please post it.

I think 2 is the most likely problem.

CowKing

IamCowKinga at 2007-7-10 1:28:32 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks CowKing for response,

It doesn't work on Sun AS 8.2 but it does under Sun AS 9.

Ad 1) I think this is OK

Ad 3) I think all jars are in the /lib folder

Ad 4) Checks if the password is correct for given username

Here is the web.xml

<?xml version="1.0"?>

<!--

* Copyright 2004 The Apache Software Foundation.

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

*http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*

* UPDATED: Marty Hall changed to use .faces suffix,

* faces-config.xml filename, and servlets 2.4.

* See tutorial at http://www.coreservlets.com/JSF-Tutorial/.

* Note: uncomment the filter entries at the bottom

*to use Tomahawk extended components.

-->

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<!-- Marty Hall:

Changed name from "examples-config.xml"

back to standard of "faces-config.xml" -->

<context-param>

<param-name>javax.faces.CONFIG_FILES</param-name>

<param-value>/WEB-INF/faces-config.xml</param-value>

<!-- description>

Comma separated list of URIs of (additional) faces config files.

(e.g. /WEB-INF/my-config.xml)

See JSF 1.0 PRD2, 10.3.2

</description> -->

</context-param>

<context-param>

<param-name>javax.faces.STATE_SAVING_METHOD</param-name>

<param-value>client</param-value>

<!--description>

State saving method: "client" or "server" (= default)

See JSF Specification 2.5.2

</description> -->

</context-param>

<context-param>

<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.PRETTY_HTML</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>

<param-value>false</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>

<param-value>true</param-value>

</context-param>

<!--

*** Uncomment the extensions filter and the two following extensions

*** mappings to enable Tomahawk (MyFaces extended components

*** and custom validators). See tutorial at

*** http://www.coreservlets.com/JSF-Tutorial/ and

*** http://myfaces.apache.org/tomahawk/extensionsFilter.html

*** Also note that if you use the old style (servlet 2.3)

*** declaration for web.xml, you have to put these filter entries

*** at the TOP of web.xml.

-->

<filter>

<filter-name>MyFacesExtensionsFilter</filter-name>

<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>

<init-param>

<param-name>maxFileSize</param-name>

<param-value>20m</param-value>

</init-param>

</filter>

<filter>

<filter-name>AuthorizationServletFilter</filter-name>

<filter-class>com.fetac.dao.AuthorizationServletFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

<servlet-name>Faces Servlet</servlet-name>

</filter-mapping>

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>

</filter-mapping>

<filter-mapping>

<filter-name>AuthorizationServletFilter</filter-name>

<url-pattern>/*</url-pattern>

<dispatcher>REQUEST</dispatcher>

<dispatcher>FORWARD</dispatcher>

</filter-mapping>

<!-- Faces Servlet

Marty Hall: changed .jsf back to standard of .faces -->

<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>*.faces</url-pattern>

</servlet-mapping>

<!-- Welcome files -->

<welcome-file-list>

<welcome-file>/index.jsp</welcome-file>

</welcome-file-list>

<login-config>

<auth-method>BASIC</auth-method>

</login-config>

</web-app>

Here is the faces-config.xml:

<managed-bean>

<managed-bean-name>awardBean</managed-bean-name>

<managed-bean-class>com.fetac.dao.AwardBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

<managed-bean>

<managed-bean-name>candidateAwardBean</managed-bean-name>

<managed-bean-class>com.fetac.dao.CandidateAwardBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

<managed-bean>

<managed-bean-name>candidateBean</managed-bean-name>

<managed-bean-class>com.fetac.dao.CandidateBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

<managed-bean>

<managed-bean-name>navigationMenu</managed-bean-name>

<managed-bean-class>com.fetac.dao.NavigationMenu</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

<managed-bean>

<managed-bean-name>resultBean</managed-bean-name>

<managed-bean-class>com.fetac.dao.ResultBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

<managed-bean>

<managed-bean-name>userBean</managed-bean-name>

<managed-bean-class>com.fetac.dao.UserBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

I am thinking if I should jar all my classes and add that to /lib folder ?

I would be happy if you could tell me what is wrong in my implementation/configuration.

Thanks,

Karim

karrumaa at 2007-7-10 1:28:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Nothing pops out at me when reviewing your configuration. You probably don't need these lines (try it without):

<context-param>

<param-name>javax.faces.CONFIG_FILES</param-name>

<param-value>/WEB-INF/faces-config.xml</param-value>

<!-- description>

Comma separated list of URIs of (additional) faces config files. (e.g. /WEB-INF/my-config.xml)

See JSF 1.0 PRD2, 10.3.2

</description> -->

</context-param>

This may cause your faces-config.xml to be loaded twice and for you to instantiate duplicate components, renderers, beans, etc... It doesn't seem likely that it would cause the NoClassDefFoundError though. But you never know.

You shouldn't need to JAR your own classes and add them to the WEB-INF/lib directory. When they get compiled, they probably go to the WEB-INF/classes directory.

The only thing left is to go through your project and figure out what's missing. Start at the UserBean.

Also, I don't know MyFaces very well, but does it require its own faces servlet to be configured in the web.xml? And of course, add all the appropriate myfaces jars!

CowKing

IamCowKinga at 2007-7-10 1:28:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...