Hi,
Many times we dont want to install a separate WebServer like (Apache,IIS or IPlanate) rather we want to configure and run a WebLogic Server itself as a WebLogic WebServer. Yes it is possible. In the following manner we can configure a WebLogic Server as a Frontend WebServer which is going to point a WebLogic Cluster. This can be achievend by deploying a simple WebApplication in the front end WebLogic ManagedServer to make it working it as a WebServer.
Here in this sample we are going to use WebLogic HttpClusterServlet application as a WebLogic WebServer. As described in the following Diagram e are going to use HttpClusterServlet…
Architecture Diagram:
Step1). Create a WebLogic Domain with 1-AdminServer and 3 ManagedServers…And a Cluster like following:
Step2). We are going to develope a Simple HttpClusterServletWebApplication to make the “FrontEnd_MS” Server as a WebServer. So Create a Directory somewhere in your file system like following:
C:DemoProxyWebApp
Step3). Create a “WEB-INF” directory inside “C:DemoProxyWebApp” and then place the following “web.xml” file inside “C:DemoProxyWebAppWEB-INF”
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"> <servlet> <servlet-name>HttpClusterServlet</servlet-name> <servlet-class>weblogic.servlet.proxy.HttpClusterServlet</servlet-class> <init-param> <param-name>WebLogicCluster</param-name> <param-value>localhost:7003|localhost:7005</param-value> </init-param> <init-param> <param-name>verbose</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>DebugConfigInfo</param-name> <param-value>ON</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>HttpClusterServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HttpClusterServlet</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HttpClusterServlet</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HttpClusterServlet</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> </web-app>
————————————————————————–
Step4). Now create a Simple “weblogic.xml” file inside “C:DemoProxyWebAppWEB-INF” like following:
<?xml version="1.0" encoding="UTF-8"?> <weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90"> <context-root>/</context-root> </weblogic-web-app>
————————————————————————–
Step5). Now deploy the Application “ProxyWebApp” on “FrontEnd_MS” WebLogic Server to make it as a WebServer…to redirect Client request to Cluster Members.
NOTE: S t e p – 6 ) is optional If already u have some application deployed on your Cluster then no need to develop a new Test Application…your Set up is ready till “s t e p 5)” you can skip other below Steps.
————————————————————————–
Step6). Now we will develope a Simple WebApplication to check if the Failover and Loadbalancing is happening or not. So Please create another WebApplication in the following Location:
C:DemoTestWebApp
————————————————————————–
Step7). provide the following “index.jsp” page inside “C:DemoTestWebApp”
<HTML> <center> <form action="ValidateServlet" method="POST"> <h3>Enter Your ID : <input type=text name=userid value=admin><BR> <h3>Enter Password : <input type=password name=pass value="weblogic"><BR> <input type=submit value="Login"> <input type=reset value="Clear"> </form> </center> <HR> NOTE: Default password is "weblogic" <% System.out.println("nnt index.jsp called"); %> </HTML>
————————————————————————–
Step8). Provide the following “logout.jsp” page inside “C:DemoTestWebApp”
<HTML> <% if(session!=null) { session.invalidate(); %> <jsp:forward page="index.jsp" /> <% } else{ %> Logged Out Successfully.... <% }%> </HTML>
————————————————————————–
Step9). Create a “WEB-INF” directory inside “C:DemoTestWebApp” location
.
Step10). Create “classes” directory inside “C:DemoTestWebAppWEB-INF” location
.
————————————————————————–
Step11). Now start writing the “ValidateServlet.java” program inside “C:DemoTestWebAppWEB-INFclasses” like following:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class ValidateServlet extends HttpServlet { public void service(HttpServletRequest req , HttpServletResponse res)throws ServletException,IOException { PrintWriter out=res.getWriter(); out.println("<html>"); String id=req.getParameter("userid"); String pass=req.getParameter("pass"); if(id.equals("admin") && pass.equals("weblogic")) { HttpSession session=req.getSession(true); System.out.println("nt ValidateServlet: SessionID: "+session.getId()); session.setAttribute("name","Jack"); RequestDispatcher rd=req.getRequestDispatcher("/AddServlet"); System.out.println("nnt ValidateServlet calling the requstDispatcher.forward(req,res)");; out.println("<center><a href=AddServlet>Click Here to Add Two Numbers</a></center>"); } else { RequestDispatcher rd=req.getRequestDispatcher("/SorryServlet"); req.setAttribute("msg","InValid User Please Try Again.."); rd.forward(req,res); } out.println("</html>"); } }
————————————————————————–
Step12). Now start writing the “AddServlet.java” program inside “C:DemoTestWebAppWEB-INFclasses” like following:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class AddServlet extends HttpServlet { public void service(HttpServletRequest req , HttpServletResponse res)throws ServletException,IOException { PrintWriter out=res.getWriter(); out.println("<html>"); HttpSession session=req.getSession(false); System.out.println("nt AddServlet : Session Exists? : "+session); System.out.println("nt AddServlet : SessionID: "+session.getId()); // false=> If the Session Object for this client is already existing then Use the Same // Otherwise DON’T Create a new Session Object if(session!=null) { String name=(String)session.getAttribute("name"); out.println("<body bgcolor=maroon text=white>"); out.println("<center><h1>Welcome Mr. "+name+"</h1>"); out.println("<form action=ResultServlet>"); out.println("<h3>Enter First Number : <input type=text name=fno><BR>"); out.println("<h3>Enter Second Number : <input type=text name=sno><BR>"); out.println("<input type=submit value=AddNow></form>"); out. println("<hr><a href=LogoutServlet>Want to Logout</a>"); } else { RequestDispatcher rd=req.getRequestDispatcher("/SorryServlet"); req.setAttribute("msg","Sorry You cannot Access AddServlet Please login First..."); rd.forward(req,res); } out.println("</body></html>"); } }
————————————————————————–
Step13). Now start writing the “ResultServlet.java” program inside “C:DemoTestWebAppWEB-INFclasses” like following:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class ResultServlet extends HttpServlet { public void service(HttpServletRequest req , HttpServletResponse res)throws ServletException,IOException { PrintWriter out=res.getWriter(); out.println("<html>"); HttpSession session=req.getSession(false); System.out.println("nt ResultServlet : Session Exists? : "+session); System.out.println("nt ResultServlet : SessionID: "+session.getId()); if(session!=null) { String name=(String)session.getAttribute("name"); out.println("<center><h1>Welcome Mr. "+name+"</h1>"); int a=Integer.parseInt(req.getParameter("fno")); int b=Integer.parseInt(req.getParameter("sno")); int sum=(a+b); out.println("<h1>Sum of "+a+" And "+b+" = "+sum); out. println("<hr><a href=LogoutServlet>Want to Logout</a>"); } else { RequestDispatcher rd=req.getRequestDispatcher("/SorryServlet"); req.setAttribute("msg","Sorry You cannot Access ResultServlet Please login First..."); rd.forward(req,res); } out.println("</html>"); } }
————————————————————————–
Step14). Now start writing the “LogoutServlet.java” program inside “C:DemoTestWebAppWEB-INFclasses” like following:
import javax.servlet.*;
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class LogoutServlet extends HttpServlet { public void service(HttpServletRequest req , HttpServletResponse res)throws ServletException,IOException { PrintWriter out=res.getWriter(); out.println("<html>"); HttpSession session=req.getSession(false); System.out.println("nt 1----LogoutServlet : Session Exists? : "+session); System.out.println("nt LogoutServlet : SessionID: "+session.getId()); if(session!=null) { String name=(String)session.getAttribute("name"); out.println("<center><h1>Welcome Mr. "+name+"</h1>"); session.invalidate(); // to destroy session object out. println("<hr><a href=logout.jsp>Want to Login Again</a>"); } else { RequestDispatcher rd=req.getRequestDispatcher("/SorryServlet"); req.setAttribute("msg","Sorry You cannot Logout Before Loggin In, Please login First…"); rd.forward(req,res); } System.out.println("nt 2----LogoutServlet : Session Exists? : "+session); out.println("</html>"); } }
————————————————————————–
Step15). Now start writing the “LogoutServlet.java” program inside “C:DemoTestWebAppWEB-INFclasses” like following:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class SorryServlet extends HttpServlet { public void service(HttpServletRequest req , HttpServletResponse res)throws ServletException,IOException { PrintWriter out=res.getWriter(); out.println("<html>"); String message=(String)req.getAttribute("msg"); out.println("<h1>"+message); out.println("</html>"); } }
————————————————————————–
Step 16). Now provide the following “web.xml” file inside “C:DemoTestWebAppWEB-INF” location
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>one</servlet-name> <servlet-class>ValidateServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>one</servlet-name> <url-pattern>/ValidateServlet</url-pattern> </servlet-mapping> <servlet> <servlet-name>onea</servlet-name> <servlet-class>AddServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>onea</servlet-name> <url-pattern>/AddServlet</url-pattern> </servlet-mapping> <servlet> <servlet-name>oneb</servlet-name> <servlet-class>ResultServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>oneb</servlet-name> <url-pattern>/ResultServlet</url-pattern> </servlet-mapping> <servlet> <servlet-name>onec</servlet-name> <servlet-class>LogoutServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>onec</servlet-name> <url-pattern>/LogoutServlet</url-pattern> </servlet-mapping> <servlet> <servlet-name>oned</servlet-name> <servlet-class>SorryServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>oned</servlet-name> <url-pattern>/SorryServlet</url-pattern> </servlet-mapping> </web-app>
————————————————————————–
Step17). The Most Important Step to make the HttpSession as replicatable for our application….Please provide the following “weblogic.xml” file inside “C:DemoTestWebAppWEB-INF” :
<?xml version="1.0" encoding="UTF-8"?> <weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90"> <session-descriptor> <persistent-store-type>replicated</persistent-store-type> </session-descriptor> </weblogic-web-app>
————————————————————————–
Step18). Open a command window and then run the “setWLSEnv.cmd” to set the environment in the current prompt and then move inside the “C:DemoTestWebAppWEB-INFclasses” directory in the same command prompt to compile the Servlet programs….like following:
Step19). Now deploy the Application “TestWebApp” from the following location “C:DemoTestWebApp” in the WebLogic Cluster (This Cluster contains 2 ManagedServers…MS1 and MS2 as we have seen in the architectur Diagram)
Step20). Now hit the Proxy Server to access the Clustered Application:
http://localhost:81/TestWebApp like following:
.
.
Thanks
Jay SenSharma
August 1st, 2010 on 9:03 pm
Thanks Jay …. Appreciate your help!!!
August 4th, 2010 on 4:19 am
hi Jay ,
recently iam getting below error in my managednohup.out file.
we have only one cluster in that domain, please advice what was the problem.
August 4th, 2010 on 11:55 am
Hi Rocky,
Seems that the error which u tried to paste from “managednohup.out ” is not pasted in this comment. Please try to post it once again.
NOTE: Sometimes u may find difficulty in posting your Error Logs or XML files….in that case please do teh following ……
replace all > with >
replace all < with <
Before posting the error/Xml file contents.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 4th, 2010 on 9:56 pm
Hi khan,
in my log file , iam getting this error ,
>
i have only one cluster in my domain.
August 4th, 2010 on 10:31 pm
NOTE: Sometimes u may find difficulty in posting your Error Logs or XML files….in that case please do teh following ……
replace all > with >
replace all < with <
Before posting the error/Xml file contents.
August 12th, 2010 on 2:03 am
Hi Jay,
I have posted a question to you over OTN Forums. But I would like to have the same question posted here too. When you get a chance, would you take a look at and giev me any information you can. Thanks a lot!
I am new to this weblogic forum. Recently I am helping my weblogic admins to perform J2EE applications performance tests. We found out some scenarios that we could not explain during our perfromance tests. The issue is about Thread Throughput of Weblogic JVMS. We have a cluster that has two members. The number of Thread Throughput on one of the 2 Weblogic JVMS always jumps up high a few minutes after our performance test starts each time. This case happens either on AppSvr1 or on AppSvr2, but not on both from a same test. See the sample logs from Weblogic JMX below.
bash-3.00$ more MonThread_AppSvr1.log
************************** 2010-08-04 15:10:36 **********************************************
Server Name: AppSvr1
Queue Name: ThreadPoolRuntime
Current Idle Thread Count: 13
Execute Thread Total Count: 22
Execute Thread Standby Count: 7
Hogging Thread Count: 0
Pending Request current Count: 0
Queue Length: 0
Total number of serviced request: 7222764
Server Throughput: 9.0
************************** 2010-08-04 15:15:47 **********************************************
Server Name: AppSvr1
Queue Name: ThreadPoolRuntime
Current Idle Thread Count: 14
Execute Thread Total Count: 22
Execute Thread Standby Count: 7
Hogging Thread Count: 0
Pending Request current Count: 0
Queue Length: 0
Total number of serviced request: 7228771
Server Throughput: 195.1219512195122
You can see the number jumps up to 195.1219512195122 at 15:15:47 which is 5 minutes after the test started. We opened a case in BEA, but we haven’t gotten any answers yet. Did you guys see same situations on your systems before or this is just a bug in Weblogic itself? Your responses will be much appreciated.
August 17th, 2010 on 5:27 pm
Hi Faysal,
I am using customised script for shutting down the server. It contains 2 ways.
1) weblogic.Admin FORCESHUTDOWN
2) killing the PID
If first one fails, the second one will execute.
but fro some reason if I run that script, the server is killed with PID and it is displaying one message as follows.
Stopping Weblogic Server…
Cannot shutdown a server when using a BootIdentify file AND running in Production mode
August 17th, 2010 on 5:33 pm
Hi Prasad,
Can you post the script you are using to stop the server?
Also paste the server logs here.
let me test your script at my end.
Thanks,
Faisal
August 17th, 2010 on 5:40 pm
Hi Prasad,
While Posting your Error Messages in Wonders Please …replace all the > Characters with > and all the < characters with <
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 17th, 2010 on 7:13 pm
WL_HOME=/WebLogic/utils/bea705/weblogic700
JAVA_HOME=”external jdk 1.3″
if [ “$1” != “” ] ; then
UIDPWD=”-username $1″
shift
fi
if [ “$1” != “” ] ; then
UIDPWD=”${UIDPWD} -password $1″
shift
fi
if [ “” = “true” ] ; then
if [ “${UIDPWD}” = “” ] ; then
echo “ERROR: Because your domain was created as a production mode domain. ”
echo “You MUST include a username parameter that can be used to shutdown Weblogic Server”
read _val
exit
fi
fi
# set server name
SERVER_NAME=itrpAdmin
if [ “$1” != “” ] ; then
SERVER_NAME=”$1″
shift
fi
if [ “${SERVER_NAME}” = “” ] ; then
echo “ERROR: Missing Server Name. ”
echo “Usage: stopWebLogic.cmd(sh) [username] [password] [server-name] [admin-url]”
read _val
exit
fi
# set ADMIN_URL
if [ “$1” != “” ] ; then
ADMIN_URL=”$1″
shift
else
if [ “${ADMIN_URL}” = “” ] ; then
ADMIN_URL=”value”
fi
fi
# Call commEnv here.
. $WL_HOME/common/bin/commEnv.sh
echo “Stopping Weblogic Server…”
${JAVA_HOME}/bin/java -cp ${WEBLOGIC_CLASSPATH} weblogic.Admin FORCESHUTDOWN -url ${ADMIN_URL} ${UIDPWD} ${SERVER_NAME} 2>&1
#/WebLogic/utils/bea705/jdk131_10/bin/java -cp ${WEBLOGIC_CLASSPATH} weblogic.Admin FORCESHUTDOWN -url ${ADMIN_URL} ${UIDPWD}
${SERVER_NAME} 2>&1
#rl ${ADMIN_URL} ${UIDPWD} ${SERVER_NAME} 2>&1
sleep 15
WL_MANAGED_PID=`/usr/ucb/ps auwwx|grep java|grep ${SERVER_NAME} |awk ‘{print $2}’`
if [ “$WL_MANAGED_PID” = “” ] ; then
echo “# ***********************************************************”
echo “# WebLogic Managed Server ${SERVER_NAME} stopped successfully”
echo “# ***********************************************************”
else
echo “# ***********************************************************”
echo “# WebLogic Managed Server ${SERVER_NAME} was not stopped”
echo “# Killing WebLogic Managed Server process”
echo “# `kill $WL_MANAGED_PID`”
echo “# ***********************************************************”
kill $WL_MANAGED_PID
fi
August 17th, 2010 on 9:04 pm
Hi Prasad,
Your Script has Missing Parameters “-username” and “-password” in “weblogic.Admin” Utility.
Example: java weblogic.Admin -url MS1HostName:7003 -username weblogic -password weblogic FORCESHUTDOWN
In your Script i can see that u are passing the UserName and Password But u are not specifying the -username and -password attributes …
Just change your script Line as below:
Your Script Lines below:
${JAVA_HOME}/bin/java -cp ${WEBLOGIC_CLASSPATH} weblogic.Admin FORCESHUTDOWN -url ${ADMIN_URL} ${UIDPWD} ${SERVER_NAME} 2>&1
Edited Lines as Below
${JAVA_HOME}/bin/java -cp ${WEBLOGIC_CLASSPATH} weblogic.Admin FORCESHUTDOWN -url ${ADMIN_URL} -username ${AdminUserName} -password ${AdminPWD} ${SERVER_NAME} 2>&1
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
October 4th, 2010 on 11:27 pm
Hi Jay;
I have done the above setup an dhave the web server running on ports 7001(http) and 7002(https). But somehow the url adds 443 at the end of the url before forwarding to the cluster running at 7003, 7004, and 7005 ports on the same machine.
abc.xyz.com:7003:443
abc.xyz.com:7004:443
abc.xyz.com:7005:443
And the log shows connection refused.
Thanks
Aattish
October 5th, 2010 on 11:45 pm
Hi Aatish
Answer this
What ports and ip ( use dummy values if u want) are the
1) Webserver
2) Application Server running on
With what ur you are accessing the application?
Can you send a screenshot along with the proxy log and proxy configuration file at weblogicwonders@yahoo.in ??
-Faisal
October 7th, 2010 on 4:29 am
hello Admin,
Can we use this process for production environment.
October 9th, 2010 on 3:32 pm
No, HTTP Cluster Servlet is not recommended for Production.
Thanks,
Faisal
December 16th, 2010 on 2:19 am
I am getting an error after step 5)
Below is the error
Unable to access the selected application.
Exception in AppMerge flows’ progression
Exception in AppMerge flows’ progression
java.io.CharConversionException: Unconvertible UTF-8 character beginning with 0x94
December 16th, 2010 on 4:04 pm
Hi Rakesh,
The error which you are getting comes due to some special characters, hence would suggest you to check if you have copied the xml data properly and if yes then check for any special characters in it.
Regards,
Ravish Mody
December 17th, 2010 on 4:14 am
Hello ravish/Jay,
Can’t we use this HTTPPROXYSERVLET process in production mode for load balancing.
Also, if it can be used in prod, is this effective for load balancing ???
or do you suggest to go for some third party web server like IIS as we are working with weblogic on windows 2k# Server OS.
Thanks in Advance
Rakesh
December 17th, 2010 on 10:56 am
Hi Rakesh,
HttpClusterServlet is not recommended for production environments because more efficient & Lightweight WebServers are available in market like Iplanet/ Apache/IIS …etc All those plugins provides much more features additional to the HttpClusterServlet.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 29th, 2010 on 8:11 pm
HI Jay ,
If i have turned ON the extended logging for weblogic when using it as a web servers . So , how can i get sessions information in access log .
Is there any way to configure the logging to get the session information in Weblogic web server ?
Regards,
Appi
December 29th, 2010 on 11:27 pm
Hi Appi,
Limited informations about HttpSession you can get in the WebLogic Servers “access.log”…But for that you need to add a Custom Field for Session Logging …Which can be achieved as described in the following Link: http://download.oracle.com/docs/cd/E12840_01/wls/docs103/config_wls/web_server.html
String getRequestedSessionId(); ——>javax.servlet.http.HttpServletRequest
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 29th, 2010 on 11:42 pm
Hi Appi,
For WebLogic HttpClusterServlet you can do the following technique to get the DEBUG informations regarding the Http Headers and other things as well….
http://download.oracle.com/docs/cd/E13222_01/wls/docs81/plugins/plugin_params.html
In the “web.xml” of the “proxyApp”….
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
December 30th, 2010 on 9:08 pm
Hey Jay ..
Thanks a lot for your inputs …
I really appreciate that …
Cheers !!!
Appi
March 2nd, 2011 on 1:13 pm
Hi Jay,
How/where to configure the Documentroot ,when we configure weblogic as webserver
thanks
ARun
March 2nd, 2011 on 1:34 pm
Hi Arun,
For WebLogic HttpClusterServlet we do not have any document root parameter like for Apache or any other webservers, if you want to keep anything then has to be kept in the “ProxyWebApp” directory which is for the above post.
March 2nd, 2011 on 5:35 pm
Hi Ravish,
Thanks for your prompt response.
For example suppose say i have index.html in ProxyWebApp & i want that as the mainpage when user enters http://weblogicwebserver:port ,is there any way i can specify?
thanks
Arun
March 2nd, 2011 on 6:40 pm
Hi Arun,
Sorry to say but that cannot be possible, index.html file would be picked up from the application only which is deployed on the cluster and not from the “ProxyWebApp”. However HttpClusterServlet is not recommend to be used on production. To get more details what all parameters can be used with HttpClusterServlet you can go through the below link.
http://download.oracle.com/docs/cd/E13222_01/wls/docs81/plugins/plugin_params.html
March 2nd, 2011 on 8:09 pm
Thanks Ravish, just wanted to know! Great blog keep going
March 4th, 2011 on 5:36 pm
hi Middleware Magic team,
I followed 1st to 5 steps,then deployed my war file MS1 and MS2..add the below line in weblogic.xml in my war file
-persistent-store-type-|replicated|-/persistent-store-type|
for clustering,i have specified the following configuration
cluster address–>hostname:7003,hostname:7004
cluster messaging mode:unicast
server–>ms_7004,ms_7003
Default Load Algorithm –>Round Robin
replication type–>none
Started the FrontEnd_MS(port 7007)and even the war file,
Evertthing fine and active,
Even provided the context root ie /test
Now the problem is wen i hit the url
http://hostname:7007/test
i get this error
Error 403–Forbidden
From RFC 2068 Hypertext Transfer Protocol — HTTP/1.1:
10.4.4 403 Forbidden
its a generic error,searched online resolution for it but neva helped.
Pls help
Thanks in advance
Regards
Fabian
March 4th, 2011 on 11:43 pm
Hi Fabian,
Can you let us know the context root (/test) is for which App the “ProxyWebApp” or for your own application. If its for “ProxyWebApp” then try with http://hostname:7007/test/App where “App” is your application name.
March 5th, 2011 on 7:04 pm
hi Ravish,
Thanks for your quick response
i have specified context root /test for ProxyWebApp
and context root /App for the application which i have deployed in managed servers
i tried accesing from the url
http://hostname:7007/test/App
But again the same problem
i even tried specifying context root”/App” in
“weblogic.xml” file inside “C:DemoProxyWebAppWEB-INF
But still same problem
Thanks in advance
Regards
Fabian
March 5th, 2011 on 7:45 pm
Hi Fabian,
Try with specifying context root as just / for ProxyWebApp and then hit as
http://hostname:7007/App
March 9th, 2011 on 1:07 pm
Hi Jay/Ravish
It’s such a detailed post.Of course, such an informative website.Literally I started learning Weblogic from Begginer’s corner here.Thanks for such a repository.
Coming to this post,I am stuck below.
I have 2 boxes.
Box A: admin server,MS1,Frontend_MS
Box B: MS2
Macine1:MS1,Fronend_MS
Macine2:MS2
MS1,MS2 are in cluster C1
I was able to access my application with all non-ssl ports.
Now,I enabled ssl listen port for all admin server and managed servers including Frontend_MS.But I couldn’t access application through port of Frontend_MS and still I able to access through managed server ports.
I even set the value of SecureProxy as ON in web.xml..Am I missing anywhere else??
Regards,
Karthik
March 9th, 2011 on 5:05 pm
Hi Karthik,
Client would hit on the Frontend_MS address and port, so if you want a secured connection then you just need to enable the SSL port for Fronend_MS.
I tried the same configuration and found the following error in my server log
I am using Sun JDK 1.6.0_21, if you are also using Sun JDK 1.6.0_13 or above then do the following steps to overcome this issue
– Take a backup of the “cacerts” file which can be found in the path (jdk1.6.0_21/jre/lib/security)
– Now what I did is took “cacerts” file from an older updated of Sun JDK 1.6.0_05
– And replaced it with the newer version and restarted my all the server.
After this when I hit on the Frontend_MS using https://IP-ADDRESS:SSL-PORT/App its was work just fine.
Let me know if you need anything on it.
Note: I have not made any changes in the application or any xml files other then the enabling the SSL port of the Frontend_MS server.
March 13th, 2011 on 1:45 pm
Hi Ravish,
It was a busy week so,I couldn’t reply immediately…As I said I gave value for SecureProxy as ON in web.xml file of ProxyWebApp,I realised i didn’t redeploy the application.:-P….now I tried my luck re-deploying the ProxyWebApp and It’s able to redirect requests to managed servers perfectly..
And I am using Jrockit JDK..and even I could see the same error with different notations.As I dont have anyother cacerts file to replace, I didnt try to implement ur suggestion…anyway thanks a lot for a quick response..
— Karthik.
March 30th, 2011 on 1:55 am
Hi,
Its a very informative post.
Thanks
April 7th, 2011 on 5:57 am
Hi Jay,
As usual good post.
==================
Query:
Correct me if i am wrong here.
weblogic.servlet.proxy.HttpClusterServlet has a property named “WebLogicCluster” for which you are assigning a value “localhost:7003|localhost:7005”, Whenever the request comes with match url pattern then the request is getting directed to its value “localhost:7003|localhost:7005”.
Thanks
Sathya
July 26th, 2011 on 9:59 pm
Hi Jay,
How can load balancing be achieved in weblogic? Is this through an apache plugin or can be done within weblogic itself?
Do I need to download a apache plugin for solaris???
August 20th, 2011 on 1:48 pm
Thanks. Its was a good article.
Is there any way by which we could get the server details to which the request was forwarded. When I do getServletName() & getServletPort(), it returns me the details of proxy server. I want managed servers name & port?.
Thanks
August 20th, 2011 on 7:34 pm
Hi Nikhil,
Please write the following JMX Code snippet inside your Application to get the current Server’s Name and Port Details:
=====================
try
{
InitialContext context = new InitialContext();
MBeanServer mbeanServer = (MBeanServer) context.lookup(“java:comp/env/jmx/runtime”);
String runtimeServiceName = “com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean”;
// Create ObjectName for the runtime service
ObjectName runtimeService = new ObjectName(runtimeServiceName);
// Get the ObjectName for the ServerRuntimeMBean
ObjectName serverRuntime = (ObjectName) mbeanServer.getAttribute(runtimeService, “ServerRuntime”);
// Get the listen URL of the server
String server = (String) mbeanServer.getAttribute(serverRuntime, “ListenAddress”);
String port = (String) mbeanServer.getAttribute(serverRuntime, “ListenPort”);
}
catch (Exception e)
{
System.out.println(“Unable to obtain listen address or port. ERROR: ” + e.getMessage());
e.printStackTrace();
}
=====================
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 23rd, 2011 on 10:41 pm
Nice Tutorial. I have couple of questions.
1. Is there any way to disable loadbalancing when using HTTPClusterServlet.
I want the proxy server to only forward request to 1 server. Only when this server is down, it should start fwding it to 2nd server.
.i.e. I have been trying to create an Primary Server to do all the stuff. Only when Primary Server is down, secondary should take over.
August 23rd, 2011 on 11:59 pm
Hi Nick,
HttpClusterServlet is not recommended for Production purpose, Because it has various limitations and very limited features.
There is no direct way / Paramreter available to achieve the same what you asked for ….
But the following 2-Parameters can be set in your HttpClusterServlet inorder to achieve somewhat you wanted to achieve…
1). DynamicServerList: http://download.oracle.com/docs/cd/E13222_01/wls/docs81/plugins/plugin_params.html#1157827
2). WLIOTimeoutSecs: http://download.oracle.com/docs/cd/E13222_01/wls/docs81/plugins/plugin_params.html#1158098
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 28th, 2011 on 11:58 am
HI,
I have a question regarding Cluster. May not be related this post. I know if the cluster address is not right then EJB handling may not work properly.
I have 3 managed servers in a cluster, 2 managed servers have Listen address and port assigned but the 3 rd managed doesn’t have a assigned Listen addres but it runs on different server on different port. When i mention cluster address i have given like managed1:port1,managed2:port2 but it has 3 instances as part of cluster. will this impact EJB lookup ?
if i add managed3:port3 to cluster is that enough or even the manged server 3 should have specific Listen address described in console. ???
I hope i didn’t confused …
-Thanks
kumar
August 28th, 2011 on 7:21 pm
Hi Kumar,
When there is NO Specific Listen Address is defined in the adminConsole for a particular server ….then in that case that server can be accessed only be the address “localhost” (which is default value). So in that case the remote cluster members will not be able to communicate with it. Hence if you want cluster member communication to properly happen then in that case …we must set the “Listen Address” for each and every Managed Server.
The Listen Address value must be either the DNS name or the IP address of the computer that is hosting the server instance. Or as an alternative to admin-console listen address you can also use the JAVA_OPTION -Dweblogic.ListenAddress=host to define the Listen Address of your Server.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 29th, 2011 on 12:21 am
Thanks for the explanation Jay… you rock as always…
-Thanks
kishore
December 22nd, 2011 on 12:12 pm
Thanks Joy for this wonderful solution. Now I have a question… Lets say I have configured 5 managed servers in a cluster and proxing the request through a web server[HttpServerCluster app deployed in it] configured in weblogic. Now what happens for the logging. I have only one file name configured in my log4j.properties. Now if all the servers in my cluster are running, then they all will try to write to the same file. This can make a lot of threads BLOCKED and the count of stucked threads will increase in the Thread pool, if I am not wrong. And also the logs between servers will jumble up one upon another. I have faced the following issue a lot of times in my production :
“[ACTIVE] ExecuteThread: ‘313’ for queue: ‘weblogic.kernel.Default (self-tuning)'” waiting for lock org.apache.log4j.spi.RootLogger@3119cc BLOCKED
So my question is can I divide the logging of the application [deployed in a cluster] into separate files[May be one per server] ?? If I can, please tell me how …
December 22nd, 2011 on 6:54 pm
Hi Supratim,
If you are talking about separating your application level logs then it is quite easily done by putting the log4j.xml or log4j.properties file inside the “WEB-INF/classes” directory of your application.
http://middlewaremagic.com/weblogic/?p=633
NOTE: if many applications will try to write on the same log file then you will definitely get .RootLogger BLOCKED messages and the application will stop OR responding very slow , Because every Logger geins Lock on the log file where it is supposed to write.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
January 6th, 2012 on 5:49 am
Hi Jay,
You are configuring the software loadbalancer in Weblogic server. But which area you configure the “81” port number.Because inside the software load balancer you only pass the hostname and port number for two managed server. But the access url you mentioned the 81 port number ” http://localhost:81/TestWebApp “. Kindly provide which area you configure the 81 port number in softwareload balancer.
Regards,
S.Vinothbabu
January 6th, 2012 on 5:53 am
Hi Jai,
Kindly ignore my previous post. Because i didn’t see the software loadbalancer port number in weblogic console. The software loadbalancer port number is 81 in weblogic server.
Regards,
S.VinothBabu.
February 8th, 2012 on 8:50 am
Hi Jay,
First let me thank you for this excellent site on Weblogic administration and set up.
I have 2 RHEL server. I built each server with following configuration
Admin Server 7001
Managed server 7000 with Httpclusterserverlet deployed
Cluster 7010/7020/7030 – 3 Managed servers
Currently we are using F5 load balancer to balance load between 2 app servers clusters.F5 is configured to use persistent connections, but still app connections get dropped by F5 LB.
What is the best solution to load balance between both physical servers clusters of 3 Managed servers/app server?
Thanks in advance
Sridhar
July 4th, 2012 on 1:27 pm
Hi Jay,
Why is the web logic server not recommended to be a web server and need of apache and others instead? I had gone through the posts above but could not get the potential disadvantages of implementing weblogic as a web server too?
Many thanks for your help in advance!
hari
July 5th, 2012 on 5:07 pm
To set-up the servlet you have to do quite some work: http://docs.oracle.com/cd/E21764_01/web.1111/e13709/setup.htm#CLUST467.
When you want to change the configuration, you have to edit the web.xml file, create a war and deploy it again.
When using a web server such as apache you just have to edit a text file and restart the servers such that changes are activated – which is kind of simpler to administer (and maintain).
Also a web server (such as Apache) has some handy extra’s such as mod_rewrite (http://httpd.apache.org/docs/2.2/) etcetera.
August 4th, 2012 on 6:14 pm
Hi Jay,,
i have two managed server.
managed server 1 : 192.168.1.12:7003 (on host)
managed server 2 : 192.168.1.13:7005 (on VMBOX)
i use httpclusterservlet and set param (192.168.1.12:7003|192.168.1.13:7005) on web.xml
i have deploy aplikasi on that cluster..
what url i supposed fill in browser so failover and load balancing still work??
Regards
December 21st, 2012 on 8:21 pm
I implemented the solution above untill step 5, with my own Web App file; however receiving Error – 404 Page Not Found. Please suggest.
January 25th, 2013 on 7:23 pm
Hi, Thanks for the wonderful information. I have an issue.
I have three weblogic server instance serverA, serverB and serverC. My application is running in ServerB and ServerC and in serverA HttpClusterServlet ProxyServer
is running which redirect serverB and serverC. The problem is, even after ServerA redirect to serverB or serverB, the url in the address bar remain same with serverA’s ip address with port number. My application running in serverB and serverC is having some applets and it needs to refer the URL for some purpose and it supposed to required the url (ipaddress and portno) of the server running my application (i.e serverB or serverC), but as i said url in the address bar is remains with serverA. Is it possible to have the redirected server’s url (ipaddress and port) in the address bar? Please help, its quit urgent.