My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DownloadableWebapps  
How to create downloadable webapps.
Featured
Updated Aug 22, 2011 by jan.bar...@gmail.com

Creating Downloadable Web Applications

Making a webapp that is dynamically downloadable by i-jetty is very much like making a normal webapp. The only tricky step is that you need to run the dx tool over the classes that would normally be in WEB-INF/classes and the jars that would normally be in WEB-INF/lib.

You can see examples of how we do that with maven in the Console web application and the Hello World web application.

We do three things specially for Android:

  1. we unpack the classes/resources out of all of the dependency jars of the webapp
  2. we run the dx tool over the webapp's own classes and all of the classes from the dependency jars
  3. we zip up the classes.dex output from dx and put it into the webapp's WEB-INF/lib directory

Unpacking the dependencies

       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.3</version>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
              <excludeArtifactIds>servlet-api,android</excludeArtifactIds>
              <excludeTransitive>true</excludeTransitive>
              <outputDirectory>${project.build.directory}/generated-classes</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

Using dx

We hook the dx tool into the build of the webapp at the process-classes phase of the maven build lifecycle:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>
          <!-- Convert the compiled classes into a clases.dex. -->
          <execution>
            <id>generate-dex</id>
            <phase>process-classes</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>java</executable>
              <arguments>
                <argument>-jar</argument>
                <argument>${env.ANDROID_HOME}/platform-tools/lib/dx.jar</argument>
                <argument>--dex</argument>
                <argument>--verbose</argument>
                <argument>--core-library</argument>
                <argument>--output=${project.build.directory}/classes.dex</argument>
                <argument>--positions=lines</argument>
                <argument>${project.build.directory}/classes/</argument>
                <argument>${project.build.directory}/generated-classes/</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>

Zipping the classes.dex file

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <id>copydex</id>
            <phase>process-classes</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <mkdir
                  dir="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib" />
                <jar
                  basedir="${project.build.directory}"
                  update="true"
                  includes="classes.dex"
                  destfile="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib/classes.zip" />
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>

Using i-jetty to Download a WebApp

NOTE: Android SDK 1.5 and above is needed to support dynamic webapps.

After you've prepared your web app - you might like to read the section below on Sample Webapps for some hints - you need to download it to the phone.

First, you'll need to arrange for the webapp to be served from a http:// url. The easiest way to do this is to serve it from a Jetty installation on your desktop machine. The Jetty site has full instructions on how to download and install it.

Once you've got Jetty installed - and lets assume you installed it to $JETTY_HOME - make a directory called $JETTY_HOME/webapps/downloads. Now copy your android-ready war file to that directory. Start Jetty. Your webapp will now be available as a downloadable file from the url http://[your host ip]/downloads/[your webapp name]. So for example, if your host ip address is 10.10.1.10 and you build a webapp called myfirstwebapp.war, then it is downloadable from http://10.10.1.10/downloads/myfirstwebapp.war.

Now, go to your phone or emulator and start i-jetty if its not already running. Select the Download button and type in the url of your webapp. Then enter the context path at which you want that webapp available. For example, you might want to access it as "/howcoolami".

i-jetty will now download your webapp and install it to the phone.

At the time of writing, you will need to restart i-jetty to get it to deploy your new webapp, although we are working on providing a hot deploy capability.

Sample WebApps

The i-jetty project comes with a couple of example webapps that you can build, and then dynamically download with i-jetty to get you going with the concept of dynamic webapps in the android environment.

Hello World Example

The "HelloWorld" web application in $I_JETTY_HOME/example-webapps/hello prints out the famous "Hello World" message. The web app contains one very simple Servlet as an example of how to prepare a web app that has classes in addition to static content.

The pom.xml for HelloWorld does a couple of things to make the webapp android-ifiable (if I can invent that word):

  • runs the dx tool over all the java classes in the webapp to produce a classes.dex file
  • zips up the classes.dex output file from dx

That's all you need to do for a simple webapp that uses no libraries. For more complex webapps that use 3rd party libs, refer to the "Chat" webapp.

Chat Example

The "Chat" web application is a much more sophisticated beast than "HelloWorld". It uses 3rd party java libraries, such as the Jetty implementation of the cometd Bayeux protocol, along with the dojox.cometd javascript library to implement the now-classic Ajax chat room.

Again, this is essentially a straight-forward webapp, with the only added complication that the 3rd party jars need to be dex-ified. Looking at the pom.xml for the Chat application, you'll see that prior to the 2 steps outlined above in the HelloWorld app, the build first unpacks the classes from the dependency jars. Thus, during the dx step, all classes - both those of the webapp and those from the libraries it uses - are all compiled into the classes.dex and then classes.zip file.

Other Examples

HybridServerPages has a Sample application permanently running on http://www.hybridjava.com:8080/HJ_Sample/, which can be run under i-jetty on Android. It is downloadable via the web or via i-jetty's Download feature from http://www.hybridjava.com:8080/HJ.war.

Comment by xjh2...@gmail.com, Dec 5, 2009

I have download hello-2.1.war to i-jetty, could you tell me how to run this war?

Comment by prac...@gmail.com, Dec 14, 2009

in simple English, you need to 1. put hello-2.1.war on a server that your device can access via http://[your host]/[your-path]/hello-2.1.war 2. (double check) test if that server can be accessed from your device from web browser first (I even download it with desktop browser once) 3. from i-jerry main screen go to Download? --> URL? --> enter a URL tested in 2 (http://[your host]/[your-path]/hello-2.1.war) 4. Path? can be any simple name URL style name such as hellosample? (I guess) 5. Click Download? and it should show some "installation complete" kind of message

Comment by tnain...@gmail.com, Dec 17, 2009

I am trying to develop a webapp similar to hello world, my webapp works fine on Tomcat, now I want this app to be running on i-jetty server. I am not sure how to add pom.xml and other classes for that. Is there any tutorial for creating a web app for i-jetty.

Thanks

Comment by hbenlulu@gmail.com, Jan 13, 2010

How do I add a webapp that should be installed automatically with the iJetty installation (like the console application)?

Thanks

Comment by markwill...@gmail.com, Feb 26, 2010

How do i remove apps from i-jetty on android.

Thanks

Comment by williamp...@gmail.com, Mar 10, 2010

I have your answer hbenlulu,

As I wanted to do the same thing. So I figure it out:

first you need to change the pom.xml config file of i-jetty (from /ijetty/trunk/modules/i-jetty/pom.xml that it include in the i-jetty build the war file that you want.

here is a snapshot of pom.xml extra lines to include hello and chat webapp:

....

<dependency>
<groupId>org.mortbay.ijetty</groupId> <artifactId>console</artifactId> <type>war</type> <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mortbay.ijetty</groupId> <artifactId>hello</artifactId> <type>war</type> <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mortbay.ijetty</groupId> <artifactId>chat</artifactId> <type>war</type> <version>${project.version}</version>
</dependency>

.....

<configuration> <!-- <classifier>sources</classifier> -->

<failOnMissingClassifierArtifact>true</failOnMissingClassifierArtifact>
<excludeArtifactIds>android,console,hello,chat</excludeArtifactIds> <excludes>org/mortbay/log/Slf4jLog?.class,org/mortbay/xml/XmlParser?</excludes>
<outputDirectory>${project.build.directory}/generated-classes</outputDirectory>
</configuration>

....

<configuration>
<outputDirectory>${project.build.directory}/included-wars</outputDirectory> <overWriteReleases>true</overWriteReleases><!--was false --> <overWriteSnapshots>true</overWriteSnapshots><!--was false --> <overWriteIfNewer>true</overWriteIfNewer><!-- was true --> <excludeTransitive>true</excludeTransitive> <stripVersion>true</stripVersion> <includeArtifactIds>console,hello,chat</includeArtifactIds>
</configuration>

....

that will include your war files in your ijettysnapshot.apk

then you need to change the code of i-jetty Android application to deploy the other war file stored than console.

this code is in: ~/ijetty/trunk/modules/i-jetty/src/org/mortbay/ijetty/IJetty.java

add the following as for console (included here):

....

//unpack the console war, but don't make a context.xml for it //Must be deployed by webapp deployer to get the Android ContentResolver? //setting. File consoleWar = new File (webappsDir, "console"); if (update) {
Installer.deleteWebapp(consoleWar); Log.i("Jetty", "Cleaned console webapp for update");
}

boolean exists = consoleWar.exists(); String files = consoleWar.list(); if (!exists || files.length==0)
files==null
{
InputStream? is = this.getClassLoader().getResourceAsStream("console.war"); Installer.install(is, "/console", webappsDir, "console", false); Log.i("Jetty", "Loaded console webapp");
}
//unpack the hello war, but don't make a context.xml for it //Must be deployed by webapp deployer to get the Android ContentResolver? //setting. File helloWar = new File (webappsDir, "hello"); if (update) {
Installer.deleteWebapp(helloWar); Log.i("Jetty", "Cleaned hello webapp for update");
}
boolean exists_hello = helloWar.exists(); String files_hello = helloWar.list(); if (!exists_hello || files_hello.length==0)
files_hello==null
{
InputStream? is_hello = this.getClassLoader().getResourceAsStream("hello.war"); Installer.install(is_hello, "/hello", webappsDir, "hello", false); Log.i("Jetty", "Loaded hello webapp");
}
//unpack the chat war, but don't make a context.xml for it //Must be deployed by webapp deployer to get the Android ContentResolver? //setting. File chatWar = new File (webappsDir, "chat"); if (update) {
Installer.deleteWebapp(chatWar); Log.i("Jetty", "Cleaned chat webapp for update");
}
boolean exists_chat = chatWar.exists(); String files_chat = chatWar.list(); if (!exists_chat || files_chat.length==0)
files_chat==null
{
InputStream? is_chat = this.getClassLoader().getResourceAsStream("chat.war"); Installer.install(is_chat, "/chat", webappsDir, "chat", false); Log.i("Jetty", "Loaded chat webapp");
}

recompile et Voila!

just add you 2 ijetty .apk into your rootfs directory in system/app/ for real device or in the emulator

that's it!!!

Comment by eriksson...@gmail.com, Jul 13, 2010

I have an application since before that works fine. But when building for i-jetty I first got an error telling me it could not locate org.apache.log4j. I realized I forgot to dexify the 3rd party libs. So I added those lines in the pom.xml. But now it only says "SERVICE_UNAVAILABLE". Can SERVICE_UNAVAILABLE mean I got an exception somewhere ? How do I access the log-files, if there are any ?

Thanks

Comment by arvindma...@gmail.com, Jul 15, 2010

eriksson, If you run "adb logcat >log.txt" from command prompt, you would get the log created on Android emulator. It would have the information about the exception occured. Note that log.txt file would be created at the location from where you are running the command. Assuming that you are doing it on Windows platform. For other latform you can look for similar commands.

Thanks

Comment by arvindma...@gmail.com, Jul 15, 2010

Its driving me crazy. Not getting any information anywhere on i-jetty if it is possible to run JSP webapps. Googling it since last few days. Can someone please help in at least knowing if it is possible? Want to switch to something else to achieve the result because I am not able to resist the temptation of using JSP and at the same time not able to figure out if it is possible and how.

Please someone help. Thanks Arvind

Comment by project member jan.bar...@gmail.com, Jul 15, 2010

Arvindmaurya1978, I thought I already responded to you? You have to precompile your jsps. From your subsequent posting, it seems that the runtime jsp engine is still required, so you'll need to add in the jasper jars to the i-jetty build. Try adding in a dependency on org.mortbay.jetty.jsp-2.1-jetty.

Jan

Comment by falconed...@gmail.com, Jul 15, 2010

Hi!

I install i-jetty on my emulator and it's ok!

I don't understand how create a webapp compatible with i-jetty

"The only tricky step is that you need to run the dx tool over the classes that would normally be in WEB-INF/classes and the jars that would normally be in WEB-INF/lib."

How can I do that??? I have to use Maven?

Thanks

Comment by project member jan.bar...@gmail.com, Jul 15, 2010

Deborah,

Look at the source code, for the example web applications. Here's a link to browsing the svn repo: http://code.google.com/p/i-jetty/source/browse/#svn/trunk/webapps.

Jan

Comment by falconed...@gmail.com, Jul 16, 2010

Hi Jan,

thanks for your replay! I look the code, but is there an IDE or a plug-in for eclipse that generate automaticaly the structure project? I install Meven plug in for eclipse but I don't know if it's usefull.

Regards

Deborah

Comment by arvindma...@gmail.com, Jul 17, 2010

Hi Jan, Thanks for reply. I did tried earlier and tried again using pre-compiled JSPs. Here is how dependency section of my pom.xml looks however while starting jetty server, I am getting following in the log I/dalvikvm( 204): Failed resolving Lorg/apache/jasper/runtime/JspApplicationContextImpl?; interface 298 'Ljavax/servlet/jsp/JspApplicationContext?;'

W/dalvikvm( 204): Link of class 'Lorg/apache/jasper/runtime/JspApplicationContextImpl?;' failed

I/dalvikvm( 204): Could not find method org.apache.jasper.runtime.JspApplicationContextImpl?.removeJspApplicationContext, referenced from method org.apache.jasper.servlet.JspServlet?.destroy

W/dalvikvm( 204): VFY: unable to resolve static method 3506: Lorg/apache/jasper/runtime/JspApplicationContextImpl?;.removeJspApplicationContext (Ljavax/servlet/ServletContext?;)V

D/dalvikvm( 204): VFY: replacing opcode 0x71 at 0x0016

D/dalvikvm( 204): Making a copy of Lorg/apache/jasper/servlet/JspServlet?;.destroy code (120 bytes)

W/dalvikvm( 204): Unable to resolve superclass of Lorg/apache/jasper/runtime/JspFactoryImpl?; (302)

W/dalvikvm( 204): Link of class 'Lorg/apache/jasper/runtime/JspFactoryImpl?;' failed

E/dalvikvm( 204): Could not find class 'org.apache.jasper.runtime.JspFactoryImpl?', referenced from method org.apache.jasper.compiler.JspRuntimeContext?.<clinit>

W/dalvikvm( 204): VFY: unable to resolve new-instance 510 (Lorg/apache/jasper/runtime/JspFactoryImpl?;) in Lorg/apache/jasper/compiler/JspRuntimeContext?;

D/dalvikvm( 204): VFY: replacing opcode 0x22 at 0x0008

D/dalvikvm( 204): Making a copy of Lorg/apache/jasper/compiler/JspRuntimeContext?;.<clinit> code (526 bytes)

W/dalvikvm( 204): Exception Ljava/lang/NoClassDefFoundError?; thrown during Lorg/apache/jasper/compiler/JspRuntimeContext?;.<clinit>

W/Jetty ( 204): failed jsp: java.lang.ExceptionInInitializerError?

D/dalvikvm( 204): GC freed 6963 objects / 523704 bytes in 185ms

I/dalvikvm( 204): Failed resolving Lorg/apache/jasper/runtime/HttpJspBase?; interface 297 'Ljavax/servlet/jsp/HttpJspPage?;'

W/dalvikvm( 204): Link of class 'Lorg/apache/jasper/runtime/HttpJspBase?;' failed

I have verified in generated-classes folder for the existence of the classes being complained here. Also, looked at the class file and verified that method like removeJspApplicationContext does exit in the the class JspApplicationContextImpl?. Not sure then why it is complaining. Please let me know if doing something wrong. Appreciate your help.

<dependencies>
<dependency>
<groupId>android</groupId> <artifactId>android</artifactId>
</dependency> <dependency>
<groupId>org.mortbay.ijetty</groupId> <artifactId>i-jetty-server</artifactId> <version>${project.version}</version> <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId> <artifactId>jsp-2.1</artifactId> <version>6.1.5</version> <scope>provided</scope> <exclusions>
<exclusion> <groupId>org.mortbay.jetty</groupId> <artifactId>jsp-api-2.1</artifactId>
</exclusion> <exclusion>
<groupId>org.mortbay.jetty</groupId> <artifactId>start</artifactId>
</exclusion> <exclusion>
<groupId>org.mortbay.jetty</groupId> <artifactId>jetty-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Comment by lulubao...@gmail.com, Jul 20, 2010

A question drives me crazy: In my webapp I want to use a third party dependency, which need to load a properties file. the code such as loadProperties("/xxx.properties"); I don't know where to put the file. It seems the generated classes.dex file cannot find the file in my dependency jar file. What the path of properties file should I set in loadProperties method? Hope someone can help!!!Please!!!

Comment by falconed...@gmail.com, Aug 4, 2010

Hi lulubaobao, in my webapp i have to load a file. When maven create a .war file don't include the file that I want to load, so I add manually this file to .war file generated by maven. Then I read the file simply in the following way:

String fileName = "mnt/sdcard/jetty/webapps/<webapp_name>/<file_name>";

BufferedReader br = new BufferedReader(new FileReader(fileName));

I hope it helps :)

deborah

Comment by arvindma...@gmail.com, Aug 12, 2010

Hi, I have a query. Can I access console app from multiple machines simulatenously?

Thanks Arvind

Comment by falconed...@gmail.com, Sep 6, 2010

Hiiii!

After the Download of my webapp. I should to restart i-jetty to get it to deploy my new webapp,but when I restart i-jetty, i-jetty not start again! Have you any idea? Thanks

Comment by jfaen...@gmail.com, Nov 12, 2010

Hi everyone,

How do you debug the java part (i.e. HttpServlet?) of i-jetty webapps in Eclipse? I read through the comments and don't have a good idea how to approach this. Thanks so much!

Comment by kah...@gmail.com, Apr 20, 2011

First of all, thanks for the great work. I really like it.

After playing with i-jetty for a while, one thing that I wanted was a feature to install my webapps from the local file system of Android, so that I don't have to setup a web server externally.

After looking at the code, it turned out that it was not that difficult to do.

Here is the svn diff output (against revision 396) for the code changes that worked for me. With these changes, I can do something like the following to install my webapps.

  1. (From host os shell) adb push my_android_ready.war /sdcard/
  2. (From i-jetty console's download page) Enter URL file:///sdcard/my_android_ready.war
Index: i-jetty-ui/src/org/mortbay/ijetty/IJettyDownloader.java
===================================================================
--- i-jetty-ui/src/org/mortbay/ijetty/IJettyDownloader.java	(revision 396)
+++ i-jetty-ui/src/org/mortbay/ijetty/IJettyDownloader.java	(working copy)
@@ -18,6 +18,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.net.URI;
 
 import org.eclipse.jetty.io.Buffer;
 import org.eclipse.jetty.http.HttpStatus;
@@ -144,7 +145,13 @@
 
                         text = (EditText)findViewById(R.id.context_path);
                         String path = text.getText().toString();
-                        startDownload(url, path);
+                        if (url.startsWith("http:")) {
+                            startDownloadInstall(url, path);
+                        } else if (url.startsWith("file:")) {
+                            startInstall(url, path);
+                        } else {
+                            Log.e("Jetty", "Unknown url " + url);
+                        }
                     }
                 }
         );
@@ -221,10 +228,30 @@
     }
 
     /**
-     * Begin a download of a war file.
+     * Begin an install of a war file.
      * @param url
+     * @param path
      */
-    public void startDownload (final String url, final String path)
+    public void startInstall (final String url, final String path) {
+        try {
+            File warFile = new File(new URI(url));
+            if (!warFile.exists()) {
+                Log.e("Jetty", "File does not exist "+url);
+                return;
+            }
+            install(warFile, path);
+        } catch (Exception e) {
+            Log.e("Jetty", "Error installing file "+url, e);
+            return;
+        }
+    }
+
+    /**
+     * Begin a download and install of a war file.
+     * @param url
+     * @param path
+     */
+    public void startDownloadInstall (final String url, final String path)
     {
         final String war = getWarFileName (url);
         final File warFile = new File (tmpDir, war);
Comment by alessand...@gmail.com, May 3, 2011

Hi I have developed a simple webApp with Eclipse. I had run dx command on the .class and the output is on the /lib/classes.zip. Then I have generate the war file whit jar command. Finally I have download this webApp on i-jetty but don't work... Why??

Comment by kypria...@gmail.com, May 11, 2011

Hi all,

I have a couple of apps in the webapps directory of jetty on Android. One is called books the other picture. When I run the server I noticed that the 127.0.0.1:8080 does not give the default ijetty page but rather the books app page ... sometimes it won't even do that and it will tell me ERROR 404 Not Found No context on this server matched or handled by this request! If I include the full context path to the app (127.0.0.1:8080/books-2.2.SNAPSHOT.war/ it fails giving the service is unavailable. What is going on?

Thanks

Comment by aditya.a...@gmail.com, Sep 7, 2011

Hi ALL,

I am trying to download a simple webapplication on the i-jetty server. And I am getting some kind of class loading exception which i am not aware of. Any help would be highly appreciated.

Following are the key points :

I am using third party jar (apache commons fileupload and apache commons io). Third party jars are dex-ified Decompiled classes.dex and verified that dex'ed third party jars are present. I get the errors when the app is deployed on the server.

See below for my POM.xml and Stacktrace.

-----------------------------------------------POM.XML--------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <project

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>org.mortbay.ijetty</groupId> <artifactId>andwebap</artifactId> <name>I-Jetty :: Hello</name> <version>3.1-SNAPSHOT</version> <packaging>war</packaging> <url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty</groupId> <artifactId>servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>${android.version}</version> <scope>provided</scope>
</dependency>

<dependency>
<groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.0.1</version>
</dependency>
</dependencies>
<build>
<plugins> <plugin>
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions>
<execution>
<id>unpack-dependencies</id> <phase>generate-sources</phase> <goals>
<goal>unpack-dependencies</goal>
</goals> <configuration>
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> <excludeArtifactIds>android</excludeArtifactIds> <excludeTransitive>true</excludeTransitive> <outputDirectory>${project.build.directory}/generated-classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <configuration>
<source>1.5</source> <target>1.5</target> <verbose>false</verbose>
</configuration>
</plugin>

<!-- Convert the compiled classes into a clases.dex. -->
<plugin>
<groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1</version> <executions>
<execution>
<id>generate-dex</id> <phase>process-classes</phase> <goals>
<goal>exec</goal>
</goals> <configuration>
<!-- executable>${env.ANDROID_HOME}/platform-tools/dx</executable --> <executable>java</executable> <arguments>
<!-- <argument>-JXmx1024M</argument> -->
<argument>-jar</argument> <argument>${ANDROID_HOME}/platform-tools/lib/dx.jar</argument> <argument>--dex</argument> <argument>--verbose</argument> <argument>--core-library</argument> <argument>--output=${project.build.directory}/classes.dex</argument> <argument>--positions=lines</argument> <argument>${project.build.directory}/classes/</argument> <argument>${project.build.directory}/generated-classes/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin> <plugin>
<artifactId>maven-antrun-plugin</artifactId> <executions>
<execution>
<id>copydex</id> <phase>process-classes</phase> <goals>
<goal>run</goal>
</goals> <configuration>
<tasks>
<mkdir
dir="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib" />
<jar
basedir="${project.build.directory}" update="true" includes="classes.dex" destfile="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib/classes.zip" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> <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.1,)</versionRange> <goals>
<goal>unpack-dependencies</goal>
</goals>
</pluginExecutionFilter> <action>
<execute/>
</action>
</pluginExecution> <pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId> <artifactId>
exec-maven-plugin
</artifactId> <versionRange>[1.1,)</versionRange> <goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter> <action>
<execute/>
</action>
</pluginExecution> <pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId> <artifactId>
maven-antrun-plugin
</artifactId> <versionRange>[1.3,)</versionRange> <goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter> <action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<properties>
<android.version>1.6_r2</android.version> <jetty.version>7.5.0.RC0</jetty.version> <servlet.version>2.5-20081211</servlet.version>
</properties>
</project>

-------------------------------------LOG----------------------------------------------------------

9-07 16:39:08.279: INFO/dalvikvm(30351): DexOpt??: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlSerializer??;' 09-07 16:39:08.284: INFO/dalvikvm(30351): DexOpt??: not resolving ambiguous class 'Lorg/xmlpull/v1/XmlPullParser??;'

09-07 16:39:08.289: DEBUG/dalvikvm(30351): DexOpt??: load 345ms, verify 180ms, opt 5ms 09-07 16:39:08.299: DEBUG/CityIdContact??(20224): No CityID found
09-07 16:39:08.489: DEBUG/dalvikvm(29530): DexOpt??: --- END 'classes.zip' (success) --- 09-07 16:39:08.489: DEBUG/dalvikvm(29530): DEX prep '/sdcard/jetty/webapps/yesitis/WEB-INF/lib/classes.zip': unzip in 54ms, rewrite 897ms 09-07 16:39:08.494: INFO/Jetty(29530): NO JSP Support for {}, did not find {} 09-07 16:39:08.549: INFO/Jetty(29530): started {}
09-07 16:39:08.554: WARN/dalvikvm(29530): Class resolved by unexpected DEX: Lorg/mortbay/ijetty/hello/HelloWorld??;(0x47dd7958):0x13b9c8 ref Ljavax/servlet/http/HttpServlet?;? Ljavax/servlet/http/HttpServlet??;(0x47c2f248):0x130620
09-07 16:39:08.554: WARN/dalvikvm(29530): (Lorg/mortbay/ijetty/hello/HelloWorld??; had used a different Ljavax/servlet/http/HttpServlet??; during pre-verification) 09-07 16:39:08.554: WARN/dalvikvm(29530): Unable to resolve superclass of Lorg/mortbay/ijetty/hello/HelloWorld??; (280) 09-07 16:39:08.554: WARN/dalvikvm(29530): Link of class 'Lorg/mortbay/ijetty/hello/HelloWorld??;' failed 09-07 16:39:08.554: WARN/Jetty(29530): FAILED andwebap: java.lang.IllegalAccessError??: Class ref in pre-verified class resolved to unexpected implementation 09-07 16:39:08.554: WARN/Jetty(29530): FAILED o.e.j.w.WebAppContext??{/yesitis,file:/sdcard/jetty/webapps/yesitis/},/sdcard/jetty/webapps/yesitis: java.lang.IllegalAccessError??: Class ref in pre-verified class resolved to unexpected implementation 09-07 16:39:08.564: ERROR/Jetty(29530): EXCEPTION 09-07 16:39:08.564: ERROR/Jetty(29530): java.lang.IllegalAccessError??: Class ref in pre-verified class resolved to unexpected implementation 09-07 16:39:08.564: ERROR/Jetty(29530): at dalvik.system.DexFile??.defineClass(Native Method) 09-07 16:39:08.564: ERROR/Jetty(29530): at dalvik.system.DexFile??.loadClassBinaryName(DexFile??.java:209) 09-07 16:39:08.564: ERROR/Jetty(29530): at dalvik.system.DexFile??.loadClass(DexFile??.java:198) 09-07 16:39:08.564: ERROR/Jetty(29530): at dalvik.system.DexClassLoader??.findClass(DexClassLoader??.java:247) 09-07 16:39:08.564: ERROR/Jetty(29530): at java.lang.ClassLoader??.loadClass(ClassLoader??.java:573) 09-07 16:39:08.564: ERROR/Jetty(29530): at java.lang.ClassLoader??.loadClass(ClassLoader??.java:532) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.mortbay.ijetty.webapp.AndroidClassLoader??.loadClass(AndroidClassLoader??.java:268) 09-07 16:39:08.564: ERROR/Jetty(29530): at java.lang.ClassLoader??.loadClass(ClassLoader??.java:532) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.Loader.loadClass(Loader.java:92) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.Loader.loadClass(Loader.java:71) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:81) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.servlet.ServletHolder??.doStart(ServletHolder??.java:239) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.component.AbstractLifeCycle??.start(AbstractLifeCycle??.java:58) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.servlet.ServletHandler??.initialize(ServletHandler??.java:765) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.servlet.ServletContextHandler??.startContext(ServletContextHandler??.java:245) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.webapp.WebAppContext??.startContext(WebAppContext??.java:1209) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.server.handler.ContextHandler??.doStart(ContextHandler??.java:586)
09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.webapp.WebAppContext??.doStart(WebAppContext??.java:450)
09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.component.AbstractLifeCycle??.start(AbstractLifeCycle??.java:58) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.mortbay.ijetty.deployer.AndroidContextDeployer??.deploy(AndroidContextDeployer??.java:128) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.mortbay.ijetty.deployer.AndroidContextDeployer??$ScannerListener??.fileAdded(AndroidContextDeployer??.java:36) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:601) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.Scanner.scan(Scanner.java:394) 09-07 16:39:08.564: ERROR/Jetty(29530): at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:345) 09-07 16:39:08.564: ERROR/Jetty(29530): at java.util.Timer$TimerImpl??.run(Timer.java:290) 09-07 16:39:08.569: WARN/Jetty(29530): ContextDeployer??$Scanner failed on '/sdcard/jetty/contexts/yesitis.xml

Thanks, A

Comment by aditya.a...@gmail.com, Sep 8, 2011

The Core of my above question is that I am getting "illegal access error" because of some of my dependencies which I have used in my Web Application.

So after searching about it a little bit I found that I should change the scope of the dependencies to "provided" so that it doesn't get added to the WEB-INF folder.

That didnt work as well.

If anybody has a solution or thinks where I could be wrong , please help.

Comment by MichaelC...@gmail.com, Oct 5, 2011

Do I need to do anything special to run a javascript file and a flash file?

I have a program that converts powerpoint into a flash file. The program creates 3 files: a javascript file, an html file, and a flash file. However, when I try to launch it, it shows a little box with a question mark, like it can't run the flash file or something.

Do I need to package the javascript or flash file in some special way?

Thanks, Mike

Comment by project member jan.bar...@gmail.com, Oct 5, 2011

MichaelC,

The javascript should be fine. AFAIK, Flash is only supported by the android web browser from 2.2 onwards.

Jan

Comment by project member jan.bar...@gmail.com, Oct 5, 2011

Reminder to everyone that has a question:

please post it to the Jetty discussion group at:

user@jetty.codehaus.org

rather than add comments to this wiki page.

Thanks, Jan

Comment by suganmu...@gmail.com, Dec 22, 2011

Hi All,

I have deployed a web app in jetty server..while downloading from i-jetty i'm getting download failed with some status code..

can anyone help me to solve issue and tell me where i'm going wrong?

Thanks in advance..


Sign in to add a comment
Powered by Google Project Hosting