drogatkin / Atjeews

Android wrapper for TJWS
24 stars 6 forks source link

Trouble with the Android web application tutorial for Atjeews #2

Open flipskills25 opened 9 years ago

flipskills25 commented 9 years ago

I followed the tutorial that was provided in Creation web application for Atjeews.docx, using the jasper.jar, and servlet.jar files located in the TJWS source from http://sourceforge.net/projects/tjws/files/, 1.112 Release for the bee-dexwar.xml.

I generate the .war file with the JSP's precompiled just fine, but when I deploy the war to my actual Android device (Samsung Galaxy Note 10.1 2014 Edition, running KitKat 4.4.2) to the /sdcard/atjeews/webapps location, start up Atjeews, and I try to access mycontacts, I get the error:

500 org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.mycontacts_jsp

Copied everything from the tutorial as is aside from the lines that I edited in the bee-dexwar.xml:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE bee PUBLIC "-//Dmitriy Rogatkin//DTD Bee Project Builder 1.0//EN"
    "http://knitknot.info/DTD/bee.dtd" [
      <!ENTITY android_sdk "C:\Users\[username]\AppData\Local\Android\sdk">
      <!ENTITY jasper_lib "C:\WebServer-1112\WebServer\lib\jasper.jar">
      <!ENTITY servlet_lib "C:\WebServer-1112\WebServer\lib\servlet.jar">
      <!ENTITY target "21.0.0">
]>
<!-- $Id: bee-dexwar.xml,v 1.13 2012/09/15 17:48:30 dmitriy Exp $ Prepare 
    war file for Android deployment Copyright (c) Dmitriy Rogatkin -->
<bee name="dexer" type="script">
    <variable name="dx path">&android_sdk;/build-tools/&target;/lib/dx.jar</variable>
drogatkin commented 9 years ago

Despite the fact it is used on Kitkat where restriction to use sdcard for writing app data applied, two things should be checked first:

  1. bee-dexwar.xml should be taken from Atjeews GitHub root (not from the tutorial).
  2. dexed version of .war file has to have the following structure --->META-INF

    ----------->jsp-classes

    ------------------------------>org

    ------------------------------------->apache.....jsp
    
    -------------------------------------------------------->jsp1_jsp.java
    
    -------------------------------------------------------->jsp1_jsp.class

    --->WEB-INF --------------------->lib ---------------------------->jsp-classes.jar

flipskills25 commented 9 years ago

Checked 1, and number 2 I had the following file structure:

mycontacts.war -->
   mycontacts.jsp
   WEB-INF -->
          web.xml
          lib -->
               jsp-classes.jar
   META-INF -->
               jsp-classes -->
                         org.apache.jsp -->
                                   mycontacts_jsp.java
                                   mycontacts_jsp.class

Deleted _mycontactsjsp.class from the folder to resemble the file structure you indicated, but now I'm getting a different error:

500 org.apache.jasper.JasperException: Unable to compile class for JSP

With the logs saying that the servlet could not serve /favicon.ico

drogatkin commented 9 years ago

.war file structure appears to be correct. .class file has to be in same directory as .java one. Can you check where is the application was deployed? The problem looks like class loader can't find classes . Could you clarify where exactly you got jasper.jar? Do you build Atjeews or use a version from Google play?

flipskills25 commented 9 years ago

Using adb, I used

adb push mycontacts.war sdcard/atjeews/webapps

and I verified its location. When I re-added the .class file back to the war, now it keeps switching between the original error and the Unable to compile class for JSP error.

The version of Atjeews is 1.1 from sourceforge.net/projects/twjs/files/Atjeews since that was the only version I was able to get the server loaded. Anything 1.2 and above, whenever I tried to start up the server, I would get a mac address up in the status bar and when i tried to just load the settings module, it wouldn't load.

When I tried to pull the GitHub source and deployed the application from Eclipse, I kept getting a NoClassDefFoundError at the initServ() method.

I used the jasper.jar that's located in the TJWS source from their lib directory

C:\WebServer-1112\WebServer\lib
drogatkin commented 9 years ago

The Atjeews 1.1 contains also webfolder.war. Can you try to deploy it as well and see if it works. Android restricts class loader to get classes only in own app directories starting from API level 11. Atjeews 1.1. doesn't aware of this new limitation and works on API level < 11. You can confirm that trying to access webfolder. If it gets stuck on first redirect page, then you encounter the problem, It was fixed for later versions of Atjeews. jasper is already included in Atjeews and you do not need to have it separately unless you build Atjeews from the source. In this case you need a version jasper which is Android tuned, you can get it from latest TJWS binary distributions (not as a separate one). The problem you observe with Atjeews > 1.1 is because for security reason it is bound to local interface, however URL to it does use a different address. You can try to access it using exact IP as shown in a title. The latest version of Atjeews should also have the bug corrected however it is available in Play store only. It is a free app anyway, and you can try it unless you are avoiding Playstore .

flipskills25 commented 9 years ago

You were correct. I was able to deploy the tutorial just fine using 1.5. I tried deploying the webfolder.war on 1.1 and I was getting the errors you described. Thank you for all your help and consideration with this issue!

iboxdb commented 3 years ago

Got the same exception. the Log said "TJWS is not owned by the current user. Shared storage cannot protect your application from code injection attacks" at DexFile.loadDex( DexFile ). should find a way to compile the WAR to APT directly, one WAR one APP.