You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "chickenlj (GitHub)" <gi...@apache.org> on 2019/02/18 06:54:24 UTC
[GitHub] [incubator-dubbo] chickenlj commented on issue #3476:
NullPointerException happened when using SpringContainer.getContext()
> 1. write a project that is a provider side exposed serviceA and in the service implimentation invokes another remote service serviceB. The invoke code is like this SpringContainer.getContext().getBean("ref");
I don't understand why `SpringContainer.getContext().getBean("ref");` will throw NPE, by the time `contextRefreshedEvent` is send, the reference of ServiceB should be ready in ApplicationContext for use.
`context.start()` should only be responsible for those beans that have implemented Lifecycle, as the javadoc showed:
```java
/**
* Start all registered beans that implement {@link Lifecycle} and are <i>not</i>
* already running. Any bean that implements {@link SmartLifecycle} will be
* started within its 'phase', and all phases will be ordered from lowest to
* highest value. All beans that do not implement {@link SmartLifecycle} will be
* started in the default phase 0. A bean declared as a dependency of another bean
* will be started before the dependent bean regardless of the declared phase.
*/
@Override
public void start() {
startBeans(false);
this.running = true;
}
```
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3476 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org