Topic
11 replies Latest Post - ‏2011-12-14T12:20:56Z by BEPJ_ran_zou
CliffLau
CliffLau
4 Posts
ACCEPTED ANSWER

Pinned topic Issue with uploading pictures using mysurance.apk application

‏2011-12-09T17:30:33Z |
I have a real Motorola Xoom Wi-Fi where I've loaded the mysurance application. The server component is loaded on my Windows 7 64 bit server. I am able to update the server address within the mysurance profile so I know that I have connectivity to the server. Is there some other configuration that needed to be done to get this sample to work properly? All of the other features work as expected (location data, activating camera, etc).

However, when I attempt to upload pictures from the Xoom to the server, I immediately get a popup error window on the Xoom that says "Alert Error uploading photo: object Object"

The only recourse is to click on the OK button.

I have reviewed the source code for the APK and it's using step12.html as the local application on the Xoom. I've already reviewed the trace file on the server side and there is no indication of anything executing on the server. The only indication of issues occurs when I start up the Liberty profile... the startup output is pasted below.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/MobileDemo/MobileTechPreview-android-20111
031-1421/server/was4d/usr/servers/defaultServer/workarea/org.eclipse.osgi/bundle
s/32/data/com.ibm.ws.app.manager_gen_5ab4634b-0e88-49e8-9fcd-6463173ba1bb/WEB-IN
F/lib/slf4j-jdk14-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://66.fwk1355829456:1/org/slf4j/impl/Stat
icLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

ERROR findAAPT: Could not find aapt
WARNING DSRA8020E: Warning: The property 'supportExtensions' does not exist on the DataSource class jdbc/Mobile.
WARNING DSRA8200W: DataSource Configuration: DSRA8020E: Warning: The property 'id' does not exist on the DataSource class org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40.
Updated on 2011-12-14T12:20:56Z at 2011-12-14T12:20:56Z by BEPJ_ran_zou
  • SystemAdmin
    SystemAdmin
    59 Posts
    ACCEPTED ANSWER

    Re: Issue with uploading pictures using mysurance.apk application

    ‏2011-12-09T21:33:45Z  in response to CliffLau
    Cliff, I just hit a bug (I think) on the server update portion of this. From what I can tell the server address is never really validated. I have posted a question around this on a separate thread. I am also hitting the same error you are, so I assume we are having similar issues. Hopefully someone more knowledgeble than I can jump in help out. thanks!
    • SystemAdmin
      SystemAdmin
      59 Posts
      ACCEPTED ANSWER

      Re: Issue with uploading pictures using mysurance.apk application

      ‏2011-12-09T21:52:33Z  in response to SystemAdmin
      I debugged the service call, and it looks like its failing in the upload() method, with a path not specified error. My guess is that its expecting a hard coded path to a folder in the c drive.

      12/9/11 16:47:16:056 EST 00000017 servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause JAX-RS Servlet: javax.servlet.ServletException: java.io.IOException: The system cannot find the path specified.

      I am using the emulator, so not sure if that's causing issues.
      • SystemAdmin
        SystemAdmin
        59 Posts
        ACCEPTED ANSWER

        Re: Issue with uploading pictures using mysurance.apk application

        ‏2011-12-09T22:17:33Z  in response to SystemAdmin
        On closer inspection, it is using the rootpath. I wonder if this is causing some kind of windows security issue when it tries to write the file (I have win 7).
        • CliffLau
          CliffLau
          4 Posts
          ACCEPTED ANSWER

          Re: Issue with uploading pictures using mysurance.apk application

          ‏2011-12-09T23:56:27Z  in response to SystemAdmin
          So you can verify that it is actually getting into the POST function of the MultiFileUploadDataService? I walked through the code and I see where it attempts to set the rootPath. I suspect that it's not finding the javax.servlet.context.tempdir property which is supposed to be in the servlet configuration. A null value ends up throwing a WebApplicationException with text indicating that the tempdir was not set.

          I'm also running on Win7. Security certainly is a consideration. Maybe I'll try loading this up on a Linux box I have and see if it behaves the same way.
  • CliffLau
    CliffLau
    4 Posts
    ACCEPTED ANSWER

    Re: Issue with uploading pictures using mysurance.apk application

    ‏2011-12-10T00:20:51Z  in response to CliffLau
    I just loaded the server code on a Ubuntu v11.10 Linux box. Same symptoms so I don't think this issue is just due to Windows.
    • SystemAdmin
      SystemAdmin
      59 Posts
      ACCEPTED ANSWER

      Re: Issue with uploading pictures using mysurance.apk application

      ‏2011-12-10T00:41:12Z  in response to CliffLau
      Its actually the context-root, its trying to access the full path ending with projectName.war and that's causing the issue. Its failing when it tries to create a new file in that location. I guess changing the uri might help, but not sure how to do that. Probably have to do it in the application.xml (and I cannot find it). They must have changed a bunch of stuff on WAS 8.0. I have not done this is a few years so still finding my way around. Maybe this will help, and you can figure it out from this point on.
      • SystemAdmin
        SystemAdmin
        59 Posts
        ACCEPTED ANSWER

        Re: Issue with uploading pictures using mysurance.apk application

        ‏2011-12-10T01:29:16Z  in response to SystemAdmin
        As I thought, when I hard coded the path, everything worked.

        //String fullPathToFile = rootPath + "/" + filename; --> original code
        String fullPathToFile = "c:/" + filename; --> Hard coded work around
        File file = new File(fullPathToFile);

        The right way to do this would be to fix the context root. Maybe someone can tell us how to do this.
        • SystemAdmin
          SystemAdmin
          59 Posts
          ACCEPTED ANSWER

          Re: Issue with uploading pictures using mysurance.apk application

          ‏2011-12-13T06:11:20Z  in response to SystemAdmin
          We will investigate it for you as soon as possible.
  • BEPJ_ran_zou
    BEPJ_ran_zou
    2 Posts
    ACCEPTED ANSWER

    Re: Issue with uploading pictures using mysurance.apk application

    ‏2011-12-13T13:17:53Z  in response to CliffLau
    Hi cliff, I have tested this defect based on Oct 31st's mobile preview but can not reproduced it(Used my 7" Glaxy tab, verified on WinXP, Linux and Win7 64 bit server, covered Liberty and WAS8).Could you give me more info about your test env(or send me the package of problem code) so I can help with this? Thanks a lot.
    • CliffLau
      CliffLau
      4 Posts
      ACCEPTED ANSWER

      Re: Issue with uploading pictures using mysurance.apk application

      ‏2011-12-14T04:21:34Z  in response to BEPJ_ran_zou
      So after reviewing the javascript code and the STEP12.html, I've figured out what I've been doing wrong. When entering the server address on the Settings page, I was just using the ipaddress of the machine where I was running the Liberty profile sample. I discovered that the entered value needs to include the webcontainer listener port as well as the web context root for the application. So, it needs to look like "ServerAddr:port/contextroot". Once I did that, the photo upload works and the upload directory is logged in the server log.

      Secondly, the location of where the photo gets uploaded is a temp directory which has a horrible directory path. I'm not sure how (or if) it can be overridden. Is it possible to use a servlet init-param instead of the "javax.servlet.context.tempdir" to set the upload directory? Or would that cause potential issues due to the way that different OS platforms represent file paths? At any rate, I now understand how to properly enter the server address information.

      However, I now have to question where do the user profiles and vehicle data get uploaded? The code makes it seem like they should get uploaded, but I can't figure out where. Is it the same tempdir as the photos, or do they really not get uploaded?
      • BEPJ_ran_zou
        BEPJ_ran_zou
        2 Posts
        ACCEPTED ANSWER

        Re: Issue with uploading pictures using mysurance.apk application

        ‏2011-12-14T12:20:56Z  in response to CliffLau
        Yes, it's reasonable to let users config the upload folder themselives. But in that way you have to repackage the code and redeploy to the server. The purpose of mysurance sample is focus on hybrid part and cross platform ability, so we just made the server side as easy as possible.

        Actually the user profile and vehicle data really get uploaded. But unlike photo, they are not stored in the server side file system but a HashMap instead. You can track the source code with UserProfileDataService.createUserProfile()-> PersistenceLayer.createEntry() -> persistentStore.put()