Uploaded image for project: 'Spring Tool Suite'
  1. Spring Tool Suite
  2. STS-3686

classloading confusion in combination with JavaConfig

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.0.M2
    • Component/s: None
    • Labels:
      None

      Description

      I am using the latest restbucks example app from Oliver and I came across this exception:

      Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter cannot be found by org.springframework.data.core_1.7.0.20140120-CI
      	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
      	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
      	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
      	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      	... 59 more

      followed by another one:

      java.lang.NoClassDefFoundError: javax/ws/rs/Path
      	at org.springframework.hateoas.config.LinkBuilderBeanDefinitionRegistrar$JaxRsEntityControllerBuilderDefinitionBuilder.getBeanDefinition(LinkBuilderBeanDefinitionRegistrar.java:99)
      	at org.springframework.hateoas.config.LinkBuilderBeanDefinitionRegistrar.registerBeanDefinitions(LinkBuilderBeanDefinitionRegistrar.java:74)
      	at org.springframework.hateoas.config.HypermediaSupportBeanDefinitionRegistrar.registerBeanDefinitions(HypermediaSupportBeanDefinitionRegistrar.java:96)
      	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:319)

      All this happens because of classloader confusion in Spring IDE, where the classloader that is being used for reading the JavaConfig is using a parent classloader from Spring IDE (org.springframework.ide.eclipse.core) that is itself having a DynamicImport-Package: * on its manifest. This opens the door to various issues around loading classes from the IDE instead of the project classpath.

        Activity

        Hide
        mlippert Martin Lippert added a comment -

        This is fixed now for 3.5.0.M2. I reduced the classloading scope in this part of the beans model creation to just the necessary spring framework libs instead of the org.springframework.ide.eclipse.core bundle.

        Show
        mlippert Martin Lippert added a comment - This is fixed now for 3.5.0.M2. I reduced the classloading scope in this part of the beans model creation to just the necessary spring framework libs instead of the org.springframework.ide.eclipse.core bundle.
        Hide
        mlippert Martin Lippert added a comment -

        We moved issue tracking for this project to https://github.com/spring-projects/spring-ide.
        If you would like to comment on or re-open this issue, please file a new issue at GitHub and refer to this one.

        Show
        mlippert Martin Lippert added a comment - We moved issue tracking for this project to https://github.com/spring-projects/spring-ide . If you would like to comment on or re-open this issue, please file a new issue at GitHub and refer to this one.

          People

          • Assignee:
            mlippert Martin Lippert
            Reporter:
            mlippert Martin Lippert
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: