cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Portal service

Former Member
0 Kudos

Hi,

I wrote a portal service which will need to execute some business logic at a specified time eg at the end of the month. I wrote the follwing code to do that.

public class SchedulerService implements ISchedulerService{

private IServiceContext mm_serviceContext;

public void init(IServiceContext serviceContext)

{

mm_serviceContext = serviceContext;

}

public void afterInit()

{

while(true)

{

Date currentDate = new Date(System.currentTimeMillis());

Calendar cal = new GregorianCalendar();

cal.setTime(currentDate);

int currentMonth = cal.get(Calendar.MONTH);

Date dateAfterFiveHours = new Date(currentDate.getTime() + 56060*1000);

cal.setTime(dateAfterFiveHours);

int monthAfterFiveHours = cal.get(Calendar.MONTH);

if(currentMonth != monthAfterFiveHours)

{

// Call some method in another class }

}

}

public void configure(com.sapportals.portal.prt.service.IServiceConfiguration configuration)

{

}

public void destroy()

{

}

public void release()

{

}

public IServiceContext getContext()

{

return mm_serviceContext;

}

public String getKey()

{

return KEY;

}

}

Is it correct to write the logic in while(true) loop?

I am asking this because when I deploy the service into the server from NWDS my NWDS is hanging up and server is crashing (and I then need to unistall and reinstall the server again). It happens only when I try to deploy this service and everthing else in the world works fine.

It will be great if someone can throw light on this.

Thanks & Regards,

Sudhir

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

According to Java standards, it is legal but not sure why it gives this big kind of problem.. May be the loop logic also can be responsible for the caused. Check the method it is calling (inside the loop). Check if problem is because of this method. But I am not sure if u can use that statement as such since it will be called endlessly. That can be the cause for the server crash.

Regards,

Harini S

detlev_beutner
Active Contributor
0 Kudos

See