Bundle installation rejected by hook error | Community
Skip to main content
medhik
Level 2
July 18, 2016
Solved

Bundle installation rejected by hook error

  • July 18, 2016
  • 9 replies
  • 2757 views

Hey,

I'm working through Adobe training videos. But I'm stuck while trying to extend SlingSafeMethodsServlet. Basically I want to retrieve page data as JSON when I use a selector .data.html.

I get a build success but when I see error.log, I see the following.

17.07.2016 23:38:06.358 *INFO* [JcrInstaller.1] org.apache.sling.installer.provider.jcr.impl.JcrInstaller Registering resource with OSGi installer: [InstallableResource, priority=200, id=/apps/company/install/company-core-0.0.1-SNAPSHOT.jar]
17.07.2016 23:38:06.389 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.BundleInstallTask Exception during install of bundle TaskResource(url=jcrinstall:/apps/company/install/company-core-0.0.1-SNAPSHOT.jar, entity=bundle:com.adobe.training.company-core, state=INSTALL, attributes=[org.apache.sling.installer.api.tasks.ResourceTransformer=:24:43:21:, Bundle-SymbolicName=com.adobe.training.company-core, Bundle-Version=0.0.1.SNAPSHOT], digest=1468816686280) : Bundle installation rejected by hook.. Retrying later.
org.osgi.framework.BundleException: Bundle installation rejected by hook.
    at org.apache.felix.framework.Felix.installBundle(Felix.java:3123)
    at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:167)
    at org.apache.sling.installer.core.impl.tasks.BundleInstallTask.execute(BundleInstallTask.java:47)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.doExecuteTasks(OsgiInstallerImpl.java:847)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:689)
    at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:265)
    at java.lang.Thread.run(Unknown Source)

 

Looking forward to some inputs to resolve this error as I don't see currently the servlet gets executed on hitting .data.html.

 

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

I got your Java servlet to work - as shown here: 

I followed our AEM Community article on how to bind a servlet via a Resource Type: 

https://helpx.adobe.com/experience-manager/using/resourcetypes.html

The only difference was I replaced the code in the article with your Java code you listed here. 

It works by using this URL: http://localhost:4502/content/submitPage.groups.html

Hope this points you in the right direction... 

 

Also - as reference by Ratna - one of our super users - you need to add this dependency to your POM file to use your Java code: 

<dependency>
    <groupId>org.apache.sling</groupId>
    <artifactId>org.apache.sling.commons.json</artifactId>
    <version>2.0.10</version>
    <scope>provided</scope>
</dependency>

9 replies

smacdonald2008
Level 10
July 18, 2016

Can you please post what annotations are you using for the Sling Servlet - post the code please. 

medhik
medhikAuthor
Level 2
July 18, 2016

Here is the code-

package com.adobe.training.core;

 

import java.io.IOException;

import javax.jcr.Repository;

import javax.servlet.ServletException;

import org.apache.felix.scr.annotations.Reference;

import org.apache.felix.scr.annotations.sling.SlingServlet;

import org.apache.sling.api.SlingHttpServletRequest;

import org.apache.sling.api.SlingHttpServletResponse;

import org.apache.sling.api.servlets.SlingSafeMethodsServlet;

import org.apache.sling.commons.json.JSONException;

import org.apache.sling.commons.json.JSONObject;

 

@SlingServlet(resourceTypes="/geometrixx/components/contentpage", selectors="data", methods = "GET")
//@SlingServlet(paths="/content/dam/geometrixx")

public class MySlingSafeMethodServlet extends SlingSafeMethodsServlet {

    private static final long serialVersionUID = -3960692666512058118L;

    @Reference

    private Repository repository;

    @Override

    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {

        response.setHeader("Content-Type", "application/json");

        //response.getWriter().print("{\"coming\" : \"soon\"}");

        String[] keys = repository.getDescriptorKeys();

        JSONObject jsonObject = new JSONObject();

        for (int i = 0; i< keys.length; i++) {

            try{

                jsonObject.put(keys[i], repository.getDescriptor(keys[i]));

            }

            catch (JSONException e) {

                e.printStackTrace();

            }

        }

        response.getWriter().print(jsonObject.toString()); 

    }

}

smacdonald2008
Level 10
July 18, 2016

I will test this and post back my findings. 

medhik
medhikAuthor
Level 2
July 19, 2016

Hey smacdonald2008,

Could you try this out? Looking forward to your response.

Thanks!

smacdonald2008
Level 10
July 19, 2016

I will be starting this in the afternoon today. I will post back my findings. 

smacdonald2008
smacdonald2008Accepted solution
Level 10
July 19, 2016

I got your Java servlet to work - as shown here: 

I followed our AEM Community article on how to bind a servlet via a Resource Type: 

https://helpx.adobe.com/experience-manager/using/resourcetypes.html

The only difference was I replaced the code in the article with your Java code you listed here. 

It works by using this URL: http://localhost:4502/content/submitPage.groups.html

Hope this points you in the right direction... 

 

Also - as reference by Ratna - one of our super users - you need to add this dependency to your POM file to use your Java code: 

<dependency>
    <groupId>org.apache.sling</groupId>
    <artifactId>org.apache.sling.commons.json</artifactId>
    <version>2.0.10</version>
    <scope>provided</scope>
</dependency>

Lokesh_Shivalingaiah
Level 10
July 19, 2016

Also, "reject by hook" is just an info and not ERROR.

Re-install the bundle and see if that works ! else follow the article which Scott has mentioned and that should be working.

medhik
medhikAuthor
Level 2
July 19, 2016

Thanks all for you response!

 

smacdonald2008,

The code that I had shared was nothing but Adobe provides as part of their online training course and it is supposed to work as it is.

Should this be looked into then for completeness of the training material?

Cheers!

smacdonald2008
Level 10
July 19, 2016

I will talk to the training team. In future - check out community HELPX articles - complete listing here: 

https://helpx.adobe.com/experience-manager/topics/how-to.html