Announcement Announcement Module
Collapse
No announcement yet.
java.lang.NoClassDefFoundError: and Abstract class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.NoClassDefFoundError: and Abstract class

    I'm getting this error and it has me confused as to why it is complaining about my applicationContext-hibernate.xml file:

    Code:
           [junit] Testcase: warning(junit.framework.TestSuite$1):     FAILED
       [junit] Exception in constructor: testNewAlert (org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [../conf/appl
    cationContext-hibernate.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/coastal/urbancanyons/hq/mapping/alert (wrong name: org/coastal/urbancanyons/hq/map
    ing/Alert)
       [junit] java.lang.NoClassDefFoundError: org/coastal/urbancanyons/hq/mapping/alert (wrong name: org/coastal/urbancanyons/hq/mapping/Alert)
    Here is my applicationContext-hibernate.xml file:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>	
    	<!-- ========================= Start of PERSISTENCE DEFINITIONS ========================= --> 
    	
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName"><value>org.gjt.mm.mysql.Driver</value>            </property>
    		<property name="url">            <value>jdbc:mysql://localhost/urbancanyons</value></property>
    		<property name="username">       <value>uc</value>                                 </property>
    		<property name="password">       <value>uc</value>                                 </property>
    	</bean> 
    	
    	<!-- Choose the dialect that matches your "dataSource" definition -->
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name ="dataSource"><ref bean="dataSource"/></property>
    		<property name ="mappingResources">
    			<list>
    				<value>org/coastal/urbancanyons/hq/mapping/Address.hbm.xml     </value>
    				<value>org/coastal/urbancanyons/hq/mapping/Alert.hbm.xml       </value>
    				<value>org/coastal/urbancanyons/hq/mapping/Building.hbm.xml    </value>
    				<value>org/coastal/urbancanyons/hq/mapping/ChatMessage.hbm.xml </value>
    				<value>org/coastal/urbancanyons/hq/mapping/EmailAddress.hbm.xml</value>
    				<value>org/coastal/urbancanyons/hq/mapping/PhoneNumber.hbm.xml </value>
    				<value>org/coastal/urbancanyons/hq/mapping/Role.hbm.xml        </value>
    				<value>org/coastal/urbancanyons/hq/mapping/State.hbm.xml       </value>
    				<value>org/coastal/urbancanyons/hq/mapping/User.hbm.xml        </value>
    			</list>
    		</property>	
    		<property name = "hibernateProperties" >
    			<props>
    				<prop key="hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>
    			</props>
    		</property>	
    		
    	</bean>
    
    	<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	
    	<!-- THE HIBERNATE INTERCEPTOR -->
    	<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	
    	<!-- Add more services here -->
    	<!-- This sets a Hibernate SessionFactory on AlertHibernateDAO (which inherits setSessionFactory()
    		 from HibernateDaoSupport. Spring detects if a Session already exists, and it uses that one instead
    		 of creating a new one. This allows you to use "Open Session in View" pattern for lazy loading 
    		 collections
    		-->
    	<bean id="alertDAO" class="org.coastal.urbancanyons.dao.AlertHibernateDAO">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	<bean id="bldgDAO" class="org.coastal.urbancanyons.dao.BuildingHibernateDAO">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	<bean id="userDAO" class="org.coastal.urbancanyons.dao.UserHibernateDAO">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	<bean id="emailDAO" class="org.coastal.urbancanyons.dao.EmailAddressHibernateDAO">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	<bean id="chatDAO" class="org.coastal.urbancanyons.dao.ChatMessageHibernateDAO">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    	</bean>
    	
    	<bean id="alertFacadeTarget" class="org.coastal.urbancanyons.facade.AlertFacadeImpl">
            <property name="alertDAO"><ref local="alertDAO"/></property>
    		<property name="bldgDAO"><ref local="bldgDAO"/></property>
    		<property name="userDAO"><ref local="userDAO"/></property>
    	</bean>
    	<bean id="chatFacadeTarget" class="org.coastal.urbancanyons.facade.ChatMessageFacadeImpl">
            <property name="chatDAO"><ref local="chatDAO"/></property>
    	</bean>	
        <bean id="alertFacade" class="org.springframework.aop.framework.ProxyFactoryBean">
    		
    		<!-- See Spring in Action page 122 -->
    		<!-- Defines what bean should be the target object of the generated proxy object. 		--> 
    		<property name="target">
    			<ref bean="alertFacadeTarget"/>
    		</property>
    
    		<!-- List of interfaces that should be implemented by the beans created by the factory. -->
    		<property name="proxyInterfaces">
    			<value>org.coastal.urbancanyons.facade.AlertFacade</value>
    		</property>
    		
    		<!-- Whether to proxy the target class, rather than implementing an interface. You
    		     must use CGLIB for this (i.e., the CGLIB JAR files must be deployed).-->
    		<property name="proxyTargetClass" >
    			<value>true</value>
    		</property> 
    		
    		<!-- List of advisor or advice bean names that should be applied to the target bean -->
    		<property name="interceptorNames">
    			<list>
    				<value>hibernateInterceptor</value>
    			</list>
    		</property>
         </bean>
    	<bean id="chatFacade" class="org.springframework.aop.framework.ProxyFactoryBean">
    		
    		<!-- See Spring in Action page 122 -->
    		<!-- Defines what bean should be the target object of the generated proxy object. 		--> 
    		<property name="target">
    			<ref bean="chatFacadeTarget"/>
    		</property>
    
    		<!-- List of interfaces that should be implemented by the beans created by the factory. -->
    		<property name="proxyInterfaces">
    			<value>org.coastal.urbancanyons.facade.ChatMessageFacade</value>
    		</property>
    		
    		<!-- Whether to proxy the target class, rather than implementing an interface. You
    		     must use CGLIB for this (i.e., the CGLIB JAR files must be deployed).-->
    		<property name="proxyTargetClass" >
    			<value>true</value>
    		</property> 
    		
    		<!-- List of advisor or advice bean names that should be applied to the target bean -->
    		<property name="interceptorNames">
    			<list>
    				<value>hibernateInterceptor</value>
    			</list>
    		</property>
         </bean>
    	
    </beans>
    I've declared Alert as an abstract class which is extended by two classes and I have an Alert hibernate mapping file that contains mappings for these two classes.

    I used to have Alert declared as a normal class file and everything worked until I refactored it to be abstract.

    But the error message doesn't make sense to me. Could some explain what I'm doing wrong?

    Thanks.

  • #2
    I think you have an error inside your mapping files - i.e. that classname starts with a lower case when it should be an upper one.
    Take a look at the Alert hibernate mapping.

    Comment

    Working...
    X