嵌入式tomcat服务器未运行

时间:2016-04-24 16:09:46

标签: java jsp tomcat

我正在使用Raspberry PI和Pi4J来控制一些继电器。我希望能够从Android应用程序控制这些继电器。为此,我在here中使用示例代码。这样做是为了启动一个嵌入式tomcat服务器和一个示例servlet。我认为这就是我需要将RestFUL方法从手机调用到我的覆盆子。我已经尝试过这段代码并且在我的Windows 10上运行得很好。 要在我的Raspberry上部署应用程序,我修改了pom.xml以打包Jar并将其发送到我的覆盆子PI。

当我在netbeans上运行它时,我能够编译它并将其部署在我的Raspberry PI上。但是,当我打开浏览器时,导航到http://localhost:8080时出现404错误。这是一个tomcat服务器错误页面告诉我tomcat服务器以某种方式运行,但我没有看到" hellow haroku"消息,因为它应该。

你认为有什么不对?为什么它在我的Windows PC上而不是在我的树莓上工作?

这是修改后的pom.xml文件,用于打包jar并将其发送到我的raspberry PI

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.heroku.sample</groupId>
  <artifactId>embeddedTomcatSample</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>embeddedTomcatSample Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <tomcat.version>8.0.28</tomcat.version>
    <!-- DEFAULT RASPBERRY PI PROPERTIES -->
    <pi.host>192.168.1.122</pi.host>
    <pi.port>22</pi.port>
    <pi.user>pi</pi.user>
    <pi.password>mypassword</pi.password>
    <pi.deployDirectory>/home/pi/doorSYS</pi.deployDirectory>
    <pi.main.class>launch.Main</pi.main.class>
  </properties>

  <dependencies>
      <dependency>
        <groupId>com.pi4j</groupId>
        <artifactId>pi4j-core</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>${tomcat.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-logging-juli</artifactId>
        <version>${tomcat.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <version>${tomcat.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper</artifactId>
        <version>${tomcat.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper-el</artifactId>
        <version>${tomcat.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jsp-api</artifactId>
        <version>${tomcat.version}</version>
    </dependency>
  </dependencies>

  <build>
    <finalName>embeddedTomcatSample</finalName>

    <plugins>

        <!-- This plugin will generate JAR MANIFEST file inside the JAR in order to make our applicationeasily runnable -->
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>${pi.main.class}</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-my-jar-with-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

     <!--This plugin will Transfer the executable JAR file to the Pi and runs it -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <!-- ensure the target directory exists on the Raspberry Pi -->
                            <sshexec host="${pi.host}" port="${pi.port}" username="${pi.user}" password="${pi.password}" 
                                     trust="true" failonerror="false" verbose="true" 
                                     command="mkdir --parents ${pi.deployDirectory}"/>

                            <!-- copy the JAR file to the Raspberry Pi -->
                            <scp
                                file="${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar"
                                todir="${pi.user}:${pi.password}@${pi.host}:${pi.deployDirectory}"
                                port="${pi.port}" trust="true" verbose="true" failonerror="true">
                            </scp> 

                            <!-- run the JAR file on the Raspberry Pi -->
                            <sshexec host="${pi.host}" port="${pi.port}" username="${pi.user}"
                                     password="${pi.password}" trust="true" failonerror="false"
                                     verbose="true" 
                                     command="java -jar ${pi.deployDirectory}/${project.build.finalName}-jar-with-dependencies.jar"/>
                        </tasks>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-jsch</artifactId>
                    <version>1.9.6</version>
                </dependency>
            </dependencies>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <version>1.1.1</version>
            <configuration>
                <assembleDirectory>target</assembleDirectory>
                <programs>
                    <program>
                        <mainClass>launch.Main</mainClass>
                        <name>webapp</name>
                    </program>
                </programs>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>assemble</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
  </build>

</project>

这些是java -jar embeddedtomcat.jar

的输出
  

应用程序解析了根文件夹:/ home / pi / doorSYS禁用TLD   使用basedir扫描配置应用程序:   / tmp / default-doc-base5315596104031704189 2016年4月24日下午6:04:10   org.apache.coyote.AbstractProtocol init INFO:正在初始化   ProtocolHandler [&#34; http-nio-8080&#34;] 2016年4月24日下午6:04:10   org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO:   使用共享选择器进行servlet写入/读取2016年4月24日下午6:04:10   org.apache.catalina.core.StandardService startInternal INFO:正在启动   服务Tomcat 2016年4月24日下午6:04:10   org.apache.catalina.core.StandardEngine startInternal INFO:正在启动   Servlet引擎:Apache Tomcat / 8.0.28 2016年4月24日下午6:04:11   org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment   信息:找不到全球web.xml 2016年4月24日下午6:04:13   org.apache.coyote.AbstractProtocol start INFO:Starting   ProtocolHandler [&#34; http-nio-8080&#34;]

那是我得到的错误页面

enter image description here

0 个答案:

没有答案