3
14:00:04,449 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.servlet.characterEncodingFilter
14:00:04,450 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.redirectFilter
14:00:04,451 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.exceptionFilter
14:00:04,452 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.multipartFilter
14:00:04,452 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.identityFilter
14:00:04,453 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.rewriteFilter

These are the last set of lines which gets printed post the JBoss SEAM application startup on JBoss 6.

@Name("myStartup")
@Startup
@Scope(APPLICATION)
@BypassInterceptors
public class MyStartup {

    @Create
    public void create() {
        System.out.println("SERVER STARTED SUCCESSFULLY");
    }
}

My intention was to print the above message (on JBoss 6 console) after SeamFilter initializes. How should I do this?

Joe
  • 14,513
  • 28
  • 82
  • 144

2 Answers2

0

You can try this annotation on a normal component. Remove the @Startup on this component.

@Observer({"org.jboss.seam.postInitialization", "org.jboss.seam.postReInitialization"})
public void create() {
    System.out.println("SERVER STARTED SUCCESSFULLY");
}
Shervin Asgari
  • 23,901
  • 30
  • 103
  • 143
  • The above suggestion doesn't seem to work. Is there a way to use the @Instal annotation with a precedence option? I am not sure how to get that to work. – Joe Jun 25 '11 at 04:44
  • The above suggestion produces a similar output as before and the above line doesn't get printed after the Servlet Filter gets initialized. – Joe Jun 25 '11 at 04:51
  • I looked at the code public static void endReinitialization() { Contexts.startup(ScopeType.APPLICATION); Events.instance().raiseEvent("org.jboss.seam.postReInitialization"); and you suggestion seems correct, but for some reason didn't work. – Joe Jun 25 '11 at 04:54
  • which version of seam are you using? You should use the latest version, as it supports JBoss 6 – Shervin Asgari Jun 27 '11 at 07:42
  • If this does not work, try removing `@BypassInterceptors` in your `@Startup` component. – Shervin Asgari Jun 27 '11 at 08:53
  • Seam 2.2.2.Final w/JBoss 6 is my env. – Joe Jun 28 '11 at 07:36
  • @Shervin - We removed @BypassInterceptors in our @Startup component, but didn't make any difference as for as the output is concerned. – Joe Jun 28 '11 at 07:45
  • Then I would instead ask, what are you trying to accomplish? Maybe you can perform your task successfully in some other way. Why does it have to be right after the filters? – Shervin Asgari Jun 28 '11 at 10:33
  • @Shervin - Thanks for your support so far. I want this to serve as an indicator to an administrator (who ain't that computer savvy), that the application has started without any errors. If this message appears before the filters, then it doesn't serve the purpose. Hope it is clear and thanks for all your support. – Joe Jun 28 '11 at 14:37
  • So now your message appears `before` the filters? Otherwise I don't see your problem. The application does not have to report that it is successful after the filters, but after seam has finished loading all components. So a startup component should be enough. Also, an administrator should look for exceptions in the server.log. – Shervin Asgari Jul 01 '11 at 09:55
0

If the idea is only to show some status AFTER all seam messages, there are at least 2 ways:

First is to use a Shervin's solution and suppress org.jboss.seam.servlet.Filter INFO messages in $JBOSS_HOME/server/<your-profile>/conf/jboss-log4j.xml:

<category name="org.jboss.seam.servlet.Filter">
   <priority value="ERROR"/>
</category>

Or implement a filter:

@Scope(APPLICATION)
@Name("com.example.seam.myFilter")
@BypassInterceptors
@Filter(within={"org.jboss.seam.web.rewriteFilter"})
public class MyFilter implements Filter {
    public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
        chain.doFilter(request, response);
    }

    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("SERVER STARTED SUCCESSFULLY");
    }
}
Tair
  • 3,779
  • 2
  • 20
  • 33