Skip to content

Instantly share code, notes, and snippets.

import com.icfolson.aem.groovy.console.api.BindingExtensionProvider;
import com.icfolson.aem.groovy.console.api.BindingVariable;
import com.icfolson.aem.groovy.console.api.context.ScriptContext;
import org.osgi.service.component.annotations.Component;
import java.util.HashMap;
import java.util.Map;
// Tells the Groovy Console bundle to use this class as an extension to the default Binding
@Component(service = BindingExtensionProvider.class, immediate = true)
<dependency>
<groupId>com.icfolson.aem.groovy.console</groupId>
<artifactId>aem-groovy-console</artifactId>
<version>15.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.15</version>
<embedded>
<groupId>com.icfolson.aem.groovy.console</groupId>
<artifactId>aem-groovy-console</artifactId>
<!-- Use your /apps directory -->
<target>/apps/demo/install</target>
</embedded>
<dependency>
<groupId>com.icfolson.aem.groovy.console</groupId>
<artifactId>aem-groovy-console</artifactId>
<version>15.1.0</version>
<type>zip</type>
</dependency>
//region
import com.day.cq.replication.ReplicationOptions
import com.day.cq.search.QueryBuilder
import com.day.cq.wcm.api.PageManager
import org.apache.sling.api.SlingHttpServletRequest
import org.apache.sling.api.SlingHttpServletResponse
import org.apache.sling.api.resource.ResourceResolver
import org.osgi.framework.BundleContext
import org.slf4j.Logger
<!-- Common overlay roots -->
<filter><root>/apps/sling</root></filter>
<filter><root>/apps/cq</root></filter>
<filter><root>/apps/dam</root></filter>
<filter><root>/apps/wcm</root></filter>
<filter><root>/apps/msm</root></filter>
@Model(
adaptables = Resource.class,
adapters = DemoModel.class,
resourceType = DemoModelImpl.RESOURCE_TYPE,
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)
public class DemoModelImpl implements DemoModel {
public static final String RESOURCE_TYPE = "demo/components/content/demo";
@Model(
adaptables = Resource.class,
adapters = TestModel.class,
resourceType = TestModelImpl.RESOURCE_TYPE
)
@Slf4j
public class TestModelImpl implements TestModel {
public static final String RESOURCE_TYPE = "demo/components/content/test";
Caused by: org.apache.sling.models.factory.MissingElementsException: Could not inject all required fields into class com.theopendle.core.models.impl.TestModelImpl
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:765) [org.apache.sling.models.impl:1.4.10]
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:448) [org.apache.sling.models.impl:1.4.10]
at org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:314) [org.apache.sling.models.impl:1.4.10]
at org.apache.sling.scripting.sightly.models.impl.SlingModelsUseProvider.provide(SlingModelsUseProvider.java:135) [org.apache.sling.scripting.sightly.models.provider:1.0.8]
at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:72) [org.apache.sling.scripting.sightly:1.1.2.1_4_0]
... 298 common frames omitted
Suppressed: org.apache.sling.models.factory.MissingElementException: Could not
Caused by: org.apache.sling.models.factory.PostConstructException: Post-construct method has thrown an exception for model class com.theopendle.core.models.impl.TestModelImpl
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:774) [org.apache.sling.models.impl:1.4.10]
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:448) [org.apache.sling.models.impl:1.4.10]
at org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:314) [org.apache.sling.models.impl:1.4.10]
at org.apache.sling.scripting.sightly.models.impl.SlingModelsUseProvider.provide(SlingModelsUseProvider.java:135) [org.apache.sling.scripting.sightly.models.provider:1.0.8]
at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:72) [org.apache.sling.scripting.sightly:1.1.2.1_4_0]
... 298 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.theopendle.c