cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Scheduled Task

Former Member
0 Kudos
234

I've been over this it seems a 1000 times but I have to be missing something. I'm going to lay it out in what I hope to be enough detail so someone can tell me where things are going wrong.

Environment:

- Target platform - EP6.0 SP2

- SAP Developer Studio 2.0.11

Goal:

Create a custom task that can be run via the KM Scheduler that has access to portal specific information (users, etc).

Current Process:

- Follow Prakash Singh's article on creating a KM scheduled task () (create a portal app project, and use the Service, Filter, and Task generation wizard specifying EP6SP2)

- Before deploying the PAR, copy the 'local' folder under src.config to the same location but rename 'install'. (this keeps the PAR from erroring during building. Will get 'Cannot create config archive (you should have a valid data or meta folder)' error if I dont). <- I suspect that this step may be part of my issue.

- PAR deploys fine, will see a JDBC error (null pointer exception in the JDBC driver) in the log upon first deployment, (Strange since I'm not using JDBC here) but does not seem to affect the application. Possibly related to Hot Deployment issues of scheduled tasks ( and )

when the server restarts the application loads OK.

- Task shows in KM Scheduler, and can configure schedule OK but no execution. No mention in the logs even with System.out statements. Its as if the task is not being executed at all. Even if I deliberately put in an error (div/0) I will not see anything in the console logs.

I have been through the component monitor and it seems that everything is running fine but the scheduled tasks do not execute.

JDBC Error in detail:

Loading application: ScheduledTestTask8

Loading services:

Loading service: ScheduledTestTask8|RFServiceWrapper

java.lang.NullPointerException

at com.sapportals.wcm.repository.service.eventlog.jdbc.JDBCConnection.log(JDBCConnection.java:129)

at com.sapportals.wcm.repository.service.eventlog.jdbc.EventLoggerThread.run(EventLoggerThread.java:74)

com.sapportals.wcm.service.applog.AppLogException: [SAP_Portals][SQLServer JDBC Driver][SQLServer]

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Curt,

first, welcome on SDN!

About your question:

Generally, I wouldn't advise to use NWDS to create config archives for SP2, even if this should be possible by theory; anyhow, if the Scheduler Task appears after deployment, this might have worked. But maybe not completely, who knows...

Instead of deploying the config archive, you can also add all entries manually into the configuration. Try this.

If it doesn't work, and if you haven't done this already, strip down your implementation to an absolute minimum (let's say schedule a single line, logging for example). Check if the RFWrapper Service get called correctly.

If all this won't do it, you can mail me the project; it's hard to check everything offline. But it may take some days until I have the possibility to go through it.

Hope it helps

Detlev

Former Member
0 Kudos

Detlev -

Thank you for your greetings and response.

By the sounds of it, I need a bit more education on the topic of Config Archives and the RFWrapper Service. Unfortunately NWDS is the only tool I have at the moment, and would be open to other suggestions since the plug-ins for eclipse are no longer available.

I did a search on config archive and scheduler and turned up Thilo Brandt's presentation 'CM Component Development for EP6.0' (https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/kmc/cm component development with ep 6.0.pdf)

This presentation answered some of my lingering questions about this type of development and answered my question as to why that directory copy was needed. Every thing seems to have checked out except that I had some xml files in install but not local. Simple copy took care of that.

Here's what my configArchive.properties looks like:

  1. com.sap.portal.pdk.srv.config

ca.name=ScheduledTestTask8.prjconfig

ca.version=6.0.1.1

ca.creation.time=0923

ca.creation.date=20050927

ca.creation.user=unknown

ca.creation.machine=unknown

ca.dependencies: bc.util.prjconfig, bc.sf.prjconfig, bc.sf.service.prjconfig, bc.rf.prjconfig

cma.name=ScheduledTestTask8.prjconfig

cma.version=6.0.1.1

cma.storage=sfs

cma.creation.time=0923

cma.creation.date=20050927

cma.creation.user=unknown

cma.creation.machine=unknown

cma.dependencies: bc.util.prjconfig, bc.sf.prjconfig, bc.sf.service.prjconfig, bc.rf.prjconfig

This seems to be in line with what was highlighted as important in Thilo's presentation.

Additional Notes:

The CrtClassLoader in the RFServiceWrapper checks out. Except the RFServiceWrapper is only in src.api. Thilo's presentation hints that it needs to be in both places.

The portalapp.xml file seems to check out.

I will do some more digging and see what else I can find.

detlev_beutner
Active Contributor
0 Kudos

Hi Curt,

> Unfortunately NWDS is the only tool I have at the

> moment, and would be open to other suggestions since

> the plug-ins for eclipse are no longer available

Two answers:

a) For you may switch to NW in the future, it may be quite senseful to stay at NWDS, if NWDS isn't the source of your problem at the moment (which is not quite clear until now).

b) The Eclipse plugins <i>are</i> still available, they come with the PDK. Be aware that the KM plugins are in fact <i>two</i>, but only one is offered for download from the PDK (if this hasn't changed meanwhile). The second plugin must be gathered directly from the installation.

> Except the RFServiceWrapper is only in src.api.

> Thilo's presentation hints

> that it needs to be in both places.

No, the slides show the service interface set into the public part, the service implementation within the private part.

If you have the implementation in the public part, you will also have to set the implementation class of the scheduler, which is mapped within the configuration, into the public part.

Hope it helps

Detlev

Former Member
0 Kudos

Detlev -

Definitely Helps. After reading your post I was thinking that the RFServiceWraper might be the issue. I did some more searching and came across another of Thilo's presentations, Java Development with the KMC Platform (https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars/Java%20Development%20with%20the%20KMC%20Platform.pdf)

I really wish I could hear the audio from these presentations since they both seem to be talking around the areas that I have messed up.

Anyway, one of the points in this presentation is that the Service Key must be defined. I looked in my interface IRFServiceWrapper and indeed, it was stubbed out but not defined. I corrected that.

I also went through all the RFServiceWraper and put in outputs to make sure things are getting called. Here is my interface and wrapper classes:

package com.sap.netweaver.rf.wrapper;
 
import com.sapportals.portal.prt.service.IService;

public interface IRFServiceWrapper extends IService{
    public static final String KEY = "ScheduledTestTask8.SchedulerService";
}

package com.sap.netweaver.rf.wrapper; 

import com.sapportals.portal.prt.service.IServiceContext;
import com.sapportals.portal.prt.service.IServiceConfiguration;
import com.sapportals.portal.prt.service.IService;
import com.sapportals.wcm.crt.CrtClassLoaderRegistry;

public class RFServiceWrapper implements IRFServiceWrapper{

 private IServiceContext mm_serviceContext;

 /**
 * Generic init method of the service. Will be called by the portal runtime. 
 * @param serviceContext
 */
 public void init(IServiceContext serviceContext){
 	
 	System.out.println("ScheduledTestTask8:RFServiceWrapper - Init ");
  mm_serviceContext = serviceContext;
  CrtClassLoaderRegistry.addClassLoader(this.getKey(), this.getClass().getClassLoader());
 }

 /**
 * This method is called after all services in the portal runtime have already been initialized.
 */
 public void afterInit(){
	System.out.println("ScheduledTestTask8:RFServiceWrapper - AfterInit ");
 }

 /**
 * configure the service : @param configuration
 */
 public void configure(IServiceConfiguration configuration){
	System.out.println("ScheduledTestTask8:RFServiceWrapper - Config ");
 }

 /**
 * This method is called by the portal runtime when the service is destroyed.
 */
 public void destroy(){
	System.out.println("ScheduledTestTask8:RFServiceWrapper - Destroy ");
 }

 /**
 * This method is called by the portal runtime when the service is released.
 */
 public void release(){
	System.out.println("ScheduledTestTask8:RFServiceWrapper - Release ");
 }

 /**
 * @return the context of the service, which was previously set by the portal runtime
 */
 public IServiceContext getContext(){
	System.out.println("ScheduledTestTask8:RFServiceWrapper - getContext ");
  return mm_serviceContext;
 }

 /**
 * This method should return a string that is unique to this service amongst all
 * other services deployed in the portal runtime. 
 * @return a unique key of the service
 */
 public String getKey(){
	System.out.println("ScheduledTestTask8:RFServiceWrapper - getKey: " + KEY);
  return KEY;
 }
}

I was able to verfiy that init and after init are being called. The logs show that both the application and the service are loading just fine.

from the error log:

...

Loading application: ScheduledTestTask8

...

Loading services:

Loading service: GeneralScheduleTest|RFServiceWrapper

Loading service: ScheduledTestTask8|RFServiceWrapper

Loading service: com.sap.km.application|default

from the output log:

...

ScheduledTestTask8:RFServiceWrapper - Init

ScheduledTestTask8:RFServiceWrapper - getKey: ScheduledTestTask8.SchedulerService

The initialization of the KnowledgeManagement finished.

Entered RTCConfiguration

...

D:\usr\sap\DEV2\j2ee\j2ee_00\cluster\server\services\servlet_jsp\work\jspTemp\irj\root\WEB-INF\portal\portalapps\com.sap.workflow.apps\properties\Workflow.properties sucessfully loaded

ScheduledTestTask8:RFServiceWrapper - AfterInit

Successfully initialized logging based on the configuration file

So it appears that the RFServiceWrapper is loading propery (at least as far as my limited knowledge can determine). But even after setting the Service Key its still not being executed. I'm begining to think that I'm too thick to be able to get this to work. Just call me Thicky McThick.

detlev_beutner
Active Contributor
0 Kudos

Hi Curt,

with the output it is clear that the wrapper works. All the wrapper does is to add the application's classloader to the KM classloader registry, so that classes that are given within the configuration are dynamically loadable. This in your case will work now, definitely.

I have just tested a mini example, created with NWDS, deployed on SP2:

a) Use wizard, set KEY in Wrapper Interface, rename config folder from "local" to install", add <i>System.out.println("Ere I am");</i> within the <i>run</i> method of the SchedulerTask implementation

b) Deploy.

c) Go to ... -- Configuration -- Content Management -- Global Services -- Scheduler Tasks -- <yourSchedTask> -- Edit -- Choose CM system(s) to run on -- Choose Scheduler Times (for testing purposes, choose them all).

d) Get a cup of coffee and a cake

e) Open \usr\sap\<ID>\j2ee\j2ee_00\cluster\server\managers\console_logs\<last output.log> and find some "Ere I am" lines...

Really, pretty straight forward, takes 5 minutes.

Hope it helps

Detlev

Former Member
0 Kudos

Detlev -

I know its not rocket science and that’s what’s driving me to clownsville with this. It shouldn’t be this hard.

I after reading your last post, I thought I had a smack the forehead that’s it moment with the setting of the CM Systems, but even after setting those, still no Joy. Did what you suggested and built new mini examples and deployed em (with configuring the CM system) and still no love. I'm now back to my original suspect that the scheduler service isn’t running, however looking at the Monitoring section, it appears to be.

Can you email me your mini sample and I'll see if I can get it to run on our system and I'll send you the latest sample I just created.

Thanks again for all your assistance with this.

Former Member
0 Kudos

Ok I think I may have finally found the right track. I was reviewing the services through the monitor (Monitoring - Component Monitor). I verified that the TaskService is indeed reporting green, however I do not see SchedulerService. Looking at the Crawler task, it is in the read because it is reporting ' Configuration Error: CrawlerService: required scheduler service SchedulerService missing! '

Going through Configuration - ContentManagement - Global Services, under Classes, I found Scheduler Service. This claims to be 'active' (check marked).

Searching SDN I cant seem to find anything on administrating or trouble shooting this service. I guess its time for an OSS note.

Former Member
0 Kudos

Ok, I've narrowed it down to the SchedulerService Task. I have gotten the test tasks to run in our secondary testing environment. Now I just have to figure out why our SchedulingService task is not starting correctly in our dev environment.

Answers (0)