我正在尝试将Apache Camel与IBM MQ连接,但我收到maven插件的一个错误

时间:2014-04-18 06:18:34

标签: maven apache-camel ibm-mq

我使用下面定义的camel上下文将消息从activemq路由到ibmmq,我使用jms服务将消息从一个队列发送到另一个队列......

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
   p:staticMethod="com.ibm.mq.MQEnvironment.addConnectionPoolToken"/>

<camel:camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <camel:route>
        <camel:from uri="activemq:queue:TestAMQ1"/>  
        <camel:to uri="websphere-mq:TestWMQ"/>
    </camel:route>
</camel:camelContext>

<bean id="wasmq" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory">
        <bean  class="com.ibm.mq.jms.MQQueueConnectionFactory">
            <property name="transportType">
                <util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP" />
            </property>
            <property name="hostName" value="10.0.0.1" />
            <property name="port" value="1414" />
            <property name="queueManager" value="Sample_QM" />
            <property name="channel" value="SYSTEM.DEF.SVRCONN" />
            <property name="useConnectionPooling" value="true" />
        </bean>   
    </property>
</bean>

我的pom.xml包含以下ibm dependecies ...

<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>com.java.amq</groupId>
    <artifactId>mq</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>javamq</name>
    <description>amq</description>

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

    <dependencies>
        <dependency>
            <groupId>org.glassfish.main.javaee-api</groupId>
            <artifactId>javax.jms</artifactId>
            <version>3.1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>2.13.0</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>com.ibm.mq</artifactId>
            <version>7.0.1.3</version>
        </dependency>       
        <dependency>
            <groupId>com.ibm.mq</groupId>
            <artifactId>com.ibm.mqjms</artifactId>
            <version>7.0.1.3</version>
        </dependency>   
        <dependency>
            <groupId>com.ibm.dhbcore</groupId>
            <artifactId>com.ibm.dhbcore</artifactId>
            <version>DH610-GOLD</version>
        </dependency>
        <dependency> 
            <groupId>org.apache.camel</groupId> 
            <artifactId>camel-jms</artifactId> 
            <version>2.5.0</version> 
        </dependency> 
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-maven-plugin</artifactId>
            <version>2.13.0</version>
        </dependency>         
    </dependencies>  

    <build>
        <defaultGoal>install</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是我在运行驼峰上下文时遇到的错误....

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.045s
[INFO] Finished at: Fri Apr 18 11:32:52 IST 2014
[INFO] Final Memory: 16M/40M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project mq: Compilation failure

请帮助解决此问题....提前致谢....

当我使用mvn camel运行时出现错误:运行-e switch.I我得到以下错误列表...

[ERROR] No plugin found for prefix 'mvn' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\rahul\.m2\repository), release.fusesource.org (http://repo.fusesource.com/nexus/content/repositories/releases), snapshot.fusesource.org (http://repo.fusesource.com/nexus/content/repositories/snapshots), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix 'mvn' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\rahul\.m2\repository), release.fusesource.org (http://repo.fusesource.com/nexus/content/repositories/releases), snapshot.fusesource.org (http://repo.fusesource.com/nexus/content/repositories/snapshots), central (http://repo.maven.apache.org/maven2)]
    at org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver.resolve(DefaultPluginPrefixResolver.java:94)
    at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.findPluginForPrefix(MojoDescriptorCreator.java:262)
    at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:222)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:106)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:86)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:98)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

3 个答案:

答案 0 :(得分:0)

这是构建失败,您的代码未编译。 你是否拥有所有必要的依赖项,你没有在列表中提到过camel-core依赖项。

尝试使用-e选项运行maven构建,它可能会提供更有用的错误消息。

答案 1 :(得分:0)

您应确保为所有Camel依赖项使用相同版本的Camel。您使用Camel 2.13.0和2.5.0的混合。例如改变这个

    <dependency> 
        <groupId>org.apache.camel</groupId> 
        <artifactId>camel-jms</artifactId> 
        <version>2.5.0</version> 
    </dependency> 

    <dependency> 
        <groupId>org.apache.camel</groupId> 
        <artifactId>camel-jms</artifactId> 
        <version>2.13.0</version> 
    </dependency> 

你也可以删除那个不需要的glassfish JMS jar(因为camel-jms将api作为传递依赖包含在内)

    <dependency>
        <groupId>org.glassfish.main.javaee-api</groupId>
        <artifactId>javax.jms</artifactId>
        <version>3.1.2.2</version>
    </dependency>

答案 2 :(得分:0)

正如我所尝试的那样,IBM MQ不允许下载其依赖项。以下依赖项不起作用:

    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>com.ibm.mq</artifactId>
        <version>7.0.1.3</version>
    </dependency>       
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>com.ibm.mqjms</artifactId>
        <version>7.0.1.3</version>
    </dependency>   
    <dependency>
        <groupId>com.ibm.dhbcore</groupId>
        <artifactId>com.ibm.dhbcore</artifactId>
        <version>DH610-GOLD</version>
    </dependency>

对于那些您需要创建本地存储库的人。您将从IBM MQ安装文件夹{C:\Program Files (x86)\IBM\WebSphere MQ\java\lib}获取所有这些jar。创建自定义本地存储库并在其中添加jar。或者只是将这些罐子包含在库中。

希望这会奏效。 :)它对我有用。