【问题标题】:How to compile a .war file to i-jetty (android web server)?如何将 .war 文件编译到 i-jetty(android 网络服务器)?
【发布时间】:2011-06-14 15:33:27
【问题描述】:

我想知道是否有人知道成功遵守的步骤 战争文件。我试图在 Eclipse 上作为战争出口,但每次都没有成功 当我尝试访问网络服务时,我收到了这条消息:错误 503,服务不可用。

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

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

感谢您的宝贵时间 最好的祝福 亚历山大

【问题讨论】:

  • 你能发布堆栈跟踪或类似的东西吗? iJetty 是否支持您的 web.xml 中指定的 servlet-api 版本?

标签: java android eclipse jetty ijetty


【解决方案1】:

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

另外,你看过this site吗?

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

希望对您有所帮助!

【讨论】:

    【解决方案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)上,您将面临部件问题。因此,您需要添加以下内容以启用正确执行(在关闭插件元素之后添加它,并在关闭构建元素之前添加它( <.> 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 :) 非常感谢你让我思考,从而引导我找到解决方案!

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

      • ~"在 webapp 文件夹中创建 xyz 文件夹,该文件夹位于您设备上的 jetty 文件夹中。"有没有办法在 i-jetty 应用程序中做到这一点?还是我必须在手机中添加 adb shell?
      【解决方案4】:

      我提供的步骤与我的申请相关 (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
      

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

      【讨论】:

      • 在撰写本文时,它还不支持 jsp。
      猜你喜欢
      • 2011-03-03
      • 2015-05-27
      • 1970-01-01
      • 2012-09-03
      • 2013-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多