2

Mac (OS-X Mountain Lion) で問題なくコンパイルできる Java プロジェクトがあります。Ubuntu マシンで同じプロジェクトをコンパイルしようとすると失敗します。

基本的に、クラスが見つからないと不平を言っています。ただし、クラスは Maven クラスパスに存在します。スイッチで実行mvnした後、それを確認しました。-X

(see     612 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-twitter/2.11.0/camel-twitter-2.11.0.jar ) below. 

$HOME/.m2 リポジトリを削除して、すべてを再度ダウンロードするようにしました。しかし、それでも失敗します。

ここで何が欠けているのか分かりますか?

これがUbuntuの私の環境です。

mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_32, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/jdk1.6.0_32/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-40-generic", arch: "amd64", family: "unix"

ありがとう。

更新 (Java クラスにインポートを追加) Java クラス (src/main/java/...) にインポート

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.twitter.TwitterComponent;
import org.apache.camel.component.websocket.WebsocketComponent;

ここにスタックトレースがあります。

629 [ERROR] /tmp/jettycamelwebsocket/src/main/java/demo/websocket/TwitterStreamRoute.java:[27,55] incompatible types
630 [ERROR] found   : org.apache.camel.Component
631 [ERROR] required: org.apache.camel.component.twitter.TwitterComponent
632 [ERROR]
633 [ERROR] /tmp/jettycamelwebsocket/src/main/java/demo/websocket/TwitterStreamRoute.java:[33,8] fromF(java.lang.String,java.lang.Object...    ) in org.apache.camel.builder.RouteBuilder cannot be applied to (java.lang.String,java.lang.String,java.lang.String)
634 [ERROR] -> [Help 1]
635 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:com    pile (default-compile) on project jettycamelwebsocket: Compilation failure
636         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
637         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
638         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
639         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
640         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
641         at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
642         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
643         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
644         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
645         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
646         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
647         at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
648         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
649         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
650         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
651         at java.lang.reflect.Method.invoke(Method.java:597)
652         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
653         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
654         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
655         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
656 Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
657         at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
658         at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
659         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
660         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
661         ... 19 more

クラスパスを示す出力を次に示します。

$mvn -X clean install 


583 [DEBUG] Output directory: /tmp/jettycamelwebsocket/target/classes
584 [DEBUG] Classpath:
585 [DEBUG]  /tmp/jettycamelwebsocket/target/classes
586 [DEBUG]  /home/c/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar
587 [DEBUG]  /home/c/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar
588 [DEBUG]  /home/c/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
589 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-core/3.2.2.RELEASE/spring-core-3.2.2.RELEASE.jar
590 [DEBUG]  /home/c/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
591 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-web/3.2.2.RELEASE/spring-web-3.2.2.RELEASE.jar
592 [DEBUG]  /home/c/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
593 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-aop/3.2.2.RELEASE/spring-aop-3.2.2.RELEASE.jar
594 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-beans/3.2.2.RELEASE/spring-beans-3.2.2.RELEASE.jar
595 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-context/3.2.2.RELEASE/spring-context-3.2.2.RELEASE.jar
596 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-webmvc/3.2.2.RELEASE/spring-webmvc-3.2.2.RELEASE.jar
597 [DEBUG]  /home/c/.m2/repository/org/springframework/spring-expression/3.2.2.RELEASE/spring-expression-3.2.2.RELEASE.jar
598 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-spring/2.11.0/camel-spring-2.11.0.jar
599 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-server/8.1.3.v20120416/jetty-server-8.1.3.v20120416.jar
600 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar
601 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-continuation/8.1.3.v20120416/jetty-continuation-8.1.3.v20120416.jar
602 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-servlet/8.1.3.v20120416/jetty-servlet-8.1.3.v20120416.jar
603 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-security/8.1.3.v20120416/jetty-security-8.1.3.v20120416.jar
604 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-servlets/8.1.3.v20120416/jetty-servlets-8.1.3.v20120416.jar
605 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-client/8.1.3.v20120416/jetty-client-8.1.3.v20120416.jar
606 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-util/8.1.3.v20120416/jetty-util-8.1.3.v20120416.jar
607 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-webapp/8.1.3.v20120416/jetty-webapp-8.1.3.v20120416.jar
608 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-xml/8.1.3.v20120416/jetty-xml-8.1.3.v20120416.jar
609 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-http/8.1.3.v20120416/jetty-http-8.1.3.v20120416.jar
610 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-io/8.1.3.v20120416/jetty-io-8.1.3.v20120416.jar
611 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-core/2.11.0/camel-core-2.11.0.jar
612 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-twitter/2.11.0/camel-twitter-2.11.0.jar
613 [DEBUG]  /home/c/.m2/repository/org/twitter4j/twitter4j-core/3.0.3/twitter4j-core-3.0.3.jar
614 [DEBUG]  /home/c/.m2/repository/org/twitter4j/twitter4j-stream/3.0.3/twitter4j-stream-3.0.3.jar
615 [DEBUG]  /home/c/.m2/repository/org/apache/camel/camel-websocket/2.11.0/camel-websocket-2.11.0.jar
616 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-websocket/7.6.8.v20121106/jetty-websocket-7.6.8.v20121106.jar
617 [DEBUG]  /home/c/.m2/repository/org/eclipse/jetty/jetty-jmx/7.6.8.v20121106/jetty-jmx-7.6.8.v20121106.jar
4

1 に答える 1

2

私はそれを考え出した。このプラグインを pom.xml のプラグインに追加する必要がありました。ただし、UbuntuではなくOS-Xで動作する理由はまだわかりません。

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.3.2</version>
                        <configuration>
                                <source>1.6</source>
                                <target>1.6</target>
                        </configuration>
                </plugin>
于 2013-05-06T17:48:34.450 に答える