cancel
Showing results for 
Search instead for 
Did you mean: 

execute java code when server starts?

Former Member
0 Kudos

Hi Folks,

Does anyone of a way to execute a java code when a server

starts (something similar to a "startup" class or a

"custom service"?

TIA

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Blair,

There has been no activity on this thread for a long time.Did you find any solution to your problem?

Former Member
0 Kudos

Hi,

if you have KMC activated in your portal, you can create a Repository Service. There you have a method witch defines the actions when the service is started. Also you can customize the actions, if the service is stopped.

Regards,

Gerhard

detlev_beutner
Active Contributor
0 Kudos

Hi Gerhard,

even if I am sceptical if this "solution" is wanted (it sounds more like an application independent question) a repository service is definitely "too much"; a "standard" portal service with <i><property name="startup" value="true"/></i> within <service-config> would do it, too (also with the possibility to react on "shutdown" (stopping service)).

Best regards

Detlev

Former Member
0 Kudos

Could you please specify your requirement for this? It might help people to understand what you are trying to achieve with this and how this is normally dealt with.

Cheers,

Kalle

Former Member
0 Kudos

There are a couple of things i was thinking about:

1. caching information when server starts instead of

having users taking the him, a class will execute

the cache reload when the server starts.

2. having some sort of a timer that is activated when

the server starts and does certain operations every

x hours independently from the application work

3. some applications need some sort of a reset that

happens once when the server starts, a startup class

will enable me to do that.

The idea here is that it is an independent java code that does not have

an interface to the outside world, it operates by itself.

Weblogic has “startup class” WebSphere has “custom service”, I was wondering if we have something similar, if I need to migrate an application I will need a similar mechanism.

TIA

Former Member
0 Kudos

Hi,

It is possible through Portal.But can we achieve the same thing through WAS server only where portal not coming in picture.

Can we made such service or J2ee application and deploy on WAS server which has such startup property?

Regards,

Bhavik

Former Member
0 Kudos

Hi guys,

custom services development is not supported on Web AS (see SAP Note 822542).

Regards,

Ivo

Former Member
0 Kudos

I've been looking at just this issue - I have an applicatiojn that has a public API that allows you to be notified of remote events. Communication is via sockets. The API itself knows nothing about EJB.

I have been unable to make a Portal service receive events - the service loads ok (log messages confirm this) but the callback is never invoked. A standalone Java program that also registers a callback does receive the message.

The callback is an anonymous class, but I'm not real confident that this will work in a J2E container, since under the covers it must use threading on the backend to be able to receive events over the socket. Based on the J2EE standards we're not supposed to create threads inside the engine - I'm not sure what'll happen if we do...

My only other alternative is to have a standalone java program register a listener, and post the messages to a MDB running inside the container. This sucks, since it means there's an additional moving part in the entire system, not to mention that you'll have to remember to start the bridge service to get events.

Someone out there must have done something like this....anyone?

Former Member
0 Kudos

Hi, I know this is late but I am tired of seeing posts without answers on this forum.

Why not a servlet that has the "startup" code in the init() method and set the servlet to start when the server starts via <load-on-startup>1</load-on-startup>.

This is what most folks do when we need to run code to "reset" an app or spawn a timer/cron process. EJB 3.0 will have timers that will replace this but that won't be available for a LONG TIME!

Hope this helps,

B

Former Member
0 Kudos

You can make j2ee sap service (similar to portal service):

http://help.sap.com/saphelp_webas630/helpdata/en/14/8e633e0084e946e10000000a114084/frameset.htm

Message was edited by: Denis Lapanik