如何通过激活器激活AEM Bundel?

时间:2018-12-31 07:28:45

标签: java aem

当我将AEM上传到bundel时,我已经为自己的现有项目开发了http://localhost:8182:/system/console/bundles捆绑包。它没有被激活,我解决了所有与依赖相关的异常。但是对于以下异常,我没有任何线索。

我使用以下命令创建了Bundel项目:

mvn archetype:generate -DarchetypeRepository=http://repo.adobe.com/nexus/content/groups/public/ -DarchetypeGroupId=com.day.jcr.vault -DarchetypeArtifactId=multimodule-content-package-archetype -DarchetypeVersion=1.0.2 -DgroupId=com.adobe.cq -DartifactId=receiptService -Dversion=1.0-SNAPSHOT -Dpackage=com.adobe.cq -DappsFolderName=myproject -DartifactName="My Project" -DcqVersion="5.6.1" -DpackageGroup="Receipt Service"

pom.xml中的代码段

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<!-- ====================================================================== -->
<!-- P A R E N T P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->
<parent>
    <groupId>com.adobe.cq</groupId>
    <artifactId>receiptService</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<!-- ====================================================================== -->
<!-- P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->

<artifactId>receiptService-bundle</artifactId>
<packaging>bundle</packaging>
<name>Receipt Service Bundle</name>

<properties>
    <slf4j.version>1.7.5</slf4j.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.scr.annotations</artifactId>
    </dependency>
    <dependency>
        <groupId>biz.aQute</groupId>
        <artifactId>bndlib</artifactId>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.jcr</groupId>
        <artifactId>jcr</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.jcr.api</artifactId>
    </dependency>

    <!-- Dependency added by Developer (1574973) start -->

    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>javax.persistence-api</artifactId>
        <version>2.2</version>
    </dependency>

    <dependency>
        <groupId>commons-discovery</groupId>
        <artifactId>commons-discovery</artifactId>
        <version>0.4</version>
    </dependency>

    <dependency>
         <groupId>org.codehaus.jackson</groupId>
         <artifactId>jackson-mapper-asl</artifactId>
         <version>1.9.0</version>
    </dependency>

    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>javax.transaction-api</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.9</version>
    </dependency>

    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901.jdbc4</version>
    </dependency>

    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxrpc-api</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency>
        <groupId>javax.xml.rpc</groupId>
        <artifactId>javax.xml.rpc-api</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.6.11</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tika</groupId>
        <artifactId>tika-core</artifactId>
        <version>1.12</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>5.1.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.1.3.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>5.1.3.RELEASE</version>
    </dependency>


    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.11</version>
    </dependency>

    <!-- Spring end -->

    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
 </dependency>

 <dependency>
     <groupId>org.slf4j</groupId>
     <artifactId>slf4j-api</artifactId>
     <version>${slf4j.version}</version>
  </dependency>
  <dependency>
     <groupId>org.slf4j</groupId>
     <artifactId>jcl-over-slf4j</artifactId>
     <version>${slf4j.version}</version>
  </dependency>
  <dependency>
     <groupId>org.slf4j</groupId>
     <artifactId>slf4j-simple</artifactId>
     <version>${slf4j.version}</version>
     <scope>runtime</scope>
  </dependency>


  <dependency>
    <groupId>wsdl4j</groupId>
    <artifactId>wsdl4j</artifactId>
    <version>1.6.2</version>
</dependency>



<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.2.8.Final</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.5.Final</version>
</dependency>

<dependency>
    <groupId>org.hibernate.common</groupId>
    <artifactId>hibernate-commons-annotations</artifactId>
    <version>4.0.4.Final</version>
</dependency>

<dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.0.9</version>
    </dependency>

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.6.2</version>
</dependency>

<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.3</version>
</dependency>

<dependency>
    <groupId>javax.xml.rpc</groupId>
    <artifactId>javax.xml.rpc-api</artifactId>
    <version>1.1.1</version>
</dependency>

        <!-- External Dependency start -->
    <dependency>
         <groupId>esbaccountserviceclient-0.0.1-SNAPSHOT</groupId>
         <artifactId>esbaccountserviceclient-0.0.1-SNAPSHOT</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\lib\esbaccountserviceclient-0.0.1-SNAPSHOT.jar</systemPath>
    </dependency>

  <dependency>
         <groupId>objectmodel-0.0.1-SNAPSHOT</groupId>
         <artifactId>objectmodel-0.0.1-SNAPSHOT.jar</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\lib\objectmodel-0.0.1-SNAPSHOT.jar</systemPath>
  </dependency>

  <dependency>
        <groupId>com.tagic</groupId>
        <artifactId>logger</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <scope>system</scope>
        <systemPath>${basedir}\lib\logger-0.0.1-SNAPSHOT.jar</systemPath>
    </dependency>
    <!-- External Dependency end -->

    <!-- Dependency added by Developer (1574973) end -->

</dependencies>

<!-- ====================================================================== -->
<!-- B U I L D D E F I N I T I O N -->
<!-- ====================================================================== -->
<build>
    <plugins>
    <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <!-- <version>2.3.7</version> -->
            <extensions>true</extensions>
            <configuration>
                <unpackBundle>true</unpackBundle>
                <instructions>
                    <Bundle-SymbolicName>com.adobe.cq.receiptService-bundle</Bundle-SymbolicName>
                    <Bundle-Version>1.1-SNAPSHOT</Bundle-Version>
                    <Import-Package>*;resolution:=optional</Import-Package>
                    <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
                    <Bundle-Activator>com.tagic.receipt.service.activator.ReceiptServiceBundleActivator</Bundle-Activator>

                </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.10.3</version>
            <configuration>
                <show>private</show>
                <nohelp>true</nohelp>
                <excludePackageNames>com.tagic.receipt.handler.service.ReceiptOnlineHandlerService*:com.tagic.receipt.service.activator*</excludePackageNames>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.sling</groupId>
            <artifactId>maven-sling-plugin</artifactId>
            <configuration>
                <slingUrl>http://${crx.host}:${crx.port}/apps/myproject/install</slingUrl>
                <usePut>true</usePut>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
     </plugins>
</build>

异常堆栈跟踪:

com.adobe.cq.receiptService-bundle BundleEvent INSTALLED
31.12.2018 16:15:35.475 *INFO* [qtp570764101-243] com.adobe.cq.receiptService-bundle BundleEvent RESOLVED
31.12.2018 16:15:35.475 *INFO* [qtp570764101-243] com.adobe.cq.receiptService-bundle BundleEvent STARTING
31.12.2018 16:15:35.569 *INFO* [qtp570764101-243] com.adobe.cq.receiptService-bundle BundleEvent STOPPING
31.12.2018 16:15:35.569 *INFO* [qtp570764101-243] com.adobe.cq.receiptService-bundle BundleEvent STOPPED
31.12.2018 16:15:35.569 *ERROR* [qtp570764101-243] org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Activator start error in bundle com.adobe.cq.receiptService-bundle [3282].)
org.osgi.framework.BundleException: Activator start error in bundle com.adobe.cq.receiptService-bundle [3282].
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2273)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2141)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:977)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:964)
    at org.apache.felix.webconsole.internal.core.BundlesServlet.doPost(BundlesServlet.java:365)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:555)
    at org.apache.felix.webconsole.internal.servlet.OsgiManager$3.run(OsgiManager.java:459)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:455)
    at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:336)
    at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:297)
    at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:93)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:50)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:129)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:89)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at com.adobe.granite.license.impl.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:308)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:290)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.featureflags.impl.FeatureManager.doFilter(FeatureManager.java:115)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:76)
    at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:49)
    at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:497)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/google/gson/Gson
    at com.tagic.receipt.handler.service.impl.ReceiptOnlineHandlerServiceImpl.<init>(ReceiptOnlineHandlerServiceImpl.java:62)
    at com.tagic.receipt.service.activator.ReceiptServiceBundleActivator.start(ReceiptServiceBundleActivator.java:27)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2223)
    ... 66 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson not found by com.adobe.cq.receiptService-bundle [3282]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1557)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1998)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 70 common frames omitted
31.12.2018 16:15:44.608 *INFO* [qtp570764101-234] com.adobe.cq.receiptService-bundle BundleEvent STARTING
31.12.2018 16:15:44.608 *INFO* [qtp570764101-234] com.adobe.cq.receiptService-bundle BundleEvent STOPPING
31.12.2018 16:15:44.608 *INFO* [qtp570764101-234] com.adobe.cq.receiptService-bundle BundleEvent STOPPED
31.12.2018 16:15:44.608 *ERROR* [qtp570764101-234] org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Activator start error in bundle com.adobe.cq.receiptService-bundle [3282].)
org.osgi.framework.BundleException: Activator start error in bundle com.adobe.cq.receiptService-bundle [3282].
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2273)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2141)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:977)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:964)
    at org.apache.felix.webconsole.internal.core.BundlesServlet.doPost(BundlesServlet.java:365)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:555)
    at org.apache.felix.webconsole.internal.servlet.OsgiManager$3.run(OsgiManager.java:459)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:455)
    at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:336)
    at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:297)
    at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:93)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:50)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:129)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:89)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at com.adobe.granite.license.impl.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:308)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:290)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.featureflags.impl.FeatureManager.doFilter(FeatureManager.java:115)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
    at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:108)
    at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:80)
    at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:46)
    at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
    at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:76)
    at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:49)
    at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:497)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/google/gson/Gson
    at com.tagic.receipt.handler.service.impl.ReceiptOnlineHandlerServiceImpl.<init>(ReceiptOnlineHandlerServiceImpl.java:62)
    at com.tagic.receipt.service.activator.ReceiptServiceBundleActivator.start(ReceiptServiceBundleActivator.java:27)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2223)
    ... 66 common frames omitted

激活器,在注册服务时会引发异常

public class ReceiptServiceBundleActivator implements BundleActivator {
    private static final Logger logger = new Logger().getInstance(CommonConstants.MOTOR_MODULE_ID);
    private static volatile BundleContext bundleContext;
    public void start(BundleContext context) throws Exception {
        try {
            Hashtable<String, String> props = new Hashtable<String, String>();
            props.put("Language", "English");
            context.registerService(ReceiptOnlineHandlerService.class.getName(), new ReceiptOnlineHandlerServiceImpl(), props);
            logger.entry(className,"start","receiptService ReceiptOnlineHandlerService Registered: ", ReceiptOnlineHandlerServiceImpl.class.getName());
            bundleContext=context;
        } catch (Exception e) {
            logger.fatal("commonServiceBundleActivator :: Exception Occured: "+ e.getMessage());
            e.printStackTrace();
        }
    }
    public void stop(BundleContext context) throws Exception {
    }
    public static final BundleContext getBundleContext() {
        return bundleContext;
    }
}

在将要使用此Bundel的主项目中,将通过以下代码段进行访问

BundleContext context = FrameworkUtil.getBundle(ReceiptOnlineHandlerService.class).getBundleContext();

加载上下文后,将通过以下方式调用所需的服务

ServiceReference serviceRef = context.getServiceReference(ReceiptOnlineHandlerService.class.getName());
                if (serviceRef != null) {
                    ReceiptOnlineHandlerService recepitResponse = (ReceiptOnlineHandlerService)context.getService(serviceRef);

哪里出了错?

1 个答案:

答案 0 :(得分:0)

The answer is in the stack trace. It is missing classes: Caused by: java.lang.NoClassDefFoundError: com/google/gson/Gson. Usually, Gson should be part of AEM out-of-the-box. Check if it is there and export/import of the classes works.

Thank You Jens