Announcement Announcement Module
Collapse
No announcement yet.
bean ref not found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • bean ref not found

    Installed Spring-ide version 1.1.1 in Spring 3.01, and use Spring 1.2 rcX.
    Added nature to project and added context files to project.
    Problem: beans that are referenced with "ref bean" are not being found.

    In my applicationContext-db.xml file I have:
    Code:
        <bean id="propertyConfigurer" class="org.springframework.beans.
                factory.config.PropertyPlaceholderConfigurer">
            <description>Use the 'run.properties' file to 
                   override the properties 
                   used in the Spring container</description>
            <property name="properties"><ref  
                 bean="runProperties"></ref></property>        
        </bean>
    This refers to the bean in the root applicationContext.xml file:
    Code:
        <bean id="runProperties" class="org.springframework.beans.
             factory.config.PropertiesFactoryBean">
            <description></description>
            <property name="locations">
                <list>
                    <value>file&#58;run.properties</value>
                </list>
            </property>        
        </bean>

    All context files are flagged as in error in Eclipse. The app compiles and runs fine. I must be missing something about Spring-ide?

  • #2
    Hi jbetancourt,

    Spring IDE 1.1.1 ships with spring-core.jar version 1.1.5. Please don't use any features from the upcoming Spring 1.2 release e.g. inline values or refs. This is because the Spring IDE Xml parser (xerces) validates against the shipped dtd.

    If this does not help please provide the full spring config files as well as the .springProject file from your eclipse project.

    Greetings
    Christian

    Comment


    • #3
      Did you create a config set for your depending config files?

      Otherwise Spring IDE doesn't know anything about a relationship of certain config files and it validates every config file on it's own. With the existance of config sets config files which are part of a config set are validated within the context of a BeanFactory created from the config files belonging to the same config set.

      This way the bean references can be resolved during validation.

      Cheers,
      Torsten

      Comment


      • #4
        That fixed it, thanks.


        Originally posted by Torsten Juergeleit
        Did you create a config set for your depending config files?

        Otherwise Spring IDE doesn't know anything about a relationship of certain config files and it validates every config file on it's own. With the existance of config sets config files which are part of a config set are validated within the context of a BeanFactory created from the config files belonging to the same config set.

        This way the bean references can be resolved during validation.

        Cheers,
        Torsten

        Comment


        • #5
          Originally posted by Torsten Juergeleit
          Did you create a config set for your depending config files?
          This works if all the config-files are in the same project. But when some (or most) of the ref'ed beans are defined in config-files from other projects the I cannot eliminate the errors. (see http://springide.org/project/ticket/77)

          Is there some other workaround?

          Also when I remove the spring nature, the error markers remain. How can I get rid of the error markers after removing the spring nature?

          Comment


          • #6
            Originally posted by memelet
            This works if all the config-files are in the same project. But when some (or most) of the ref'ed beans are defined in config-files from other projects the I cannot eliminate the errors.
            For referencing config files in a different Spring project you have to select this external Spring project in the list of "Project References" in your Spring project's properties first. This way Spring IDE get's aware of your externally defined Spring config files. Now you can add the Spring config files of the external Spring project to config sets defined in your Spring project. The Java build path isn't checked for Spring projects because it's available for Java projects only. Spring projects don't have to be Java projects.
            Originally posted by memelet
            Also when I remove the spring nature, the error markers remain. How can I get rid of the error markers after removing the spring nature?
            To get rid of the problem markers you have the following options:
            • remove the config files from the Spring project via project properties dialog "Spring Beans / Config"
            • turn of displaying Spring IDE's problem markers at all (via the problem views' filter setting by deselecting "Spring Problem Marker")
            I have added these questions to the Spring IDE FAQ: http://springide.org/project/wiki/SpringideFaq

            Your ticket (http://springide.org/project/ticket/77) is updated as well.

            Comment


            • #7
              Originally posted by Torsten Juergeleit
              For referencing config files in a different Spring project you have to select this external Spring project in the list of "Project References" in your Spring project's properties first. This way Spring IDE get's aware of your externally defined Spring config files.
              I forgot to mention that I tried this (because it was indicated on the wiki somewhere), but it did not work. Even with the depedent project selected I was not offered the option to select config files from that project.

              (This is 1.2 running M7 BTW)

              Comment


              • #8
                Originally posted by memelet
                Even with the depedent project selected I was not offered the option to select config files from that project.
                Your are only offered to add them while creating / editing a config set ;-).

                I have updated the FAQ http://springide.org/project/wiki/SpringideFaq. Please edit entry 2.1 in this wiki page if it's not clearly defined yet . Thanx.

                Cheers,
                Torsten

                Comment


                • #9
                  Ok, I works now. Almost. Now I get a popup containing:

                  Errors during build.
                  Errors running builder "Spring Project Builder" on project bbt.liquidityarbitrage.
                  An error occurred while traversing resources.
                  The entry in the log contains:
                  Code:
                  java.lang.IllegalArgumentException&#58; Path for project must have only one segment.
                  	at org.eclipse.core.internal.utils.Assert.isLegal&#40;Assert.java&#58;60&#41;
                  	at org.eclipse.core.internal.resources.WorkspaceRoot.getProject&#40;WorkspaceRoot.java&#58;134&#41;
                  	at org.springframework.ide.eclipse.beans.core.internal.model.BeansModel.getProject&#40;BeansModel.java&#58;125&#41;
                  	at org.springframework.ide.eclipse.beans.core.internal.model.BeansModelUtils.getConfig&#40;BeansModelUtils.java&#58;55&#41;
                  	at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfigValidator.validate&#40;BeansConfigValidator.java&#58;96&#41;
                  	at org.springframework.ide.eclipse.beans.core.internal.project.BeansProjectValidator.build&#40;BeansProjectValidator.java&#58;69&#41;
                  	at org.springframework.ide.eclipse.core.internal.project.SpringProjectBuilder.build&#40;SpringProjectBuilder.java&#58;154&#41;
                  	at org.springframework.ide.eclipse.core.internal.project.SpringProjectBuilder.access$0&#40;SpringProjectBuilder.java&#58;150&#41;
                  	at org.springframework.ide.eclipse.core.internal.project.SpringProjectBuilder$Visitor.visit&#40;SpringProjectBuilder.java&#58;109&#41;
                  	at org.eclipse.core.internal.resources.Resource$2.visit&#40;Resource.java&#58;103&#41;
                  	at org.eclipse.core.internal.resources.Resource$1.visitElement&#40;Resource.java&#58;50&#41;
                  	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration&#40;ElementTreeIterator.java&#58;81&#41;
                  	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration&#40;ElementTreeIterator.java&#58;85&#41;
                  	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration&#40;ElementTreeIterator.java&#58;85&#41;
                  	at org.eclipse.core.internal.watson.ElementTreeIterator.iterate&#40;ElementTreeIterator.java&#58;126&#41;
                  	at org.eclipse.core.internal.resources.Resource.accept&#40;Resource.java&#58;60&#41;
                  	at org.eclipse.core.internal.resources.Resource.accept&#40;Resource.java&#58;101&#41;
                  	at org.eclipse.core.internal.resources.Resource.accept&#40;Resource.java&#58;80&#41;
                  	at org.springframework.ide.eclipse.core.internal.project.SpringProjectBuilder.build&#40;SpringProjectBuilder.java&#58;91&#41;
                  	at org.eclipse.core.internal.events.BuildManager$2.run&#40;BuildManager.java&#58;585&#41;
                  	at org.eclipse.core.internal.runtime.InternalPlatform.run&#40;InternalPlatform.java&#58;1029&#41;
                  	at org.eclipse.core.runtime.Platform.run&#40;Platform.java&#58;775&#41;
                  	at org.eclipse.core.internal.events.BuildManager.basicBuild&#40;BuildManager.java&#58;168&#41;
                  	at org.eclipse.core.internal.events.BuildManager.basicBuild&#40;BuildManager.java&#58;202&#41;
                  	at org.eclipse.core.internal.events.BuildManager$1.run&#40;BuildManager.java&#58;231&#41;
                  	at org.eclipse.core.internal.runtime.InternalPlatform.run&#40;InternalPlatform.java&#58;1029&#41;
                  	at org.eclipse.core.runtime.Platform.run&#40;Platform.java&#58;775&#41;
                  	at org.eclipse.core.internal.events.BuildManager.basicBuild&#40;BuildManager.java&#58;234&#41;
                  	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop&#40;BuildManager.java&#58;253&#41;
                  	at org.eclipse.core.internal.events.BuildManager.build&#40;BuildManager.java&#58;282&#41;
                  	at org.eclipse.core.internal.events.AutoBuildJob.doBuild&#40;AutoBuildJob.java&#58;139&#41;
                  	at org.eclipse.core.internal.events.AutoBuildJob.run&#40;AutoBuildJob.java&#58;200&#41;
                  	at org.eclipse.core.internal.jobs.Worker.run&#40;Worker.java&#58;67&#41;
                  The error only occurs with spring-nature enabled -- remove the spring-nature and the error is not issued.

                  Comment


                  • #10
                    Originally posted by memelet
                    Ok, I works now. Almost. Now I get a popup containing:
                    Errors during build.
                    Errors running builder "Spring Project Builder" on project bbt.liquidityarbitrage.
                    An error occurred while traversing resources.
                    I opened a new ticket: http://springide.org/project/ticket/80

                    Comment


                    • #11
                      Same problem for me

                      I am also having "ref bean not found" error in my spring configuration files.

                      I am running springide 1.2 on eclipse 3.1M6 with spring 1.2.1. I created a config set but still getting the error.

                      Any help is appreciated. Thanks!

                      Kenny

                      Comment

                      Working...
                      X