cancel
Showing results for 
Search instead for 
Did you mean: 

Java application to act as background job on SAP J2EE server

Former Member
0 Kudos

Hi Folks,

I have a java class(assume, ClassA) in a DC. This class has a method to call a Web Service.

I have to create one more DC, which contains my Java application.

This application should make calls to ClassA's method after every 15 minutes.

I guess I will have to create a servlet for this. Also, I think I can use java.util.Timer for making the regular calls.

Can you please suggest me the ways to proceed on this?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Checkout Quartz Scheduler. It is open source and widely used.

Former Member
0 Kudos

Thanks, Frank and sorry for late update.

I have to use Servlets and Thread. Even though, Quartz seems a better solution.

Any points that I should keep in mind while going this way???

Thanks,

Swapnil.

Former Member
0 Kudos

Hi Swapnil,

First of all Quartz works very well on Netweaver and offers you a very stable scheduling environment.

It is also very easy to monitor planned jobs and schedules during runtime.

What you really have to care about in my eyes is, how you schedule jobs in a cluster environment.

I think most productive Netweaver Installations are clusters.

You may have situations, vere a job may run on all cluster nodes whereas other jobs should run only once probably on a special node.

This can become a bit tricky. Hovever this issue is not Quartz related. Yuo might have considered this allready for your existing solution.

Cheers

Frank

Former Member
0 Kudos

Thanks, Frank.

Yes, we too have a cluster environment. In our case, this scheduler has to run only on one server node.

As per the technical requirements, I went ahead with a Servlet application.

The scheduler is running fine, except one problem.

I need to call an EJB method deployed on the same server.

Below is the code snippet.

InitialContext ctx = new InitialContext();

MyEjbLocalHome objLocalHome = (MyEjbLocalHome) ctx.lookup("localejbs/my.com/abc~myearDC/MyEjbBean");

I am getting ClassCastException at the above line.

I am sure that the local home interface is correct and belongs to the same EJB.

Can you please help me with this?

Former Member
0 Kudos

Hi,

This issue is mostly deployment related. I would need to know some more details about how you structured your application in terms of deployment packages.

Is your servlet packaged in an EAR or just in a WAR ?

I would expect that you are using an EAR for your servlet and that you have defined a refrerence to another EAR holding your EJBs ?

If this is true the servlet EAR should contain a jar that contains the EJB local interfaces. (please check)

Now here is the issue:

If you have deployed your servlet EAR and just have called it, the class loader would have loaded the version of the EJB classes that are contained in your servlet EAR (!).

If you now change the EJB and deploy it. The class loader still holds the older version. That causes a class cast exception.

The solution for this is to just redeploy the servlet EAR.

I hope this helps.

Former Member
0 Kudos

Thanks, Frank. Your solution did the trick.

Sorry for being so late to reply

Former Member
0 Kudos

Thanks, Christian, for the informative links.

Answers (1)

Answers (1)

Former Member
0 Kudos

As was mentioned [here|/thread/1972726 [original link is broken];, depending on the version of your Netweaver installation, you could use this functionality: [Scheduler Article|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/90a95132-8785-2b10-bda5-90d82a76431e].