@Reference not working inside the *serviceImpl@Reference not working inside the *serviceImplhttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1213690892024-03-29T09:53:54Z2024-03-29T09:53:54Z@Reference not working inside the *serviceImplVishnu S Kumarhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1213690882022-02-25T15:02:38Z2022-02-25T15:00:46Z<p>Inside the service builder *serviceImpl class, the @Reference
annotation gives a null value and there is a catch here.When the impl
class first activates (inside the @activate function), the @reference
annotations works. But later, when we call a method inside the
service, @reference dependency is null.<br /> </p>
<pre>
<code class="language-java">public interface Base{}
................
@component(service = Base.class)
public class Parent implements Base{}
..................
@Component(.......)
public class testServiceImpl{
@Reference
private volatile Base b;
public void doSomething(){
b.test(); // null point exception
}
@Activate
@Modified
protected void activate(Map<String, Object> properties)
{
b.test(); // works here
}
}
}</code></pre>
<p> &