Hi,
In response to comment posted regarding tunning of EJB3 app: http://middlewaremagic.com/weblogic/?p=1696#comment-1356
Here is a Simple Demonstration of Changing the Tunable Parameters of an EJB3.0 application using “Plan.xml”. As we have many annotations available as part of EJB3.0 Specifications But we dont have the Annotations available for many Tunable parameters like “max-beans-in-free-pool”, “initial-beans-in-free-pool”…etc. If we want to change/add these values for our EJB3.0/EJB2.x Application then we have have to change provide our own “weblogic-ejb-jar.xml” file.
But In Most of the production scenarios The WebLogic Administrator doesnt have priviledge to change any thing inside the EJB jar module. So in that case A WebLogic AdminiStartor can use the “Plan.xml” file to change these Tunable Parameters Settings…
Step1). Create a Directory somewhere in your file system.
Example: C:EJB3_Plan_XML_Demo
Step2). Create a Directory “EJB3App” inside Directory “C:EJB3_Plan_XML_Demo”
Step3). Provide the EJB3 Business Interface “CalculatorRemote.java” inside “C:EJB3_Plan_XML_DemoEJB3App”
package calculator; import javax.ejb.*; @Remote public interface CalculatorRemote { public int add(int x,int y); public int sub(int x,int y); public int mult(int x,int y); public int div(int x,int y); }
Step4). Provide the EJB3 Stateless Bean Implementation class “CalculatorBean.java” inside “C:EJB3_Plan_XML_DemoEJB3App”
package calculator; import javax.ejb.*; @Stateless public class CalculatorBean implements CalculatorRemote { public int add(int x,int y) { return (x+y); } public int sub(int x,int y) { return(x-y); } public int mult(int x,int y) { return (x*y); } public int div(int x,int y) { return (x/y); } }
Step5). Now Create a directory “META-INF” inside “C:EJB3_Plan_XML_DemoEJB3App” and then provide an Empty “weblogic-ejb-jar.xml” file as following:
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd"> </weblogic-ejb-jar>
NOTE: Step5 is the Most important Step because if we want to override setting of any descriptor then at least that file must exist inside our application….doesn’t matter if it is Empty or having some contents inside it.
Step6). Now a command prompt and the run the “setWLSEnv.cmd” and then Compile the above two ejb stuffs.
Step7). Write the “build.xml” file to deploy your Application…inside “C:EJB3_Plan_XML_Demo” like following:
<project name="webservices-hello_world" default="deploy"> <!-- set global properties for this build --> <property name="wls.username" value="weblogic" /> <property name="wls.password" value="weblogic" /> <property name="wls.hostname" value="localhost" /> <property name="wls.port" value="7001? /> <property name="wls.server.name" value="AdminServer" /> <target name="deploy"> <wldeploy action="deploy" name="EJB3App" source="EJB3App" user="${wls.username}" password="${wls.password}" verbose="true" adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" /> </target> <target name="undeploy"> <wldeploy action="undeploy" name="EJB3App" failonerror="false" user="${wls.username}" password="${wls.password}" verbose="true" adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" /> </target> </project>
Step8). Now open a Command prompt and then run “setWLSEnv.cmd” then run the above ant “build.xml” file to deploy your application:
Step9). Now Login to Admin Consoel to see how many initial beans have been created for our EJB3App.
Step10). Now Provide the “plan.xml” file inside “C:EJB3_Plan_XML_Demo” location as following to change the “initial-bean-in-free-pool” setting for our EJB3App…
<?xml version=’1.0' encoding=’UTF-8'?> <deployment-plan xmlns="http://www.bea.com/ns/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/deployment-plan http://www.bea.com/ns/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false"> <application-name>EJB3App</application-name> <variable-definition> <variable> <name>initialPoolVariable</name> <value>15</value> </variable> </variable-definition> <module-override> <module-name>EJB3App</module-name> <module-type>ejb</module-type> <module-descriptor external="true"> <root-element>weblogic-ejb-jar</root-element> <uri>META-INF/weblogic-ejb-jar.xml</uri> <variable-assignment> <name>initialPoolVariable</name> <xpath>/weblogic-ejb-jar/weblogic-enterprise-bean/[ejb-name="CalculatorBean"]/stateless-session-descriptor/pool/initial-beans-in-free-pool</xpath> </variable-assignment> </module-descriptor> </module-override> <config-root>C:EJB3_Plan_XML_Demo</config-root> </deployment-plan>
Step11). provide the “build_with_plan.xml” file inside “C:EJB3_Plan_XML_Demo” to redepoy the application with the settings provided as part of our “plan.xml” file. Like following :
Step12). Now again Login to AdminConsole and then see the Monitoring Tab of your EJB3App … like following:
.
.
Thanks
Jay SenSharma
August 31st, 2011 on 2:20 am
Hi Jay,
Thanks for the Post really informative.
I have one issue currently i am seeing.
During the high loads (approx equal to the double of normal)
we are seeing the following errors related to jdbc in weblogic logs and w
e are having a kind of outage for few mins.
connection pool setting are
min :- 20 and max :- 175.
Can you shed any light on this.
Error:-
<Stack trace associated with message 001129 follows:
java.sql.SQLRecoverableException: Io exception: The Network Adapter could not establish the connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:101)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:458)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:490)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:202)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:474)
at weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(ConnectionEnvFactory.java:316)
at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:217)
at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1109)
at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1033)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResourceInternal(ResourcePoolImpl.java:379)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:302)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:427)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:316)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:61)
at weblogic.jdbc.jts.Driver.newConnection(Driver.java:902)
at weblogic.jdbc.jts.Driver.createLocalConnection(Driver.java:321)
at weblogic.jdbc.jts.Driver.connect(Driver.java:166)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:338)
at org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource.getConnection(AbstractRoutingDataSource.java:133)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:935)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
>
——————————————————————————————————————–
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [
0]; weblogic.common.resourcepool.ResourceDeadException: 0:weblogic.common.ResourceException: Could not create pool connection. The DBMS driver exception was: Io exception: Socket
read timed out; nested exception is weblogic.jdbc.extensions.ConnectionDeadSQLException: weblogic.common.resourcepool.ResourceDeadException: 0:weblogic.common.ResourceException: C
ould not create pool connection. The DBMS driver exception was: Io exception: Socket read timed out
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:102)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:293)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110)
at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:139)
at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:217)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.hbo.it.go.commons.web.ResponseHeaderFilter.doFilter(ResponseHeaderFilter.java:38)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
September 1st, 2011 on 6:09 pm
Can you check in your database to see how fast session (connections) are finished processing.
Note that the connection pool and the load must be in balance with one another. When the connection is not returned to the pool within a certain amount of time the threads start to build-up in the execute queue. In order to overcome this problem you can use work managers and set a maximum thread constraint which is equal to the number of connections in the connection pool.
In your case it looks like the database was out of order “Could not create pool connection. The DBMS driver exception was: Io exception: Socket”. What you can try to do is set the ‘Test Connections On Reserve’ on the connection pool, which enables the option to first check the connection before it is given to the application. It could be that somehow a certain connection becomes stale, with this option enable such a connection is thrown out of the connection and when it is needed again the connection is created again.
August 1st, 2013 on 12:16 pm
I do have one more question regarding this.
run time statistics can be exactly viewed only by this URL http://hostname:portNo/contextPath/servletPath/pathInfo_WebLogicBridgeConfig
can’t we View this by main LB URL(VIP URL) , instead of hostname and port ..?
because when i access main url like http://google.com/contextPath/servletPath/pathInfo_WebLogicBridgeConfig
it returns only one weblogic server in list, but if i access individual apache server URL and port number it retruns exact list..
I check all apaches in farm,, every thing returns good and correct result, but if i access LLB url not giving proper response.
Is this any where related to weblogic proxy-plugin enable parameter in weblogic ?.
Thanks