I am writing a standalone script in java which is trying to modify some tags on my AEM instance. I am running into a problem when trying to get an instance of TagManager (com.day.cq.tagging.TagManager).
Here is what I have tried:
Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server"); Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray())); JcrTagManagerFactoryImpl tagManagerFactory = new JcrTagManagerFactoryImpl(); TagManager tagManager = tagManagerFactory.getTagManager(session);
There is a NullPointerException being thrown on my last line of code there and I am not sure why. I would like to be clear that since this script is not being installed onto my AEM server (it is not a servlet), I cannot obtain the TagManager from a ResourceResolver. Also my session object is working correctly (I testing adding nodes through it and it was fine).
Thankyou for any help.
Solved! Go to Solution.
You problem is that the JcrTagManagerFactoryImpl class is not intended to be used in a stand alone application. It is an OSGI service and will only work properly when accessed as and OSGI service. If you look at the service it has OSGI references to the SlingRepository and the Sling JcrResourceResolver. The service won't work in a standalone Java application. You'll either have to use standard JCR interfaces to manipulate the tag nodes, or you have to migrate your standalone script to a JSP or servlet that executes on an AEM instance.
You problem is that the JcrTagManagerFactoryImpl class is not intended to be used in a stand alone application. It is an OSGI service and will only work properly when accessed as and OSGI service. If you look at the service it has OSGI references to the SlingRepository and the Sling JcrResourceResolver. The service won't work in a standalone Java application. You'll either have to use standard JCR interfaces to manipulate the tag nodes, or you have to migrate your standalone script to a JSP or servlet that executes on an AEM instance.
orotas wrote...
You problem is that the JcrTagManagerFactoryImpl class is not intended to be used in a stand alone application. It is an OSGI service and will only work properly when accessed as and OSGI service. If you look at the service it has OSGI references to the SlingRepository and the Sling JcrResourceResolver. The service won't work in a standalone Java application. You'll either have to use standard JCR interfaces to manipulate the tag nodes, or you have to migrate your standalone script to a JSP or servlet that executes on an AEM instance.
Thankyou very much, very clear answer.
Views
Replies
Total Likes