ClassNotFoundException: ObjectServiceDescriptor in OSGi

1.7k Views Asked by At

I am trying to develop a simple java program that calls DFS web services and I get this runtime error:

Caused by: com.emc.documentum.fs.rt.impl.servicemodel.ServiceModelException: Service descriptor class not found: "java.lang.ClassNotFoundException: com.emc.documentum.fs.services.core.client.ObjectServiceDescriptor".
at com.emc.documentum.fs.rt.impl.servicemodel.JavaBeanTreeFactory.getDescriptor(JavaBeanTreeFactory.java:218)
at com.emc.documentum.fs.rt.impl.servicemodel.JavaBeanTreeFactory.getModule(JavaBeanTreeFactory.java:41)
at com.emc.documentum.fs.rt.context.ServiceFactory.makeServiceUrl(ServiceFactory.java:332)
at com.emc.documentum.fs.rt.context.ServiceFactory.getRemoteService(ServiceFactory.java:143)
at com.emc.documentum.fs.rt.context.ServiceFactory.getRemoteService(ServiceFactory.java:197)
at info.hartmann.dfs.impl.Handler.init(Handler.java:112)

I'm using maven to build a project and to install it into the OSGi container of Adobe CQ5. I tried this same code in a usual Java application in Eclipse and it worked.

The strange thing for me is that this class ObjectServiceDescriptor is in one of the .jar libraries which I include through maven dependencies. The jar name is emc-dfs-services-remote-1.0.jar. If I open my .jar generated by maven, I can see the emc-dfs-services-remote-1.0.jar there.

The project compilation goes without any problems, but during runtime I get the error on this line:

IObjectService objectService = serviceFactory.getRemoteService(com.emc.documentum.fs.services.core.client.IObjectService.class, serviceContext,  module, host);

My pom.xml is below. As you see, I declare some of the packages as optional in Imported-Packages. If I don't do this, my bundle can be compiled, but cannot be started. Could declaring these packages as optional be the problem?

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>CXF-example-ievgen</groupId>
    <artifactId>CXF-example-ievgen</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>bundle</packaging>
    <name>Ievgeng sample bundle</name>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>maven-sling-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install-bundle</id>
                        <goals>
                            <goal>install</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <slingUrl>http://192.168.56.101:4502/system/console</slingUrl>
                    <user>user</user>
                    <password>password</password>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-scr-plugin</artifactId>
                <version>1.7.2</version>
                <executions>
                    <execution>
                        <id>generate-scr-scrdescriptor</id>
                        <goals>
                            <goal>scr</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.1.0</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>wrap-my-dependency</id>
                        <goals>
                            <goal>wrap</goal>
                        </goals>
                        <configuration>
                            <wrapImportPackage>;</wrapImportPackage>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <instructions>
                        <Export-Package>info.hartmann.dfs.api</Export-Package>
                        <Private-Package>info.hartmann.dfs.impl

                        </Private-Package>
                        <!-- bundle supplied resource prefixes -->
                        <Include-Resource>{maven-resources}</Include-Resource>

                        <!-- Do not inline jars, include as jar files -->
                        <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
                        <Embed-Transitive>true</Embed-Transitive>

                        <!-- use _exportcontents instead of Export-Package to avoid conflict with Embed-Dependency an inline=true -->
                        <!-- <_exportcontents> -->
                        <!-- org.apache.cxf.*;version=${project.version} -->
                        <!-- </_exportcontents> -->

                        <!-- declare optional dependencies -->
                        <Import-Package>
                         com.documentum.fc.client.search;resolution:=optional,
                         com.documentum.fc.client.impl.session;resolution:=optional,
                         com.documentum.fc.common;resolution:=optional,
                         com.documentum.fc.client;resolution:=optional,
                         com.documentum.com;resolution:=optional,
                         com.documentum.ci;resolution:=optional,
                         com.documentum.ucf.*;resolution:=optional,
                         com.documentum.operations.*;resolution:=optional,
                         com.documentum.registry;resolution:=optional,
                         com.documentum.xerces_2_8_0.xerces.impl.dv.util;resolution:=optional,
                         org.slf4j.*;resolution:=optional,
                         org.osgi.*;resolution:=optional,
                         com.emc.documentum.kerberos.*;resolution:=optional,
                         javax.xml.registry.*;resolution:=optional,
                         jp.co.swiftinc.relax.*;resolution:=optional,
                         junit.framework;resolution:=optional,
                         org.apache.xerces.*;resolution:=optional,
                         org.apache.xml.*;resolution:=optional,
                         sun.io;resolution:=optional,
                         sun.misc;resolution:=optional,
                         sun.nio.cs;resolution:=optional,
                         sun.security.action;resolution:=optional,
                         com.sun.tools.javadoc;resolution:=optional,
                         org.apache.regexp;resolution:=optional,
                         org.apache.tools.*;resolution:=optional,
                         org.apache.xerces.*;resolution:=optional,
                         org.apache.xml.*;resolution:=optional,
                         org.aspectj.bea.jvm;resolution:=optional,
                         org.eclipse.jface.text;resolution:=optional,
                         org.eclipse.osgi.framework.*;resolution:=optional,
                         org.eclipse.osgi.internal.profile;resolution:=optional,
                         org.eclipse.osgi.service.*;resolution:=optional,
                         org.eclipse.osgi.util;resolution:=optional,
                         org.eclipse.update.configurator;resolution:=optional, 
                         *
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>





        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
org.apache.felix
                                        </groupId>
                                        <artifactId>
maven-scr-plugin
                                        </artifactId>
                                        <versionRange>
[1.7.2,)
                                        </versionRange>
                                        <goals>
                                            <goal>scr</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore/>
                                    </action>
                                </pluginExecution>

                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

    </build>



    <dependencies>
       <dependency>
            <groupId>activation</groupId>
            <artifactId>activation</artifactId>
            <!-- actually it is version 1.1 but i didnt get how to resolve error -->
            <version>1.0</version>
            <scope>runtime</scope>      
        </dependency>
        <dependency>
            <groupId>aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.5.2a</version>
            <scope>compile</scope>  
        </dependency>
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>emc-collaboration</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.2</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.4</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>emc-admin-services-remote</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
            <!--<systemPath>${project.basedir}/src/main/resources/emc-admin-services-remote.jar</systemPath>-->
        </dependency>
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>emc-bpm-services-remote</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>emc-ci-services-remote</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>emc-dfs-rt-remote</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>emc-dfs-services-remote</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>emc-search-services-remote</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.fastinfoset</groupId>
            <artifactId>FastInfoset</artifactId>
            <version>1.2</version>
        </dependency>      
        <dependency>
            <groupId>com.emc</groupId>
            <artifactId>http</artifactId>
            <version>1.0</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb1-impl</artifactId>
            <version>2.1.4</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.0</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.1.11</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>jaxws-api</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.1.7</version>
        </dependency>        
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jsr173_api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>javax.jws</groupId>
            <artifactId>jsr181-api</artifactId>
            <version>1.0</version>
        </dependency>        
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.jvnet</groupId>
            <artifactId>mimepull</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>com.sun.org.apache.xml.internal</groupId>
            <artifactId>resolver</artifactId>
            <version>20050927</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>saaj-api</artifactId>
            <version>1.3</version>
        </dependency>         
        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.3.3</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.stream</groupId>
            <artifactId>sjsxp</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.jvnet.staxex</groupId>
            <artifactId>stax-ex</artifactId>
            <version>1.0</version>
            <scope>runtime</scope>
            <!--<systemPath>${project.basedir}/src/main/resources/stax-ex.jar</systemPath>-->
        </dependency>
        <dependency>
            <groupId>com.sun.xml.stream.buffer</groupId>
            <artifactId>streambuffer</artifactId>
            <version>0.8</version>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.5.0</version>
        </dependency> 
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.scr.annotations</artifactId>
            <version>1.6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.commons.osgi</artifactId>
            <version>2.0.2-incubator</version>
            <type>bundle</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.osgi.compendium</artifactId>
            <version>1.4.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.commons.log</artifactId>
            <version>2.0.6</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

Bundle classpath after installing into OSGi console:

    Bundle Classpath    ., sjsxp-1.0.jar, emc-collaboration-1.0.jar, FastInfoset-1.2.jar, 
aspectjrt-1.5.2a.jar,stax-api-1.0.jar,jsr250-api-1.0.jar,activation-1.0.jar, 
resolver-20050927.jar,streambuffer-0.8.jar,jsr181-api-1.0.jar,
jsr173_api-1.0.jar,jaxb1-impl-2.1.4.jar, emc-dfs-rt-remote-1.0.jar,
commons-lang-2.4.jar,commons-io-1.2.jar,stax-ex-1.0.jar,saaj-impl-1.3.3.jar, 
jaxws-rt-2.1.7.jar,xercesImpl-2.5.0.jar,jaxb-api-2.0.jar,mimepull-1.4.jar, 
emc-bpm-services-remote-1.0.jar,emc-search-services-remote-1.0.jar,activation-1.1.jar,http-1.0.jar,
 jaxb-impl-2.1.11.jar,jaxws-api-2.1.jar,emc-ci-services-remote-1.0.jar,
emc-admin-services-remote-1.0.jar, emc-dfs-services-remote-1.0.jar,servlet-api-1.0.jar,saaj-api-1.3.jar

My Java code:

public void init() throws Exception {
  ContextFactory contextFactory = ContextFactory.getInstance();
  serviceContext = contextFactory.newContext();
  RepositoryIdentity repositoryIdentity = new RepositoryIdentity();

  repositoryIdentity.setRepositoryName(repository);
  repositoryIdentity.setUserName(user);
  repositoryIdentity.setPassword(pass);
  serviceContext.addIdentity(repositoryIdentity);

  ServiceFactory serviceFactory = ServiceFactory.getInstance();
//ERROR is thrown here:
  objectService = serviceFactory.getRemoteService(IObjectService.class, serviceContext,  module, host);
  queryService = serviceFactory.getRemoteService(IQueryService.class, serviceContext,  module, host);
  }

I've seen a similar problem here: https://community.emc.com/thread/82798 but the solution provided there didn't help me. I tried

  • Changing JRE version to higher than 1.5
  • Making sure make sure that I am creating a class of type com.emc.documentum.fs.services.core.client.IObjectService (and not com.emc.documentum.fs.services.core.impl.IObjectService).
  • Trying with the more fully parameterized version of getRemoteService which will remove any ambiguties with the call.
  • And lots of other things, like installing all the external jars in a separate bundle and then importing them.

It looks like a maven dependency problem, but I can't figure it out, as I included all the .jars in my project which I used in my Eclipse project, so it should work the same, shouldn't it?

I appreciate any help.

EDIT: I tried changing export-packages to: info.hartmann.dfs.api, com.emc.documentum.* In other words, I tried exporting all the documentum packages. The above listed error dissapeared, but I got a new one:

Caused by: com.emc.documentum.fs.rt.impl.servicemodel.ServiceModelException: Service descriptor file not found: "services-core-service-model.xml".
at com.emc.documentum.fs.rt.impl.servicemodel.JavaBeanTreeFactory.getModuleByName(JavaBeanTreeFactory.java:65)
at com.emc.documentum.fs.rt.impl.servicemodel.JavaBeanTreeFactory.getModule(JavaBeanTreeFactory.java:42)
at com.emc.documentum.fs.rt.context.ServiceFactory.makeServiceUrl(ServiceFactory.java:332)
at com.emc.documentum.fs.rt.context.ServiceFactory.getRemoteService(ServiceFactory.java:143)
at com.emc.documentum.fs.rt.context.ServiceFactory.getRemoteService(ServiceFactory.java:197)
at info.hartmann.dfs.impl.Handler.init(Handler.java:112)

Unfortunatelly, I don't even know if it moves me one step further or one step behind.

1

There are 1 best solutions below

0
On

It looks like your user bundle is missing the wiring to com.emc.documentum.fs.services.core.client.ObjectServiceDescriptor. Just being in the classpath is not enough

Confirm that the JavaBeanTreeFactory bundle imports the package com.emc.documentum.fs.services.core.client