Skip to main content

[urgent] problem in starting server when the app already deployed

6 replies [Last post]
Anonymous

Hi

We have a problem in starting Glassfish server. When the application is
already deployed and we restart the server, the glassfish stop responding
and seems it gets into a loop!.

to clarify, let me tell you that we are using EJB3 (on Glassfish 9.1) and we
have a ContextListener to initialize our application. this listener will
init some config classes. one of these classes will use InitialContext to
lookup a DAO class. As I traced the logs, I realized that right when the
application is going to lookup the DAO class everything stops !!!

if we remove the application and start the server and then deploy the
application, everything's Ok, but this problem emerge only if we didn't
undeployed the application before restarting.

Should be this a bug in Glassfish?

My guess is that this InitialContext is going to lookup just before all the
EJBs are initialized by the container. if I am right, how to avoid to
initialize my application before initializing the EJBs?

is there any workaround?

thank you very much

-----
--
Regards
Mohammad Norouzi
Help each other to reach the future faster
http://brainable.blogspot.com http://brainable.blogspot.com

--
View this message in context: http://www.nabble.com/-urgent--problem-in-starting-server-when-the-app-a...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
whartung
Offline
Joined: 2003-06-13

Are the WAR and EJBs in the same EAR? Or are they separate?

Have you tried moving the initialization code to a dedicated InitServlet (my term for a dedicated Servlet used only for its init() method combined with using the load-on-startup tag in the web.xml) instead of a Context Listener?

Have you tried a simple test case with nothing more than a Context Listener trying to get something via the InitialContext, just to see if you can isolate it?

This works for me in a load-on-startup servlet, but I agree it's likely in a different part of the container lifecycle. Also, the servlet is not part of the EAR, but a separate WAR (the EAR is deployed on the same server, however). I also have a retry loop there to make sure that if my lookup fails, it sleeps and gives it a couple of more chances -- thought to be frank I'm not sure I actually still need that part.

If practical, I would take a stab at using an InitServlet and see if that can work around the problem for you.

Sorry this is coming almost 20hrs later than your post, but what can you do.

Good luck, and do let us know what you find out one way or the other. If this does NOT work, no doubt someone better versed in this area than me will want a thread dump (or two), so you may want to get some of those going as well.

is_maximum

Hi
Thanks
Yes the WAR and EJBs are in the same EAR file

I thought when the lookup method is being called the server get into a loop
and yes I've just found that after nearly half an hour, that lookup method
is throwing some exception that complains cannot find SerialInitialContext
or so.

I also tried to suspend the current thread in order to give the EJBs the
opportunity to be loaded completely, but this workaround didn't work. I
don't know why.

However, I am reluctant using init Servlet but I will try it out and will
give you the result.

-----
--
Regards

Mohammad Norouzi

Help each other to reach the future faster

http://pixelshot.wordpress.com Pixelshot Photoblog

http://brainable.blogspot.com Brainable Blog

--
View this message in context: http://www.nabble.com/-urgent--problem-in-starting-server-when-the-app-a...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

whartung
Offline
Joined: 2003-06-13

It may simply be a conflict with the initializing thread, so suspending/sleeping may not help. You might also try spawning a new thread to do that initialization, and let that sleep instead.

Just be careful of other dependencies that may try to use whatever you're setting up when they're not quite ready yet.

is_maximum

How to do spawning? And I can't understand why suspending thread does not
work.
I believe they should consider a @Startup annotation or something like that
to put on an EJB to be initialized automatically when all the EJBs are
loaded successfully.

-----
--
Regards

Mohammad Norouzi

Help each other to reach the future faster

http://pixelshot.wordpress.com Pixelshot Photoblog

http://brainable.blogspot.com Brainable Blog

--
View this message in context: http://www.nabble.com/-urgent--problem-in-starting-server-when-the-app-a...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

whartung
Offline
Joined: 2003-06-13

I know that they're looking at lifecycle issues in the next version of EJB, but I don't know the details.

Spawning would be creating a new thread to run your initialization rather than relying on the current thread. The problem with suspending the current thread is that there may well be something that the current thread is blocking that is causing this deadlock -- so suspending the thread just lengthens the dead lock, it doesn't resolve it.

By spawning a new thread, the current thread can continue and, ideally, release whatever it is that may be causing the hang up, while the new thread continues trying to initialize the resource, and even perhaps retrying should it run in to errors.

The downside is that you are no longer assured that once your ContextListener has exited, everything is initialized -- the new thread may very well still be running and waiting on resources.

So, it's definitely a nasty problem, and fixing one race condition with perhaps another isn't really the best way to solve things. But it may actually work.

is_maximum

Hello
Thank you very much, that worked fine :)
In my context listener I create a thread and put all the initializing
processes in the run() method, and set a name for that thread.
then, in my own locator I checked if this thread is the same thread coming
from context listener then suspend that thread for nearly 20 seconds, to let
the EJBs be loaded.

it worked fine, thanks again

-----
--
Regards

Mohammad Norouzi

Help each other to reach the future faster

http://pixelshot.wordpress.com Pixelshot Photoblog

http://brainable.blogspot.com Brainable Blog

--
View this message in context: http://www.nabble.com/-urgent--problem-in-starting-server-when-the-app-a...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net