Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
Nível 1
Nível 2
Faça login na Comunidade
Faça logon para exibir todas as medalhas
Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
import com.day.cq.wcm.webservicesupport.Configuration; import com.day.cq.wcm.webservicesupport.ConfigurationManager; @Component(immediate=true) public class Videos { private final Logger log = Logger.getLogger(Videos.class); private Configuration configuration; @Reference private ConfigurationManager cfgMgr; public void connectToService() { configuration = cfgMgr.getConfiguration("mycustomservice"); } }
cfgMgr is null. I wonder why is a reference variable null anyway. Are there any other methods to get it? Any help is appreciated. Thanks.
Solucionado! Ir para a Solução.
Visualizações
respostas
Total de curtidas
The problem doesn't have anything to do with this class. It has to do with how you are accessing this class or really the instance. You are creating a new instance of this class. Instead, you should use the instance created by DS.
You should not use getServiceReference() in a DS component except for very specific needs (which this is definitely not an example of).
Visualizações
respostas
Total de curtidas
Looks right to me. Are you sure cfgMgr is null OR calling configuration cfgMgr.getConfiguration("mycustomservice") is null.
Visualizações
respostas
Total de curtidas
I am sure cfgMgr is null. I added a null check statement to find it out and it came out as null. Do you think I ran into any kind of bug here?
Visualizações
respostas
Total de curtidas
That is a possibility - when you inject a ConfigurationManager - it should not be null. Sham - do you think a ticket should be opened?
Visualizações
respostas
Total de curtidas
smacdonald2008 wrote...
That is a possibility - when you inject a ConfigurationManager - it should not be null. Sham - do you think a ticket should be opened?
So, is there another way of getting the ConfigurationManager without using Reference annotation? Please advise.
Visualizações
respostas
Total de curtidas
It is not a bug & I can'ot reproduce the issue. Which version of AEM? Are you seeing the configuration manager in your instance at http://localhost:4502/system/console/services
Otherway of getting is using bundlecontext getService method.
Visualizações
respostas
Total de curtidas
Sham HC wrote...
It is not a bug & I can'ot reproduce the issue. Which version of AEM? Are you seeing the configuration manager in your instance at http://localhost:4502/system/console/services
Otherway of getting is using bundlecontext getService method.
I am on CQ 5.5 I can see the service.
[img]Screen Shot 2013-10-10 at 3.38.46 PM.png[/img]
Visualizações
respostas
Total de curtidas
Do I have to add the package cq-wcm-webservice-support as an exclusive dependency to the maven pom.xml? Can you please provide me a code snippet to retrieve the service from BundleContext?
Visualizações
respostas
Total de curtidas
protected void activate(ComponentContext context) { BundleContext bundleContext = context.getBundleContext(); ServiceReference serviceReference = bundleContext.getServiceReference(ConfigurationManager.class.getName( )); ConfigurationManager cfgMgr = (ConfigurationManager) bundleContext.getService(serviceReference); }
In the above code also, I get cfgMgr as null. Sham, Can you please share the code that you have tested with?
Visualizações
respostas
Total de curtidas
The problem doesn't have anything to do with this class. It has to do with how you are accessing this class or really the instance. You are creating a new instance of this class. Instead, you should use the instance created by DS.
You should not use getServiceReference() in a DS component except for very specific needs (which this is definitely not an example of).
Visualizações
respostas
Total de curtidas
justin_at_adobe wrote...
The problem doesn't have anything to do with this class. It has to do with how you are accessing this class or really the instance. You are creating a new instance of this class. Instead, you should use the instance created by DS.
You should not use getServiceReference() in a DS component except for very specific needs (which this is definitely not an example of).
Well, if I access the DS instance of the class using @Reference annotation it returns null.
Visualizações
respostas
Total de curtidas
bhavani IKKURTHI wrote...
justin_at_adobe wrote...
The problem doesn't have anything to do with this class. It has to do with how you are accessing this class or really the instance. You are creating a new instance of this class. Instead, you should use the instance created by DS.
You should not use getServiceReference() in a DS component except for very specific needs (which this is definitely not an example of).
Well, if I access the DS instance of the class using @Reference annotation it returns null.
How are you getting the DS instance? Through the ScrService ?
Visualizações
respostas
Total de curtidas
justin_at_adobe wrote...
bhavani IKKURTHI wrote...
justin_at_adobe wrote...
The problem doesn't have anything to do with this class. It has to do with how you are accessing this class or really the instance. You are creating a new instance of this class. Instead, you should use the instance created by DS.
You should not use getServiceReference() in a DS component except for very specific needs (which this is definitely not an example of).
Well, if I access the DS instance of the class using @Reference annotation it returns null.
How are you getting the DS instance? Through the ScrService ?
I am not following you. DS instance of what? ConfigurationManager class?
Visualizações
respostas
Total de curtidas
bhavani IKKURTHI wrote...
justin_at_adobe wrote...
bhavani IKKURTHI wrote...
justin_at_adobe wrote...
The problem doesn't have anything to do with this class. It has to do with how you are accessing this class or really the instance. You are creating a new instance of this class. Instead, you should use the instance created by DS.
You should not use getServiceReference() in a DS component except for very specific needs (which this is definitely not an example of).
Well, if I access the DS instance of the class using @Reference annotation it returns null.
How are you getting the DS instance? Through the ScrService ?
I am not following you. DS instance of what? ConfigurationManager class?
No. The Videos class.
You are doing this:
Videos videos = new Videos(); videos.connectToService()
This is a different instance of the Videos class than the one which is managed by the Declaritive Services (DS) runtime. Only the managed instance will have the fields injected. Any other instance of this class will not.
Visualizações
respostas
Total de curtidas
Visualizações
Curtida
respostas