Topic
  • 18 replies
  • Latest Post - ‏2012-08-29T23:32:35Z by SystemAdmin
kai.huang
kai.huang
22 Posts

Pinned topic a question when deploy WLApp on Apache tomcat

‏2012-07-24T06:16:04Z |
hi, some background before question,
We have made the worklight.war deployed on the tomcat webapp folder,
as well as necessary jar lib files. the console is accessiable from the tomcat port.
the wlapp file and the adapater could also get deployed through the console.
and the "preview as common resouce" link works.

we have put one testing app on the android market to test this production env,
but it seems like the app can not access to the adpater delopyed on the tomcat server.

the server url bind with app in the application-descripter.xml while dev environment is :domain:port
which i guess is not corret, it does failed. so i change it to domain:port/worklight , which is point to the worklight server war, but not workling as well.
any one know if i miss something?
what is actually the "configuring WORKLIGHT SERVER" shoud do?
"Step 1: Defining environment variables."
Step 2: Applying environment-specific customization.
Step 3: Deploying content.
"
the admin.pdf guide just roughly mentioned these three steps...
i do found a customization.jar file under bin folder, what is it for?
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-24T07:10:02Z  
    i wonder is it some configuration we should make on the toomcat server.xml file?
  • VV3R_mordechai_taitelman
    43 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-24T07:22:11Z  
    Hi Kai
    In most cases what you describe happens when a mobile developer switch from the Eclipse environment to the production environment (Websphere/Liberty/Tomcat server).
    Usually it is all about the context root in Tomcat.
    Eclipse environment uses the root context for all worklight servlets,
    However, on Tomcat you will probably want some special context root or special port or both.
    (for sake of example let's assume: http://tomcat:8721/myProj ) so in that case, just before
    you deploy the customization WAR file to your tomcat , go back to the Eclipse Worklight project .
    (While all worked well in Eclipse ,two files contain information about the target server)
    1. application-descriptor.xml has a line:
    <worklightServerRootURL>http://${local.IPAddress}:8080</worklightServerRootURL>
    change it to match your Tomcat server hostname and port and desired context root:
    <worklightServerRootURL>http://tomcat:8721/myProj/</worklightServerRootURL>
    2. worklight.properties : find these entries:
    #publicWorkLightPort=8080
    #publicWorkLightContext=/
    and un-comment them. edit them to match your desired tomcat setting:
    publicWorkLightPort=8721
    publicWorkLightContext=/myProj
    3. save the last edited file (this will update the WAR). Take the customization WAR file from the Eclipse project bin directory and re-deploy to your tomcat.
    4. open a browser to validate: http://tomcat:8721/myProj/console
  • VV3R_mordechai_taitelman
    43 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-24T07:25:44Z  
    Hi Kai
    In most cases what you describe happens when a mobile developer switch from the Eclipse environment to the production environment (Websphere/Liberty/Tomcat server).
    Usually it is all about the context root in Tomcat.
    Eclipse environment uses the root context for all worklight servlets,
    However, on Tomcat you will probably want some special context root or special port or both.
    (for sake of example let's assume: http://tomcat:8721/myProj ) so in that case, just before
    you deploy the customization WAR file to your tomcat , go back to the Eclipse Worklight project .
    (While all worked well in Eclipse ,two files contain information about the target server)
    1. application-descriptor.xml has a line:
    <worklightServerRootURL>http://${local.IPAddress}:8080</worklightServerRootURL>
    change it to match your Tomcat server hostname and port and desired context root:
    <worklightServerRootURL>http://tomcat:8721/myProj/</worklightServerRootURL>
    2. worklight.properties : find these entries:
    #publicWorkLightPort=8080
    #publicWorkLightContext=/
    and un-comment them. edit them to match your desired tomcat setting:
    publicWorkLightPort=8721
    publicWorkLightContext=/myProj
    3. save the last edited file (this will update the WAR). Take the customization WAR file from the Eclipse project bin directory and re-deploy to your tomcat.
    4. open a browser to validate: http://tomcat:8721/myProj/console
    One clarification:
    port 8721 is the Tomcat http listening port in my example only.
    Default tomcat http port is usually 8080. Some people change it for security reasons.
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-25T00:47:13Z  
    Hi Kai
    In most cases what you describe happens when a mobile developer switch from the Eclipse environment to the production environment (Websphere/Liberty/Tomcat server).
    Usually it is all about the context root in Tomcat.
    Eclipse environment uses the root context for all worklight servlets,
    However, on Tomcat you will probably want some special context root or special port or both.
    (for sake of example let's assume: http://tomcat:8721/myProj ) so in that case, just before
    you deploy the customization WAR file to your tomcat , go back to the Eclipse Worklight project .
    (While all worked well in Eclipse ,two files contain information about the target server)
    1. application-descriptor.xml has a line:
    <worklightServerRootURL>http://${local.IPAddress}:8080</worklightServerRootURL>
    change it to match your Tomcat server hostname and port and desired context root:
    <worklightServerRootURL>http://tomcat:8721/myProj/</worklightServerRootURL>
    2. worklight.properties : find these entries:
    #publicWorkLightPort=8080
    #publicWorkLightContext=/
    and un-comment them. edit them to match your desired tomcat setting:
    publicWorkLightPort=8721
    publicWorkLightContext=/myProj
    3. save the last edited file (this will update the WAR). Take the customization WAR file from the Eclipse project bin directory and re-deploy to your tomcat.
    4. open a browser to validate: http://tomcat:8721/myProj/console
    thank you very much for your reply.
    i did by follow your method.
    http://domain:port/path/console and it worked.
    i use it to deploy the wlapp and adapter, it works fine.

    but the problem we having is,
    when wlapp try to invoke the adapter on the server, it returns fail.

    did we still miss some step?
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-25T00:49:33Z  
    • kai.huang
    • ‏2012-07-25T00:47:13Z
    thank you very much for your reply.
    i did by follow your method.
    http://domain:port/path/console and it worked.
    i use it to deploy the wlapp and adapter, it works fine.

    but the problem we having is,
    when wlapp try to invoke the adapter on the server, it returns fail.

    did we still miss some step?
    actually we got a 500 error

    HTTP Status 500 -

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    java.lang.NullPointerException
    com.worklight.core.auth.impl.LoginConfigurationService.createInstance(LoginConfigurationService.java:248)
    com.worklight.core.auth.impl.LoginConfigurationService.createLoginContext(LoginConfigurationService.java:159)
    com.worklight.core.auth.impl.AuthenticationContext.checkAuthentication(AuthenticationContext.java:456)
    com.worklight.core.auth.impl.AuthenticationContext.pushCurrentResource(AuthenticationContext.java:346)
    com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:68)
    com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:143)
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-25T00:55:58Z  
    • kai.huang
    • ‏2012-07-25T00:49:33Z
    actually we got a 500 error

    HTTP Status 500 -

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    java.lang.NullPointerException
    com.worklight.core.auth.impl.LoginConfigurationService.createInstance(LoginConfigurationService.java:248)
    com.worklight.core.auth.impl.LoginConfigurationService.createLoginContext(LoginConfigurationService.java:159)
    com.worklight.core.auth.impl.AuthenticationContext.checkAuthentication(AuthenticationContext.java:456)
    com.worklight.core.auth.impl.AuthenticationContext.pushCurrentResource(AuthenticationContext.java:346)
    com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:68)
    com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:143)
    below is exception catched from tomcat log:
    0-----------------
    org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet GadgetAPIServlet threw exception
    java.lang.NullPointerException

    ....
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-25T01:17:42Z  
    • kai.huang
    • ‏2012-07-25T00:55:58Z
    below is exception catched from tomcat log:
    0-----------------
    org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet GadgetAPIServlet threw exception
    java.lang.NullPointerException

    ....
    a update of the background,,
    this app is for demo purpose,
    so we dont configue any authentication steps

    in application-descriptor.xml
    <usage requireAuthentication="never"/>
  • VV3R_mordechai_taitelman
    43 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-25T06:52:43Z  
    One clarification:
    port 8721 is the Tomcat http listening port in my example only.
    Default tomcat http port is usually 8080. Some people change it for security reasons.
    one more issue:
    in Tomcat : the name of the WAR will also determine its context root.
    so : no matter what is the WAR name , before deploy, rename it to myProj.war
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-25T07:08:38Z  
    one more issue:
    in Tomcat : the name of the WAR will also determine its context root.
    so : no matter what is the WAR name , before deploy, rename it to myProj.war
    thanks.
    i use tomcat manager admin page to verify if the war got deployed successfully.
    the console page is working.
    base on the 500 error indicated, it seems like the app authentication part might cause the error? since our app didn't implement any authentication methodology.
    the problem we have is for the app to invoke adapter, it returns 500 error as above msgs mentioned
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-25T18:41:44Z  
    Can you attach the code for the adapter in question? And can you provide the code snippet of the wlapp that is invoking the adapter?
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-26T00:17:02Z  
    Can you attach the code for the adapter in question? And can you provide the code snippet of the wlapp that is invoking the adapter?
    thanks/

    1.code to invoke adapter:
    var invocationData = {
    adapter : 'ClinicSearchAdapter',
    procedure : 'getClinics',
    parameters : longitude, latitude
    };
    var options = {
    onSuccess : nearbyClinicOnSuccess,
    onFailure : nearbyClinicOnFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);

    2.attached code contains apater and some java files related

    Attachments

  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-26T00:59:16Z  
    • kai.huang
    • ‏2012-07-26T00:17:02Z
    thanks/

    1.code to invoke adapter:
    var invocationData = {
    adapter : 'ClinicSearchAdapter',
    procedure : 'getClinics',
    parameters : longitude, latitude
    };
    var options = {
    onSuccess : nearbyClinicOnSuccess,
    onFailure : nearbyClinicOnFailure,
    };
    WL.Client.invokeProcedure(invocationData, options);

    2.attached code contains apater and some java files related
    you might see some problem in the application-descripter.xml, please ignore as we have updated it to our:
    domain:port/contentroot
  • kai.huang
    kai.huang
    22 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-07-26T01:05:29Z  
    Can you attach the code for the adapter in question? And can you provide the code snippet of the wlapp that is invoking the adapter?
    also, just got a question in my mind,

    can we invoke java class file straightaway in the adapter javascript file on the server side?

    kai
  • nareshnelluri
    nareshnelluri
    36 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-08-29T11:56:28Z  
    Hi Kai
    In most cases what you describe happens when a mobile developer switch from the Eclipse environment to the production environment (Websphere/Liberty/Tomcat server).
    Usually it is all about the context root in Tomcat.
    Eclipse environment uses the root context for all worklight servlets,
    However, on Tomcat you will probably want some special context root or special port or both.
    (for sake of example let's assume: http://tomcat:8721/myProj ) so in that case, just before
    you deploy the customization WAR file to your tomcat , go back to the Eclipse Worklight project .
    (While all worked well in Eclipse ,two files contain information about the target server)
    1. application-descriptor.xml has a line:
    <worklightServerRootURL>http://${local.IPAddress}:8080</worklightServerRootURL>
    change it to match your Tomcat server hostname and port and desired context root:
    <worklightServerRootURL>http://tomcat:8721/myProj/</worklightServerRootURL>
    2. worklight.properties : find these entries:
    #publicWorkLightPort=8080
    #publicWorkLightContext=/
    and un-comment them. edit them to match your desired tomcat setting:
    publicWorkLightPort=8721
    publicWorkLightContext=/myProj
    3. save the last edited file (this will update the WAR). Take the customization WAR file from the Eclipse project bin directory and re-deploy to your tomcat.
    4. open a browser to validate: http://tomcat:8721/myProj/console
    hi.....

    i m using developer edition....

    ->is it possible to deploy my worklight app to tomcat server
    ->i did all the changes u mentioned but i m not getting the xpected...

    ->i followed this link also still getting error in deploying tomcat

    http://public.dhe.ibm.com/ibmdl/export/pub/software/mobile-solutions/worklight/docs/Module_42_-_Moving_from_Development_Environment_to_Remote_QA_and_Production_Servers.pdf
    if it is possible to do with developer edition please give the necessary steps to deploy in tomcat server
  • Somasundaramrk
    Somasundaramrk
    49 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-08-29T12:09:31Z  
    Hi,

    I want to know how to deploy worklight apps in tomcat. Can you tel me the steps?
  • nareshnelluri
    nareshnelluri
    36 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-08-29T14:18:40Z  
    • kai.huang
    • ‏2012-07-25T00:47:13Z
    thank you very much for your reply.
    i did by follow your method.
    http://domain:port/path/console and it worked.
    i use it to deploy the wlapp and adapter, it works fine.

    but the problem we having is,
    when wlapp try to invoke the adapter on the server, it returns fail.

    did we still miss some step?
    please provide step by step process for deployment of application on tomcat server
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-08-29T14:48:44Z  
    If you haven't enabled authentication on your application or adapter then the problem shouldn't be related to auth. Has your adapter been uploaded to your Tomcat server? You must manually upload it as it cannot be uploaded through the Eclipse environment as you normally would do. Also, how are you calling the adapter? Through the application? Using a URL?

    Somasundaramrk, can you please open up a new thread for your question? Thanks.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: a question when deploy WLApp on Apache tomcat

    ‏2012-08-29T23:32:35Z  
    hi.....

    i m using developer edition....

    ->is it possible to deploy my worklight app to tomcat server
    ->i did all the changes u mentioned but i m not getting the xpected...

    ->i followed this link also still getting error in deploying tomcat

    http://public.dhe.ibm.com/ibmdl/export/pub/software/mobile-solutions/worklight/docs/Module_42_-_Moving_from_Development_Environment_to_Remote_QA_and_Production_Servers.pdf
    if it is possible to do with developer edition please give the necessary steps to deploy in tomcat server
    Naresh,

    See reply to your thread here: http://www.ibm.com/developerworks/forums/thread.jspa?threadID=447600&tstart=0

    Barbara Hampson, Manager, IBM Worklight