Showing posts with label Weblogic Server. Show all posts
Showing posts with label Weblogic Server. Show all posts

Saturday, February 12, 2011

Fix: Weblogic ServletContext.getRealPath() returns null

Weblogic Server[WLS] returns null if your code is using Servlet.getRealPath() many of you expect that it's another weblogic server bug but it's not. An application can be deployed in two ways either exploded or archive. If you are deploying an application as exploded which is a folder containing your application you won't see such an error. But, if you deploy it as an archive which is like zipping the folder having extentions like war, ear etc.  you will see this error, and mostly we prefer to deploy our applications as archive rather than exploded. So, how to fix such an error.
So, Let's get started
Note:  The advantage of deploying an application as exploded over archive is the access to the application content is much faster.
It's a simple fix. You can fix this problem by approaching it in two ways one is application server level. The other is application level.

Application Server Level

Goto Server Admin Console > Domain > Web Application > Archived Real Path Enabled. Enable this option restart the server and Bingo.!!!

It makes an entry into domain config.xml file something like this,

<web-app-container>
    <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</web-app-container>

Application Level

Create a xml file in WEB-INF folder name it weblogic.xml if it's not there by default. Add the following entry.

<container-descriptor>
    <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>

Redeploy your application done.

Hope this Helps! Please write your comments it will help me improve.

Wednesday, February 09, 2011

JSF2.0: Unable to load JSF2.0/Primefaces jars on Weblogic Server 10.3.2 start up

I think except for the option to upgrade to a new version or applying a patchset there is a workaround that i tried and it worked for me.

Problem
It occurs because weblogic 10 is shipped with Mojarra JSF 1.2 and the version that we want to make it work is Mojarra JSF 2.0.

Solution
It's a simple fix. In weblogic there is a file called commEnv.bat/sh. If you are running windows edit the bat file, else if you are running Linux/Mac edit the sh file.

Search for PRE_CLASSPATH or WEBLOGIC_CLASSPATH and add a complete path to the jsf-api.jar, jsf-impl.jar before weblogic.jar and if you are using Primefaces, just append it afterwords. Restart the server, deploy your application make sure that jsf-api.jar and jsf-impl.jar are there in the lib folder, but you are now free to remove the primefaces jar as it is already loaded by weblogic at server start-up otherwise you will see the same error still your application won't break.


Topic Discussed
http://forums.oracle.com/forums/thread.jspa?threadID=1043858&start=30&tstart=0
http://www.coderanch.com/t/486434/JSF/java/Unable-load-primefaces-jar-Weblogic

Hope this Helps! Please write your comments it will help me improve.