Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Service wont registerd on application deploy

 
ray frid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am using Jboss5.1.x AS , EJB3.0 I am trying to add job(using Quartz) to my deployment. so I am registering new Service, so it will init the schedualer on application deploy. problem is: the service never got register when I deploy my app.

some code:

interface:

public interface ComponentMonitoringService{
void create() throws Exception;
void start() throws Exception;
void stop();
void destroy();
}


-----

@Service(objectName = "com.mirs.ecms.timer:service=ServerStartupManager")
@Management(ComponentMonitoringService.class)
public class ServerStartupManager implements ComponentMonitoringService
{

private SchedulerFactory schedulerFactory = null;
private Scheduler scheduler = null;
Logger logger = Logger.getLogger("ecms.log");

public void create() throws Exception
{
}

public void start() throws Exception
{
// Write your startup code

initScheduler();

}

private void initScheduler() throws ParseException, SchedulerException
{

schedulerFactory = new StdSchedulerFactory();
scheduler = schedulerFactory.getScheduler();

JobDetail startECMSJob = new JobDetail("startECMSJob", "group1", StartECMSJob.class);
CronTrigger trigger1 = new CronTrigger("cronTrigger", "TriggersGroup1", "0 0/5 * * * ?");

scheduler.scheduleJob(startECMSJob, trigger1);

scheduler.start();
}

public void stop()
{
try
{
scheduler.shutdown();
} catch (Exception e)
{
logger.error("ServerStartupManager Failure occured during Manager stop", e);
}
}

public void destroy()
{
}
}

thanks ray.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you packaging this application? And what's the full package name of the @Service annotation that you are using?
 
ray frid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using MyEclipse. so right now it all being packged under .ear file. my jboss5.1.x is installed locally.

about the " full package name of the @Service annotation that you are using" .. package name: org.jboss.annotation.ejb.service

ray
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
about the " full package name of the @Service annotation that you are using" .. package name: org.jboss.annotation.ejb.service


That's not the correct one for JBoss AS5. For JBoss AS5 and later, use @org.jboss.ejb3.annotation.Service. More details here
 
ray frid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this jar in my class path. but when I use @Service annotation, I can in the import options only the library i am currently using. how come?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ray frid wrote:I have this jar in my class path.

That jar is for JBoss AS 4.x

ray frid wrote:
but when I use @Service annotation, I can in the import options only the library i am currently using. how come?


You need the JBOSS_HOME/client/jboss-ejb3-ext-api.jar in your classpath.
 
ray frid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YOU ARE THE BEST!!

man I have have struggle with this for 3 days now!!! first you found I am using the wrong annotation, second you told me where I should find the right one.
thanks again!!
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to know it worked!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic