I need some help understanding how CanDI works with the Startup pattern mentioned in the following tutorial on Caucho's Web site.


Here is what the tutorial says:

  Startup Pattern

The |@Startup| annotation marks a bean as initializing on server startup. Because the startup bean is discovered through classpath scanning like the other beans, the initialization is controlled by the startup class itself. In other words, looking at the startup class is sufficient, because it doesn't rely on XML for startup. The startup bean uses the |@PostConstruct| annotation on an initialization method to start initialization code.

I have added the two annotations @Startup and @PostConstruct to the class that I want to load at server initialization time, but when I start Resin, the class is not initialized. My understanding from reading the tutorial is that this is all I should have to do to have the class loaded and initialized. But, it doesn't seem to work. I don't think Resin is scanning the classpath or finding the class in the classpath. Is there more to it than this?

Here is my Java class:
package example;

import javax.annotation.PostConstruct;
import javax.ejb.Startup;
import javax.inject.Inject;

public class MyStartupBean {

System.out.println("MyStartupBean instance loaded");

  public void init()
System.out.println("MyStartupBean.init() ran");

This Java class is located in the webapp's WEB-INF/classes folder (in the example package).

I see Resin compiling it, but I don't see the print messages in the stdout log.

Do I need to add something to the resin.xml or the webapp's web-resin.xml file to get it to load?

I did figure out a way to explicitly tell Resin to load the class. I created a resin-web.xml file in my web application with the following statements:

<web-app xmlns="http://caucho.com/ns/resin"; xmlns:ee="urn:java:ee"

Now when resin starts, I see the class loading and the init() method is run.

Should this be required?

Thanks for any help.


Keith Fetterman                        Direct: 206-319-9434
Mariner Supply, Inc.                   206-780-5670
http://www.go2marine.com               kfetter...@go2marine.com


resin-interest mailing list

Reply via email to