0

我正在尝试开发一个简单的 Java 程序来调用 DFS Web 服务,但我得到了这个运行时错误:

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)

我正在使用maven构建一个项目并将其安装到Adob​​e CQ5 的 OSGi 容器中。我在 Eclipse 中的一个普通 Java 应用程序中尝试了相同的代码,它工作正常。

对我来说奇怪的是,这个类 ObjectServiceDescriptor 位于我通过 maven 依赖项包含的 .jar 库之一中。jar 名称是emc-dfs-services-remote-1.0.jar。如果我打开 maven 生成的 .jar,我可以在那里看到emc-dfs-services-remote-1.0.jar

项目编译没有任何问题,但在运行时我在这一行得到错误:

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

我的 pom.xml 在下面。如您所见,我在 Imported-Packages 中将一些包声明为可选。如果我不这样做,我的包可以编译,但无法启动。将这些包声明为可选包会是问题吗?

<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>

安装到 OSGi 控制台后捆绑类路径:

    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

我的Java代码:

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);
  }

我在这里看到了类似的问题:https ://community.emc.com/thread/82798但那里提供的解决方案对我没有帮助。我试过了

  • 将 JRE 版本更改为高于 1.5
  • 确保我正在创建一个类型为 com.emc.documentum.fs.services.core.client.IObjectService 的类(而不是 com.emc.documentum.fs.services.core.impl.IObjectService)。
  • 尝试使用更完全参数化的 getRemoteService 版本,这将消除调用中的任何歧义。
  • 还有很多其他的事情,比如将所有外部 jar 安装在一个单独的包中,然后导入它们。

它看起来像一个 maven 依赖问题,但我无法弄清楚,因为我在我的项目中包含了我在 Eclipse 项目中使用的所有 .jar,所以它应该工作相同,不是吗?

我很感激任何帮助。

编辑:我尝试将导出包更改为:info.hartmann.dfs.api, com.emc.documentum.* 换句话说,我尝试导出所有文档包。上面列出的错误消失了,但我得到了一个新错误:

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)

不幸的是,我什至不知道它是让我更进一步还是落后一步。

4

1 回答 1

0

看起来您的用户捆绑包缺少到com.emc.documentum.fs.services.core.client.ObjectServiceDescriptor. 仅仅在类路径中是不够的

确认JavaBeanTreeFactory捆绑包导入包com.emc.documentum.fs.services.core.client

于 2013-09-12T17:46:26.317 回答