开发者

Error when deploying a web service: Missing Constraint: Import-Package: org.apache.axis2.databinding; version="0.0.0". How can I solve it?

开发者 https://www.devze.com 2023-02-15 22:57 出处:网络
i am struggling with CXF and pom files. I want to add a dependency to the axis2 to it, so I added this to my pom.

i am struggling with CXF and pom files. I want to add a dependency to the axis2 to it, so I added this to my pom.

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        开发者_StackOverflow中文版<version>1.5.2</version>
    </dependency>

It downloads the dependency correctly and everything seems to work. When I deploy, I get this message:

The bundle could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.axis2.databinding; version="0.0.0"

So I changed my plugin tag to add the org.apache.axis2.databinding reference:

<plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <configuration>
                <instructions>
                    <Bundle-Activator>de.innoshgs.iai.services.pruefentxschema_uas_01.Activator</Bundle-Activator>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Import-Package>
                        javax.jws,
                        javax.wsdl,
                        javax.xml.bind,
                        javax.xml.bind.annotation,
                        javax.xml.namespace,
                        javax.xml.soap,
                        javax.xml.transform,
                        javax.xml.ws,
                        javax.xml.ws.handler,
                        javax.xml.ws.handler.soap,
                        META-INF.cxf,
                        META-INF.cxf.osgi,
                        org.apache.cxf.bus,
                        org.apache.cxf.bus.spring,
                        org.apache.cxf.bus.resource,
                        org.apache.cxf.configuration.spring,
                        org.apache.cxf.feature,
                        org.apache.cxf.resource,
                        org.apache.cxf.transport.http_osgi,
                        org.apache.cxf.interceptor,
                        org.apache.servicemix.util,
                        org.springframework.beans.factory.config,
                        org.apache.camel.osgi,
                        org.apache.axis2.databinding,
                        sun.misc;resolution:=optional,
                        !de.innoshgs.iai.services.pruefentxschema_uas_01,
                        !de.innoshgs.iai.namespace,
                        *
        </Import-Package>
                    <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
                    <Private-Package>
                        de.innoshgs.iai.services.pruefentxschema_uas_01,
                        de.innoshgs.iai.namespace,
        </Private-Package>
                </instructions>
            </configuration>
        </plugin>

But I keep getting the same error. I am not a java dev, I am starting with it,so I am a lost with it. I have been searching and I could get som e hints until I got to this point, but now I seem to get stuck. What do I have to do, so maven is able to find this databinding reference?

The whole pom file is here:

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>org.apache.servicemix.examples</groupId>
    <artifactId>examples</artifactId>
    <version>4.2.0-fuse-01-00</version>
</parent>

<groupId>de.innoshgs.iai.Services</groupId>
<artifactId>PruefenTXSchema_UAS_01</artifactId>
<packaging>bundle</packaging>
<version>4.2.0-fuse-01-00</version>
<name>PruefenTXSchema_UAS_01</name>

<!-- Add fusesource repositories for snaphots and releases -->
<pluginRepositories>
    <pluginRepository>
        <id>fusesource.m2-snapshot</id>
        <name>FuseSource Snapshots Repository</name>
        <url>http://repo.fusesource.com/maven2-snapshot/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
    <pluginRepository>
        <id>fusesource.m2</id>
        <name>FuseSource Repository</name>
        <url>http://repo.fusesource.com/maven2/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>
<repositories>
    <repository>
        <id>fusesource.m2-snapshot</id>
        <name>FuseSource Snapshots Repository</name>
        <url>http://repo.fusesource.com/maven2-snapshot/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
    <repository>
        <id>fusesource.m2</id>
        <name>FuseSource Repository</name>
        <url>http://repo.fusesource.com/maven2/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>${commons.logging.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-ftp</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
        <version>${geronimo.wsmetadata.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.servicemix</groupId>
        <artifactId>servicemix-utils</artifactId>
        <version>${servicemix-utils.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-all</artifactId>
        <version>5.3.1-fuse-02-00</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-cxf</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.servicemix.kernel</groupId>
        <artifactId>org.apache.servicemix.kernel.main</artifactId>
        <version>1.1.0.1-fuse</version>
    </dependency>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.5.2</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${basedir}/src/main/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/resources/wsdl/PruefenTXSchema_UAS_01Service.wsdl</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <configuration>
                <instructions>
                    <Bundle-Activator>de.innoshgs.iai.services.pruefentxschema_uas_01.Activator</Bundle-Activator>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Import-Package>
                        javax.jws,
                        javax.wsdl,
                        javax.xml.bind,
                        javax.xml.bind.annotation,
                        javax.xml.namespace,
                        javax.xml.soap,
                        javax.xml.transform,
                        javax.xml.ws,
                        javax.xml.ws.handler,
                        javax.xml.ws.handler.soap,
                        META-INF.cxf,
                        META-INF.cxf.osgi,
                        org.apache.axis2.databinding,
                        org.apache.cxf.bus,
                        org.apache.cxf.bus.spring,
                        org.apache.cxf.bus.resource,
                        org.apache.cxf.configuration.spring,
                        org.apache.cxf.feature,
                        org.apache.cxf.resource,
                        org.apache.cxf.transport.http_osgi,
                        org.apache.cxf.interceptor,
                        org.apache.servicemix.util,
                        org.springframework.beans.factory.config,
                        org.apache.camel.osgi,
                        sun.misc;resolution:=optional,
                        !de.innoshgs.iai.services.pruefentxschema_uas_01,
                        !de.innoshgs.iai.namespace,
                        *
        </Import-Package>
                    <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
                    <Private-Package>
                        de.innoshgs.iai.services.pruefentxschema_uas_01,
                        de.innoshgs.iai.namespace,
        </Private-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

Thanks a lot, Oscar

Edit: just to make it clear: the server and the computer I am using to develop are different machines.


Can you try adding axis2-adb dependency and see if the error persists?

<dependency>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-adb</artifactId>
    <version>1.5.2</version>
</dependency>


The issue seems to be that the dependency you want to add to your project does not exist in the server. You need your JAR to provide the dependency on the server. Try adding:

<Embed-Dependency>axis2</Embed-Dependency>

after the Import-Package element of your maven bundle plugin configuration. This will embed the axis2 jar into your compiled jar, expose it and allow it to be called within the server. Further reading about the embed dependency can be found at Apache Felix - Embedding Dependencies although I will admit it is not all that helpful to know when/why to use it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号