Hi,
Many times we see that our applications MDBs are getting started before the Application Server’s all resource activation, Which causes many resource lookups which our MDB does while activating itself… So Please specify in your “weblogic-application.xml” file witht the following Tag:
<start-mdbs-with-application>false</start-mdbs-with-application>
By default, an MDB starts processing messages as soon as it is deployed, even if its target WebLogic Server instance has not completed booting. This can cause an MDB application to access uninitialized services or applications during the boot process, and to fail. To avoid this problem, set start-mdbs-with-application to false in weblogic-application.xml.
Setting start-mdbs-with-application to false forces MDBs to defer starting until after the server instance opens its listen port, near the end of the server boot up process.
Example:
<strong><ejb></strong> <strong><start-mdbs-with-application>false</start-mdbs-with-application></strong> <strong></ejb></strong>
———————————-
If you DONOT have any option to change/Edit your “weblogic-application.xml” file then …
If you want to perform startup tasks after JMS and JDBC services are available, but before applications and modules have been activated, you can select the Run Before Application Deployments option in the Administration Console (or set the StartupClassMBean’s LoadBeforeAppActivation attribute to “true”).
If you want to perform startup tasks before JMS and JDBC services are available, you can select the Run Before Application Activations option in the Administration Console (or set the StartupClassMBean’s LoadBeforeAppDeployments attribute to “true”).
.
.
Thanks
Jay SenSharma
August 20th, 2010 on 3:53 pm
Jay,
I am getting I am getting NameNotFoundException while trying to look up timer from startup class. The timer configured in ejb-jar.xml.
I already posted this in oracle forum :
http://forums.oracle.com/forums/thread.jspa?threadID=1117546&tstart=0
August 20th, 2010 on 3:54 pm
Could you please help out on this issue?
August 20th, 2010 on 3:57 pm
Hi Podile,
I have updated the http://forums.oracle.com/forums/thread.jspa?threadID=1117546&tstart=0 Thread. Not sure it will work for you or not. But you can give it a try.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 20th, 2010 on 4:15 pm
Hi Podile,
If you want to make sure that your Startup class should be able to lookup the TimerManager successfully …then you can set the Deployment Order for your MDB Application Higher than the Deployment Order of your Startup class.
If you want to perform startup tasks after JMS and JDBC services are available, but before applications and modules have been activated, you can select the Run Before Application Deployments option in the Administration Console (or set the StartupClassMBean’s LoadBeforeAppActivation attribute to “true”).
If you want to perform startup tasks before JMS and JDBC services are available, you can select the Run Before Application Activations option in the Administration Console (or set the StartupClassMBean’s LoadBeforeAppDeployments attribute to “true”).
Please refer to “http://download.oracle.com/docs/cd/E15051_01/wls/docs103/deployment/managing.html#wp1014261”
. (Ordering Startup Class Execution and Deployment )
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 20th, 2010 on 5:04 pm
Jay,
Thaks for your valuble information. I tried as you suggested!!! But NO luck :). Still I am getting the issue.
I am using a class implements ApplicationLifecycleListener to listen my application.
I have overriden the methods preStart(), postStart(), preStop() and postStop() methods.
in weblogic-application.xml I have given the entry
my.examples.mdb.timer.TestApplicationListener
August 20th, 2010 on 5:05 pm
/my.examples.mdb.timer.TestApplicationListener/
August 20th, 2010 on 5:06 pm
(means listener-class=my.examples.mdb.timer.TestApplicationListener)
August 20th, 2010 on 5:10 pm
also (start-mdbs-with-application = false) as you suggested
If I try to look-up from postStart() method then it is giving NameNotFoundException
The same exception is giving in preStop() method.
If it is problem with initialization; I think, it should not give problem with preStop() method. (Correct me if I am wrong)
August 20th, 2010 on 5:13 pm
If I try to lookup onMessage() method of my MDB, It is not giving any problem. I didn’t understand the reason why it is happening.
Note: All the life cycle methods (preStart(), postStart(), preStop() and postStop() ) are getting executed when I start/stop/redeploy my application from console.
August 20th, 2010 on 5:28 pm
Added more clear description to the problem at http://forums.oracle.com/forums/thread.jspa?messageID=4517130#4517130
August 20th, 2010 on 8:54 pm
Hi Podie,
I Have tested your program as your have posted in the forums. And I got the same error NameNotFoundException . After debugging some more on this I found that Until the ApplicationLifecycleListener’s preStart)( as well as postStart() method executes successfully the EJB Module doesnt actually gets activated …thats why the <resource-ref> which we have specified in the “ejb-jar.xml” file doesn’t gets nvoked so till that time There is no such Timer available on the Server so we are getting NameNotFoundException.
If somehow we can do lookup for “timer/MyDefaultTimer” after the preStart() and postStart() method gets executed successfully then we dont see any issue.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 24th, 2010 on 10:44 am
Jay,
Thank you for your research on this issue. Actually we have to initialize some jobs along with the applications active state. So we planned to use common.timers.TimerManager, but we are not able to lookup it along with app’s active state, So we are using java.util.Timer and controling in ApplicationLifecycleListener.
Thanks again for your research on this issue :).
August 28th, 2010 on 4:02 am
Hi Jay,
Regarding the element “start-mdbs-with-application” = false in the weblogic-application.xml. Been using it (wls10.3.0 – 10.3.3), but the MDB’s still try to process all the messages in the persistent queue (filestore) before the server is properly initialize. Thereby causing alot of exceptions to be thrown. The only way to avoid this is to delete all the messages in the queue. Do you have any suggestions why it’s not working in my end. Below is the weblogic-application.xml I’m using in wls 10.3.3 (11gR1):
— Thanks
false
August 29th, 2010 on 12:07 am
Hi Junv,
Please refer to: http://middlewaremagic.com/weblogic/2010/08/20/mdb-starting-before-the-server-resource-activation/#comment-1662…Ravish has updated some pointers.
.
.
Keep Posting 🙂
Thanks
Jay SenSharma
August 28th, 2010 on 4:04 am
Sorry about that. Here’s my weblogic-application.xml
(replace GT& LT with “[]”)
[?xml version=’1.0′ encoding=’UTF-8′?]
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd"%5D
[ejb]
[start-mdbs-with-application]false[/start-mdbs-with-application]
[/ejb]
[/weblogic-application]
August 29th, 2010 on 12:00 am
Hi junv,
From the link below (i.e. Oracle link for WLS-11g) it states that
“Set to false to defer message processing until after WebLogic Server opens its listen port.”
Search for: start-mdbs-with-application
Link-1 http://download.oracle.com/docs/cd/E15523_01/web.1111/e15493/summary.htm
# Conclusion:
This means that “false” should have resolved your issue but it is not so this might be a bug. Similar bug was seen in WLS-9.2 version which was fixed in WLS-9.2 Mp-1 version check out the link below.
Search for: CR293982 or CR299012
Link-2 http://download.oracle.com/docs/cd/E13222_01/wls/docs92/issues/known_resolved.html
However if it was fixed in WLS 9.2 Mp-1 then the same issue is most probably taken care in WLS 10.x.x version also.
# Suggestion:
– Try to set “start-mdbs-with-application” as “true” and check if that works for you.
This is because if you read the “Link-1” carefully it states that “With default setting of true”, however when you check the “Default” column it shows “false”. Hence cant say which one is default. It might be document bug as well.
# How to solve this issue:
1) Create a simple test case to prove that “start-mdbs-with-application” when set as “false” does not work.
2) Open a ticket with Oracle and provide all the details with the test case and let them do their job.
Keep Posting 🙂
Thanks
Ravish Mody