Search code examples
mavenaemsling

Sling Models, No Adaptable Class found, Ignoring


I am trying to get the simplest Sling Model example registered on my system, AEM6.0 SP2.

package com.company.services.osgi.entities;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
import javax.inject.Inject;

@Model(adaptables = Resource.class) 
public class Profile {
    @Inject 
    private String uniqueName;
}   

With the header added to the Maven Bundle Plugin

<groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
    <configuration>
      <instructions>
        <Sling-Model-Packages>
          com.company.services.osgi.entities.Profile
        </Sling-Model-Packages>

I see the warning ...

22.08.2015 18:32:11.017 WARN [OsgiInstallerImpl] org.apache.sling.models.impl.ModelPackageBundleListener No adaptable classes found in package com.company.services.osgi.entities.Profile, ignoring

I see the bundle is installed and started, so not sure what's wrong here. Does anyone have suggestions how to troubleshoot this problem?


Solution

  • It never fails. as soon as I post something here, I see the simplest thing. In this case I was adding the class, and not the package. Should have been...

        <Sling-Model-Packages>
          com.company.services.osgi.entities
        </Sling-Model-Packages>