Results 1 to 4 of 4

Thread: ClassNotFound Exception

  1. #1
    Join Date
    Feb 2005
    Location
    Eskisehir, Turkiye
    Posts
    16

    Default ClassNotFound Exception

    Hi,
    I am trying to write a simple application with spring (which is in Spring in Action book)but i get the following error:


    Loading XML bean definitions from class path resource [aoptest/mrt/knight/knight.xml]
    Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=1607032777]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [quest,knightTarget,mintrel,knight]; root of BeanFactory hierarchy
    4 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=1607032777]
    Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.StaticMessageS ource: {}]
    Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@56cc56cc]
    Refreshing listeners
    Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [quest,knightTarget,mintrel,knight]; root of BeanFactory hierarchy]
    Creating shared instance of singleton bean 'quest'
    Creating shared instance of singleton bean 'knightTarget'
    Bean 'knightTarget' instantiated via constructor [public aoptest.mrt.knight.KnightOfTheRoundTable(java.lang .String)]
    Creating shared instance of singleton bean 'mintrel'
    Creating shared instance of singleton bean 'knight'
    Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [quest,knightTarget,mintrel,knight]; root of BeanFactory hierarchy}
    Destroying inner beans in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [quest,knightTarget,mintrel,knight]; root of BeanFactory hierarchy}
    SRVE0068E: Could not invoke the service() method on servlet Mrb. Exception thrown : org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'knight' defined in class path resource [aoptest/mrt/knight/knight.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.MethodInvocationExceptio n: Property 'proxyInterfaces' threw exception; nested exception is java.lang.ClassNotFoundException: aoptest.mrt.knight.Knight]


    I am definitely sure ( :evil: ) the interface Knight is in the aoptest.mrt.knight package

    the knight beans definition in xml file:

    <bean id="knight" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="interceptorNames">
    <list>
    <value>
    aoptest.mrt.knight.MinstrelAdvice
    </value>
    </list>
    </property>
    <property name="proxyInterfaces">
    <value>
    aoptest.mrt.knight.Knight
    </value>
    </property>
    <property name="target">
    <ref bean="knightTarget"/>
    </property>
    </bean>

    And the servlet code is: (I also tried to execute this code with a simple Java application then i got the same error.)


    ApplicationContext context = new ClassPathXmlApplicationContext("/aoptest/mrt/knight/knight.xml");

    try {
    Knight knight = (Knight)context.getBean("knight");
    knight.embarkOnQuest();
    } catch (Exception e) {
    e.printStackTrace();
    }

    Platform: Windows XP and Eclipse 3

    Thanx everyone.

    Murat HAZER

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    You need to remove cr/lf when using <value> tags:
    Code:
      <bean id="knight" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="interceptorNames">
          <list>
            <value>aoptest.mrt.knight.MinstrelAdvice</value>
          </list>
        </property>
        <property name="proxyInterfaces">
          <value>aoptest.mrt.knight.Knight</value>
        </property>
        <property name="target">
          <ref bean="knightTarget"/>
        </property>
      </bean>
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Feb 2005
    Posts
    217

    Default

    I believe ClassNotFound exceptions can be thrown if the JVM finds more then one class file of the same name. You could do some simple bash thing like this to get you started:
    Code:
    for i in $&#40;find . -type f -name \*.jar&#41;; do jar tf $i | grep class$ ; done | sort | uniq -d
    So what I would do is list all your jars in your classpath and see if there are any duplicates. By "all your jars" I mean anything that could possibly be loaded up -- check your container's shared lib directory for example.

  4. #4
    Join Date
    Feb 2005
    Location
    Eskisehir, Turkiye
    Posts
    16

    Default

    Thanx irbouho, problem is solved when i remove cr/lf tag in value tags. But i think spring should throw a different exception in this situation. Am i wrong? Also thanx to cwilkes.

    Have nice days.


    4Ever OpenSource :o

Similar Threads

  1. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  2. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  3. ClassNotFound Exception, please help
    By radone in forum Security
    Replies: 1
    Last Post: Jul 20th, 2005, 07:38 AM
  4. Replies: 0
    Last Post: Jul 11th, 2005, 05:49 PM
  5. Replies: 3
    Last Post: Nov 8th, 2004, 07:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •