2010-11-28 6 views
0

Ich habe einen EJB-Timer mit einer lokalen Schnittstelle erstellt und ich bin nicht in der Lage, JNDI-Lookup für es von einem ServletContextListener.Kann nicht EJB3 von ServletContextListener in JBoss 4.2.3 suchen

ist hier Teil des EJB-Code:

@Stateless 
@LocalBinding(jndiBinding = "TimedFileDeletion") 
public class TimedFileDeletionBean implements TimedFileDeletionBeanLocal { 

@Resource 
    TimerService timerService; 
private String timerInfo = "FileDeletionTimer"; 

    public void startTimer() { 
    .... 
    } 

    public boolean isItRunning() { 
    .... 
    } 

    @Timeout 
    public void timeout(Timer timer) { 
    .... 
    } 
} 

Hier ist die lokale Schnittstelle:

public interface TimedFileDeletionBeanLocal { 

public void startTimer(); 

public boolean isItRunning(); 
} 

Und hier ist der ServletContextListener:

public class StartupEventHandler implements ServletContextListener { 

TimedFileDeletionBeanLocal timedFileDeletionBeanLocal; 

    public StartupEventHandler() { 
    try { 
    InitialContext ic = new InitialContext(); 
    timedFileDeletionBeanLocal = (TimedFileDeletionBeanLocal) ic.lookup("java:comp/env/ejb/TimedFileDeletion"); 

    } catch (NamingException e) { 
    e.printStackTrace(); 
    } 
    } 

    public void contextInitialized(ServletContextEvent arg0) { 
     if(!timedFileDeletionBeanLocal.isItRunning()) { 
     timedFileDeletionBeanLocal.startTimer(); 
     } 
    } 

    public void contextDestroyed(ServletContextEvent arg0) { 

    } 
} 

Für die Lookup mich auch benutzte die folgenden Strings aber keiner der funktioniert: - java: comp/env/TimedF ileDeletion - java: comp/TimedFileDeletion - java: TimedFileDeletion - TimedFileDeletion

In allen Fällen war ich ein javax.naming.NameNotFoundException bekommen.

Jeder Rat würde geschätzt werden.

Antwort

0

Beim Start von JBoss protokolliert es alle lokalen/Remote-Schnittstellen & ihre JNDI-Konfiguration.

JBoss Startprotokoll:

15:26:47,394 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI: 

hrms/AccountSummarySessionBean/local - EJB3.x Default Local Business Interface 
hrms/AccountSummarySessionBean/local-com.cc.hrms.bl.accounts.generalaccount.session.AccountSummarySessionBeanLocal - EJB3.x Local Business Interface 

Lookup:

initialCtx.lookup("hrms/AccountSummarySessionBean/local-com.cc.hrms.bl.accounts.generalaccount.session.AccountSummarySessionBeanLocal"); 

Ich verwende JBoss-5 & Methode für die Suche verallgemeinert haben, nur Schnittstelle Namen geben.

Sie können es entsprechend ändern.

+0

Vielen Dank. Ich habe den Namen in den Logs nachgeschlagen, habe den Namen benutzt, der funktioniert. – Alex

Verwandte Themen