Click to See Complete Forum and Search --> : What does "java.lang.NoClassDefFoundError:" mean ?


barsand
06-08-2006, 05:15 PM
What does this error mean? The JUnit compiles fine but when I'm running it it failes with this error message.

java.lang.NoClassDefFoundError: com/tel/customermgt/domain/CustomerConsent
at com.tel.customermgt.service.impl.CustomerMgtSvcImplTest.setUpMockObjects(CustomerMgtSvcImp lTest.java:124)
at com.tel.customermgt.service.impl.CustomerMgtSvcImplTest.setUp(CustomerMgtSvcImplTest.java: 112)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

arowberry
06-08-2006, 08:00 PM
When it compiles successfully and then gives a NoClassDefFoundError, my experience has been that the CLASSPATH environment variable is wrong or that I have left the correct package statement out of my program. Here are some other user experiences that may reveal the problem:
http://www.jguru.com/faq/view.jsp?EID=455768

gwoods
06-13-2006, 10:14 PM
Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

hagi
06-14-2006, 10:00 AM
What does NoClassDefFound mean?

NoClassDefFound means "No Class Definition Found".

NoClassDefFound is an error from the JVM when it cannot find a class required to run a Java program.

This error could be caused by an actual missing class, but it is usually caused by a faulty CLASSPATH.

This error also sometimes occurs when Java users add the unnecessary .class extension to the end of their command lines:

C:\>java HelloWorld.class
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class

C:\>java HelloWorld
Hello World!

kennethrene
07-12-2007, 11:03 AM
Hi, I have a similar error:

I am new en the JSF-Spring-Hibernate and the problem is that I created a proyect in Eclipse 3.2 and I have the page:

index.jsp:

<html>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

<f:view>
<body>
<table>
<tr>
<td>Documents : </td>
<td>
<h:selectOneMenu id="documento" value="#{accesoInscripcion.documentosItems}">
</h:selectOneMenu>
</td>
</tr>
<tr>
</tr>
</table>
</body>
</f:view>
</html>

but I try to execute the nex error appear:

11/07/2007 08:31:33 AM org.apache.myfaces.shared_impl.util.ClassUtils newInstance
GRAVE: Class : co.edu.uis.admisiones.vista.beans.AccesoInscripcionBean not found.
java.lang.NoClassDefFoundError
at co.edu.uis.admisiones.vista.beans.BaseBean.<init>(BaseBean.java:14)
at co.edu.uis.admisiones.vista.beans.AccesoInscripcionBean.<init>(AccesoInscripcionBean.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:3 9)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImp l.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:277)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:268)
...




But the class is in the package. Sombody could tell me what is the solution?

The configuration files are:


faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config>
<managed-bean>
<managed-bean-name>
documento</managed-bean-name>
<managed-bean-class>
co.edu.uis.admisiones.modelo.bo.Documento</managed-bean-class>
<managed-bean-scope>
request</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>accesoInscripcion</managed-bean-name>
<managed-bean-class>
co.edu.uis.admisiones.vista.beans.AccesoInscripcionBean
</managed-bean-class>
<managed-bean-scope>
request</managed-bean-scope>

<managed-property>
<property-name>initAware</property-name>
<value>true</value>
</managed-property>
</managed-bean>

</faces-config>


BaseBean.java:

package co.edu.uis.admisiones.vista.beans;

import co.edu.uis.admisiones.vista.ServiceLocatorAdmisiones;

public class BaseBean
{
private boolean initAware = false;
protected ServiceLocatorAdmisiones serviceLocator;

public BaseBean()
{
try
{
this.setServiceLocator(ServiceLocatorAdmisiones.getInstance());
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException("Error inicializando serviceLocator", e);
}
}

public boolean isInitAware()
{
return initAware;
}

public void setInitAware(boolean initAware)
{
this.initAware = initAware;
if (this.initAware)
{
this.init();
}
}

protected void init(){}

public ServiceLocatorAdmisiones getServiceLocator()
{
return serviceLocator;
}

public void setServiceLocator(ServiceLocatorAdmisiones serviceLocator)
{
this.serviceLocator = serviceLocator;
}
}


AccesoInscripcionBean.java:

package co.edu.uis.admisiones.vista.beans;

import java.util.*;
import co.edu.uis.admisiones.vista.*;

public class AccesoInscripcionBean extends BaseBean
{
private List documentosItems;

public AccesoInscripcionBean()
{
super();
documentosItems = new ArrayList();
}

public List getDocumentosItems()
{
return documentosItems;
}

public void setDocumentosItems(List listaDocumentos)
{
this.documentosItems = listaDocumentos;
}

private void initItemsDocumentos()
{
this.documentosItems = Listados.ListaDocumentos(
this.getServiceLocator().getServicioConsultasGen().getDocumentos());
}

protected void init()
{
try
{
super.init();
initItemsDocumentos();
}
catch(Exception e)
{
System.err.println("Error en el método init() de AccesoInscripcionBean.java: "+e.toString());
}
}
}


admisiones.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd" >

<beans>
<!-- DataSource Definition -->
<bean id="dataSourceAdmisiones"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.informix.jdbc.IfxDriver</value>
</property>
<property name="url">
<value>jdbc:informix-sqli://192.168.19.6:12010/academic:INFORMIXSERVER=UI;SelectMethod=cursor</value>
</property>
<property name="username">
<value>admis</value>
</property>
<property name="password">
<value>sdlfkseic</value>
</property>
</bean>

<!-- Spring Data Access Exception Translator Defintion -->
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource"><ref bean="dataSourceAdmisiones"/></property>
</bean>

<!-- Hibernate SessionFactory Definition -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>co/edu/uis/admisiones/modelo/bo/Documento.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.InformixDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</property>

<property name="dataSource">
<ref bean="dataSourceAdmisiones"/>
</property>
</bean>

<!-- INTERCEPTORS -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>


<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory"></ref>
</property>
</bean>

<!-- Hibernate Template Defintion -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
<property name="jdbcExceptionTranslator"><ref bean="jdbcExceptionTranslator"/></property>
</bean>

<!--DAO'S-->

<bean id="DocumentoDao" class="co.edu.uis.admisiones.modelo.dao.hibernate.DocumentoDaoHibernateImpl">
<property name="hibernateTemplate"><ref bean="hibernateTemplate"/></property>
</bean>

<!-- SERVICIOS-->

<!-- Servicio de consultas -->
<bean id="servicioConsultasGenTarget" class="co.edu.uis.admisiones.modelo.servicios.implementaciones.ServicioConsultasGenImpl">

<property name="DocumentoDao">
<ref bean="DocumentoDao"/>
</property>
</bean>

<!-- Servicio consultas Proxy Transaccional-->
<bean id="servicioConsultasGen" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref bean="servicioConsultasGenTarget"/>
</property>

<property name="proxyInterfaces">
<value>co.edu.uis.admisiones.modelo.servicios.ServicioConsultasGen</value>
</property>

<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
</beans>


web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp_ID">
<display-name>jsf</display-name>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/admisiones.xml</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>*.faces</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

ravisankar
07-19-2007, 06:31 AM
it is nothing but their is some problem in setting class path
set the class path and try
or else
execute it from bin