Topic
  • 2 replies
  • Latest Post - ‏2013-10-14T08:03:23Z by jnjnc
jnjnc
jnjnc
6 Posts

Pinned topic Liberty profile servlet context getRealPath

‏2013-10-11T11:48:14Z |

Hi,

Even when following the below recommendation

http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/index.jsp?topic=%2Fcom.ibm.websphere.wlp.express.doc%2Fae%2Frwlp_restrict.html

I'm getting null when trying to access ServletContext.getRealPath() with liberty profile 8.5.5.

I also try to apply following fix pack

http://www-01.ibm.com/support/docview.wss?uid=swg1PM70146.

 

Please note that the same application is working on 8.5 full profile. I did same kind of deployment than the one done by in the full profile, initially the application is a war, I embedded it in an exploded ear file,  as an exploded war file.

 

It has also been posted there by user having similar problem with no luck.

https://www.ibm.com/developerworks/community/forums/html/topic?id=ec4e381b-5deb-4fa2-ac14-798c2ca89ba9&ps=50

Do you have any suggestion.

 

Thanks for your help and regards.

  • Alasdair
    Alasdair
    55 Posts

    Re: Liberty profile servlet context getRealPath

    ‏2013-10-11T13:54:53Z  

    Hi,

    If you point the liberty profile at a .war or .ear file then the Liberty profile will run the application from the .war or .ear file. The Java EE specification says that when this is done getRealPath must return null.

    If your application needs a non-null return from getRealPath then you can deploy the war as an exploded directory by unzipping it into a directory named after the .war file. If you are deploying a .ear file you should do the same to the .ear and each .war file in the ear.

    Thanks
    Alasdair

  • jnjnc
    jnjnc
    6 Posts

    Re: Liberty profile servlet context getRealPath

    ‏2013-10-14T08:03:23Z  
    • Alasdair
    • ‏2013-10-11T13:54:53Z

    Hi,

    If you point the liberty profile at a .war or .ear file then the Liberty profile will run the application from the .war or .ear file. The Java EE specification says that when this is done getRealPath must return null.

    If your application needs a non-null return from getRealPath then you can deploy the war as an exploded directory by unzipping it into a directory named after the .war file. If you are deploying a .ear file you should do the same to the .ear and each .war file in the ear.

    Thanks
    Alasdair

    Hi,

    Thanks for your answer, I did deploy my application as suggested in an exploded directory, to be sure, I copied my application from the installedApps folder of the full profile, which is working fine.

    The expanded structure look like this :

    C:\WASLiberty\usr\servers\MyServer\apps\MyApp_war.ear\MyApp.war

    Please note that MyApp.war is an exploded directory and there is a META-INF in MyApp_war.ear

    The server config is:

    <application id="MyApp" name="MyApp" location="${server.config.dir}/apps/MyApp_war.ear" 
    context-root="MyApp" type="ear">
    </application>

    I tried the same  by exploding the war directly in ${server.config.dir}/apps and setting application type to war in the server.xml with no luck, I always get null when invoking getRealPath.

    Again this application is working absolutely fine in full profile 8.5.

    Regards,

    JN