riorio
riorio

Reputation: 6826

intellij and embedded Jetty - Error creating bean with name

TLDR

Getting error of Error creating bean with name... when running embedded Jetty within IntelliJ, but not when running the same code outside of Intellij - in a stand-alone Jetty server.

In-Depth

We have a web application that runs in a Jetty.

Up until a week ago, I was able to start and use the app with the Intellij's embedded Jetty.

A few days ago a colleague of mine updated one of the beans constructors and added to it a new bean that he created.

So in the zoowebappcontext.xml he added a new entry to the bean constructor:

 <bean id="animalsService" class="java.util.ArrayList">
    <constructor-arg>
        <list>
            <ref bean="pets.catService" />
            ....
            <ref bean="pets.dogService" />  <-- The new item
            ...

And in the applicationContext.xml file, he added a new bean definition, that looks very similar to all the other beans there:

    <bean id="pets.dogService"
      class="com.example.DogServiceImpl"
      parent="...">
    <property name="..." ref="..."/>
</bean>

The strange this is this: If I mvn clean install the project, have a new zoo.war , move it to the Jetty's webapp folder and start the app as a stand-alone Jetty, the app starts with no error.

But, when running the app within the intellij's embedded Jetty, the app tries to start and eventually fails with this error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'animalsService' defined in class path resource [zoowebappContext.xml]: Cannot resolve reference to bean 'pets.dogService' while setting constructor argument with key [14]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'pets.dogSerice' is defined

Moving the code to the commit before the above change, the intellij is able to start with no problems.

Upvotes: 1

Views: 3382

Answers (1)

riorio
riorio

Reputation: 6826

It seems like intelliJ had something that was stuck in its system, as just as the problem started, it simply vanished at some point.

Some things that may have helped to "reset" IntelliJ (none of them solved the problem by its own):

  • Restarting IntelliJ several times
  • Restating the computer
  • Switching back and forth between different GIT branches
  • File -> Invalidate Caches / Restart...

And again, none of the items by itself solve it.

Upvotes: 1

Related Questions