2

我想知道是否有人知道成功编译战争文件的步骤。我尝试在 Eclipse 上导出为战争,但每次尝试访问 Web 服务时都没有成功,我收到此消息:错误 503,服务不可用。

我什至尝试编译 hello servlet 示例,并将其加载到 i-jetty 后,我收到错误 503,据我了解,eclipse 战争导出器不适用于 i-jetty,请更好地查看 chat-2.2。我也注意到一些奇怪的文件,比如 WEB-INF 上的 classes.zip 和 META-INF 上的一个带有一些 ijetty 库的 maven 文件夹。

回到开头,我想知道为 i-jetty 编译成功的战争文件的步骤是什么?

谢谢你的时间最好的问候亚历山大

4

4 回答 4

2

我得到了你的问题的解决方案。请按照以下步骤操作

1)首先在您的设备上安装ijetty,然后在 sdcard 上创建 jetty 文件夹。
2) 在 webapp 文件夹中创建 xyz 文件夹,该文件夹位于您设备上的 jetty 文件夹中。
3) 复制您的 hello.war 文件并粘贴到 xyz 文件夹
4) 单击 Edittext 中输入路径中的下载选项卡,例如 localhost:port number/xyz
6) 端口号取决于您在 ijetty 服务器中使用的端口号。
6) 上下文名称必须以 / 开头,你可以给 /hello 之类的任何名称

于 2013-09-04T13:01:18.707 回答
2

如果你知道如何做到这一点,你能告诉我吗?(实际工作方法)

我找到了一种解决方法,只需获取 classes.zip 文件并手动将其放置在 jetty/webapps/console/WEB-INF/lib 文件夹中。这是因为我认为 Nick 的链接中提到的“压缩 classes.dex 文件”不起作用,因为我在应用程序的任何地方都找不到 classes.zip 文件。

所以在自己复制之后,我的错误 503 消息消失了,webapp 部署成功。但是,我对这个解决方案不太满意,因为让想要从 Playstore 安装我的应用程序的人访问网站,下载 classes.zip 文件并将其复制到正确的文件夹中是不可行的。

编辑:

哈哈哈!我刚写下这个答案,我就知道如何正确创建 classes.zip 文件(从应用程序中部署 webapp 现在可以工作了!)。

所以基本上正如 i-jetty 官方网站所说,你需要在你的 pom.xml 中包含 3 件事,在网站https://code.google.com/p/i-jetty/wiki/DownloadableWebapps监听。现在,仅包含这三个您将面临的问题是,在较新的 Android 版本(android-maven-plugin)上,您将面临部件问题。因此,您需要添加以下内容以启用正确执行(在关闭插件元素之后添加它,并在关闭构建元素之前添加它( <./plugin> ADD IT HERE <./build> ,不带点):

<pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <versionRange>[2.0,)</versionRange>
                    <goals>
                      <goal>copy-dependencies</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
</pluginManagement>

现在,当您运行 maven 构建时,您将在 your_application/target/res-overlay/raw 文件夹中生成所需的 your_webapp.war 文件。将 your_webapp.war 文件复制到 your_application/res/raw 文件夹中。现在再次运行 Maven 构建。你有它!!现在可以正确构建 webapp 了 :) 非常感谢让我思考并引导我找到解决方案!

于 2013-08-25T05:03:53.260 回答
2

我尝试这样做,但也遇到了各种障碍。但我最终还是让它运行起来了。不过,我没有将它直接部署到服务器上,这可能是您的问题。您是否尝试过制作 .war 文件并从 i-Jetty 应用程序手动下载它?因此,不要“部署”,而是尝试“打包”来实现您的目标。

另外,你看过这个网站吗?

您会看到 classes.zip 文件,因为作为编译的一部分,它必须将 Java 字节码转换为 Dalvik VM 读取的格式。它使用 dx 工具在 maven 脚本中自动执行此操作。这包含您通常会在 .dex 文件中找到的内容。

希望这有帮助!

于 2011-09-26T16:40:48.333 回答
0

我提供的步骤与我的应用程序(Like4Wifi)相关。首先,了解您不能运行 JSP 页面,而只能运行 servlet。
为了获得一个工作示例,请下载上面提供的源代码并按照以下步骤操作:

1). Create your war file and extract it. In this case, the Like4Wifi.war
2). Get the whole 'com' folder/package from 'classes' folder
3). dx the whole 'com' folder (./dx --dex  --output=com/facebook/like4wifi/Like4Wifi.dex com/facebook/like4wifi/Like4Wifi.class)
4). Remove original .class file
5). Rename .dex file to .class
6a). Create 'classes.zip' at 'WEB-INF/lib' folder
6b). The content of 'classes.zip' is 'META-INF' folder and its contents and also classes.dex (not the       app_name.dex and without the folder/package tree)
7). Move 'classes.zip' to 'lib' folder.
9). Copy the 'Like4Wifi' folder into 'webapps' folder to the mobile.
10). Copy the other jetty libraries from WEB-INF/lib from the console folder at mobile - VOLUNTARILY

请将此应用程序作为示例,不要将其与人作对!

于 2016-03-17T11:03:44.063 回答