"Singleton" EJB Timer in GlassFish 2.1 cluster?

Hi,
suppose on a GlassFish 2.1 cluster (two instances on one machine) you deploy an ejb app which contains an ejb timer. The ejb timer executes every 60 seconds.
Following questions come to my mind:
1. After deployment do you have (the same) ejb timer on each instance (both using the same connection pool) ?
2. If so, how it is guaranteed that every 60 seconds only one timer is executed?
3. Is it possible to have a "singleton" timer for all instances in a cluster?
Thx for your help.

EJB 3.0 only supports programmatic timer creation. The app can contain an enterprise bean component that supports timer callbacks (a "timed object" in spec parlance) , but the actual timers can only be created by calling TimerService.createTimer(). Given that :
1. There is no automatic timer creation as a result of deployment. Some developers approximate automatic timer creation
by calling a stateless session bean method from a web application initialization callback, but from the ejb container's perspective
that's just a normal run-time timer creation. In all cases you'll have as many timers as the number of times TimerService.createTimer() was called.
2. In a cluster, for each unique timer, each timer timeout callback will happen in only one server instance in the cluster. We do that
by using the underlying timer database and an ownership semantic that assigns each timer to a particular server instance. During
failover, ownership of timers owned by the failed server instance is reassigned to a healthy server instance. Note that this only applies
to timeout callbacks. All timers created by a bean are always visible to any instances of that bean in any server instance in the cluster.
In other words, getTimers() always returns the total number of timers associated with the bean component, even if the callbacks
happen in a different server instance in the cluster.
3. Each call to TimerService.createTimer() is unique across the cluster. However, the burden of ensuring that createTimer() is only
called once is on the application. EJB 3.1 will address this problem by adding "automatic timers". These are timers that are
specified via metadata (annotation or ejb-jar.xml) and are created automatically as a result of deployment.

Similar Messages

  • WebLogic 12.1.3 Cluster EJB Timer with filesystem

    I'm running a WebLogic 12.1.3 Cluster and need to create clustered EJB 3.x Timers.
    Can I use a filesytem as a persistent cluster store instead of a DB? The application itself doesn't need a DB so it would be overkill for us to deploy RAC just to get clustered EJB Timers.

    Yes: As long as there is one server in the cluster still running, the timers will still function,  the application may run slower though. When all servers in the cluster stop, the timers will stop running.  When at least one of the servers in the cluster restarts again, the timers will start running.
    Check: JEE blog: How to use EJB 3 timer in a weblogic 10 cluster environment

  • Singleton EJBs in Weblogic

    Hello everyone,
    I'm developing an application (with Weblogic 11gR1PS1) which needs a single point of access to get tickets for making requests. The numbers are sequential and cannot be 2 tickets with the same number, so Concurrency is an issue. Based on this we came up with 2 ideas:
    1- Creating a singleton EJB which will generate the tickets number to avoid 2 concurrent instances to generate the same number (if executing aproximately at the same time). Unfortunately I don't know how to do that with EJB 3.0 , I know that EJB 3.1 has a @Singleton annotation but that's not an option.
    2- Try to limit up the instances of a the generator Stateless Bean to 1 , making it a singleton. Unfortunately I don't know how to limit the number of instances in a pool of a specific EJB to 1, which is what is needed.
    I don't know which solution suits best, or even if there is a third one which any of you might know. Any suggestions will be appreciated!
    Thank you

    To limit the number of beans in the pool you can use the following:
    - create a deployment plan
    - create a file a deployment override weblogic-ejb-jar.xml and place this in the right directory (defined in the deployment plan)
    - add to the deployment override the following:
    <?xml version='1.0' encoding='UTF-8'?>
    <weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/10.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/10.0 http://www.bea.com/ns/weblogic/10.0/weblogic-ejb-jar.xsd">
    <weblogic-enterprise-bean>
    <ejb-name>NameOfYourEJB</ejb-name>
    <stateless-session-descriptor>
    <pool>
    <max-beans-in-free-pool>1</max-beans-in-free-pool>
    <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
    </pool>
    </stateless-session-descriptor>
    </weblogic-enterprise-bean>
    Now there is only one bean in the pool. The problem with this is clients calling the EJB have to wait, until the EJB is released. This could have a negative effect on your response time of the application.
    Maybe you can create a normal singleton, for example,
    public class SomeSingleton {
    private static final MyObject myObject;
    private SomeSingletonl() {
    static {
    // create some instance of MyObject
    public static MyObject getMyObject() {
    return myObject;
    Then you can call this from your EJB

  • EJB timer info in persistent store

    Is it possiblle to configure WL 10.3.5 so that ejb timer information is stored into JDBC persistent store instead of the default file store?
    Where can I find documentation about that ?
    Or is it allowed in cluster configurations only ?
    Thanks

    Is it possiblle to configure WL 10.3.5 so that ejb timer information is stored into JDBC persistent store instead of the default file store?
    Where can I find documentation about that ?
    Or is it allowed in cluster configurations only ?
    Thanks

  • EJB Timer problem

    Hi all, I'm trying to run the J2EE Tutorial EJB Timer sample, but I keep getting an exception:
    Errors while obtaining information about the database. Got the following exception:
    java.sql.SQLException: Error in allocating a connection. Cause:
    Connection could not be allocated because: Connection does not exist.
    com.sun.jdo.api.persistence.support.JDOFatalInternalException:
    JDO76519: Failed to identify vendor type for the data store.
    NestedException: java.sql.SQLException: Error in allocating a connection.
    Cause: Connection could not be allocated because: Connection does not exist. .The tutorial says that I should start the PointBase database first, and I did; but there seems to be something missing, like the server is trying to lookup some datasource and it can't find it.
    Any ideas?

    Hi ,,
        Go THru this article, sure it helps .
    http://www.oracle.com/technology/sample_code/tutorials/fbs10g/fbs10gtoc.htm
    Reg
      VArun CN

  • Issues in looking up a ejb deployed on glassfish from tomcat.

    Hi all,
    I have followed the steps mentioned in the EJB FAQ in the glassfish site and was able to lookup a remote ejb deployed in glassfish from a standalone client.
    In case of standalone client, i set the appropriate jndi properties in the initial context as mentioned in the FAQ and added the 4 jars specified to the classpath of the application.
    It all worked perfectly well.
    But I attempted to do the same from a servlet running under tomcat.
    I set the appropriate jndi properties in the intial context and added 4 jars specified in the lib directory of the war file.
    But this did not turn out well and tomcat complained me with some servlet init errors.
    Then i searched through the web and found this posting from you:
    http://www.archivesat.com/GlassFish_Enterprise_JavaBeans_Developers/thread1399339.htm
    Then i created a folder called "shared/lib" under TOMCAT_HOME directory in my machine and ran the same example. Wow.....miraculously the application ran well.
    But i found that the "index.jsp" which i configured in the welcome file list does not appear now. But i was able to access the servlet without any problem. And the servlet was able to successfully lookup the ejb deployed in glassfish.
    Then i thought, let me try to access the ejb from a jsf application.
    Then i created a jsf application in netbeans 5.5.1 and tried to access the bean deployed in glassfish.
    (Note: the jsf application runs in tomcat 5.5.17 which is bundled with netbeans)
    OOPSS....
    Tomcat now complains me that it cannot compile the jsp page..
    This is the error i got...
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    C:\Documents and Settings\james\.netbeans\5.5.1\apache-tomcat-5.5.17_base\work\Catalina\localhost\CityExplorer-WebClient1\org\apache\jsp\index_jsp.java:7: org.apache.jsp.index_jsp is not abstract and does not override abstract method getDependants() in org.apache.jasper.runtime.JspSourceDependent
    public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
    ^
    Generated servlet error:
    C:\Documents and Settings\james\.netbeans\5.5.1\apache-tomcat-5.5.17_base\work\Catalina\localhost\CityExplorer-WebClient1\org\apache\jsp\index_jsp.java:12: getDependants() in org.apache.jsp.index_jsp cannot implement getDependants() in org.apache.jasper.runtime.JspSourceDependent; attempting to use incompatible return type
    found : java.lang.Object
    required: java.util.List
    public Object getDependants() {
    ^
    2 errors
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    Any ideas...
    Can you please help me.
    I've noticed that you were eagerly answering questions related to ejb lookup in many places.
    I feel there is some potential compatability issue between tomcat and glassfish...
    I request you to investigate on this and clarify the community with your response.
    Thanks in advance,
    James Selvakumar

    Thank you guys!
    I've found the answer myself.

  • SELECT is taking lot of time to fetch data from cluster table BSET

    <Modified the subject line>
    Hi experts,
    I want to fetch data of some fields from bset table but it is taking a lot of time as the table is cluster table.
    Can you please suggest me any other process to fetch data from cluster table. I am using native sql to fetch data.
    Regards,
    SURYA
    Edited by: Suhas Saha on Jun 29, 2011 1:51 PM

    Hi Subhas,
    As per your suggestion I am now using normal SQL statement to select data from BSET but it is still taking much time.
    My SQL statement is :
    SELECT BELNR
                  GJAHR
                  BUZEI
                  MWSKZ
                  HWBAS
                  KSCHL
                  KNUMH FROM BSET INTO CORRESPONDING FIELDS OF TABLE IT_BSET
                  FOR ALL ENTRIES IN IT_BKPF
                  WHERE BELNR = IT_BKPF-BELNR
                      AND BUKRS = IT_BKPF-BUKRS.
    <Added code tags>
    Can you suggest me anymore?
    Regards,
    SURYA
    Edited by: Suhas Saha on Jun 29, 2011 4:16 PM

  • Stateless Bean - scope of instance variable in EJB Timer call back function

    Hi,
    I would like to know on the scope of an instance variable of a Stateless Bean object,
    when used in a EJB Timer call back.Let me explain this in more detail below.
    I have a requirement to use a EJB Timer.
    For this, I have created a stateless object since Timer creation needs to be done
    from a stateless bean. I have a member variable "count" of the stateless bean class.
    In the timer call back(ejbTimeout), I am able to use this count variable during
    each time of the call back, and the value of this variable is also updated properly.
    I have a few queries with respect to the above behaviour:
    1) Does stateless bean object not get destroyed once the Timer is created from the Bean?
    2) If the Bean object is not destroyed, then when does the bean object get destroyed?
    3) If both (1) and (2) are not true, then can anyone explain on how the above behaviour is possible?
    Thanks in advance,
    Ulrich

    Hi Ulrich,
    The ejb timer is associated with the stateless session bean component, not with a particular bean instance. There is no formal relationship between the bean instance that called createTimer() and the bean instance on which the timer callback happens. If they're the same in your test run that's just a coincidence and not something your application should be depending on.
    In the stateless session bean model, the container can create and destroy stateless session bean instances at any time. The container is free to pick any stateless session bean instance to service any client invocation or timer callback. If you need to pass context into a timer callback, one way to do it is via the timer "info" object. However, the info object is immutable so it wouldn't be a good match for a counter. You could of course always just use a database for any necessary coordinated state.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Doing a jndi lookup() for an EJB deployed on Glassfish v3

    Hello.
    I have deployed a Stateful Sesion EJB on a Glassfish v3 AppServer.
    It is running under 'localhost' on my laptop pc.
    I am also running a stand-alone java application on the same pc... it attempts to get a remote connection from the client-app to the Glassfish Server and then do a jndi lookup() to get a reference to my EJB.
    here is the client source code:
    public class LookupTest {
    static Properties props = null;
    public static void main(String[] args) {
    try {
    props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
         props.put(Context.PROVIDER_URL, "iiop://localhost:3700");
         Context ctx = new InitialContext(props);
         System.out.println( "the context is: " + ctx);
         System.out.println( "the environment contains: " + ctx.getEnvironment() );
         System.out.println( " ");
         // do a lookup.
         Object elementObj = ctx.lookup("SerialContextProvider");
         System.out.println(elementObj);
    } catch (NamingException e) {
    e.printStackTrace();
    When I run this app, there are no Errors or Exceptions. It appears that the connection succeeds. But there are no EJB references in the context that is created. The only item that seems to be present in the context is an item named "SerialContextProvider", as noted in the return value from a list("") method invocation. Why can i not see the EJB within the context? Is my code wrong ??
    Thanks,
    Andy Jerpe
    Edited by: user1169567 on Nov 28, 2010 12:12 PM

    Ok, but the communication seems to be OK over the wire because if I use netstat -a I can see the ESTABLISHED connection with the server in the right RMI port.
    TCP PORTAL35:1581 caapiranga:12405 ESTABLISHED
    and then when I stop the instance in the OAS, the client shows an exception telling that the connection was lost.
    An curious thing is that the ons.log doesn't log this connection ;/

  • EJB Timer Services - timeout overlapping

    Hi,
    I have this question:
    What should happen if the @Timeout method spends more time in working
    something than the timer expiration time?
    For example:
    EJB timer is created with interval (expiration time) every 3 minutes. But for some reason the EJB binded to this timer is spending 4 minutes to process a timer notification. What happens with the next incoming timer notification?
    Is it skipped or blocked? What happens with the method annotated as @Timeout?
    Thanks!

    Hi Fellipe,
    This case isn't explicitly mentioned in the spec since the expectation is that the processing
    time for the timeout would be much shorter than the interval itself. The design center for the
    EJB Timer Service is to handle long-lived business processes so the spec examples for
    timeouts are on the order of hours or days, even though the actual type in the API is
    milliseconds. Many developers have expressed interest in support for finer-grained
    timeouts and even cron-like functionality. The issue you raise would be an important one
    to address in the scope of those EJB Timer Service additions.
    Having said all that, the implementation in the Java EE SDK will not deliver a subsequent
    timeout for the same timer until the previous one has completed.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Singleton ejb?

    Hi
              I need to wrapp an EJB service in a singleton service.
              But I don't know which class should be implements the weblogic.cluster.singleton.SingletonService interface (the home, remote or the bean).
              So what is the class that should implement this interface weblogic.cluster.singleton.SingletonService?
              Thanks in advance

    EJB 3.0 only supports programmatic timer creation. The app can contain an enterprise bean component that supports timer callbacks (a "timed object" in spec parlance) , but the actual timers can only be created by calling TimerService.createTimer(). Given that :
    1. There is no automatic timer creation as a result of deployment. Some developers approximate automatic timer creation
    by calling a stateless session bean method from a web application initialization callback, but from the ejb container's perspective
    that's just a normal run-time timer creation. In all cases you'll have as many timers as the number of times TimerService.createTimer() was called.
    2. In a cluster, for each unique timer, each timer timeout callback will happen in only one server instance in the cluster. We do that
    by using the underlying timer database and an ownership semantic that assigns each timer to a particular server instance. During
    failover, ownership of timers owned by the failed server instance is reassigned to a healthy server instance. Note that this only applies
    to timeout callbacks. All timers created by a bean are always visible to any instances of that bean in any server instance in the cluster.
    In other words, getTimers() always returns the total number of timers associated with the bean component, even if the callbacks
    happen in a different server instance in the cluster.
    3. Each call to TimerService.createTimer() is unique across the cluster. However, the burden of ensuring that createTimer() is only
    called once is on the application. EJB 3.1 will address this problem by adding "automatic timers". These are timers that are
    specified via metadata (annotation or ejb-jar.xml) and are created automatically as a result of deployment.

  • EJB Timer stops when database connection lost

    G'day.
    We use EJB Timers quite successfully in stateless session beans under Sun Java System Application Server 8.1 on Windows Server 2003.
    We start and stop the timers for specific session beans using public intefaces on their respective beans. This works fine.
    The problem we have is when the JDBC connection used by the EJBTimer service is dropped, such as when the remote database / machine falls over or (probably) when the network is lost. All the timers stop working at this point.
    The timers do not restart when the database connection is restored either, despite the entries still being in the ejb__timers__tbl table.
    If we stop and start the application server instance then they do restart.
    We've looked at the setup of the timers but this seems to be pretty straightforward with no options that seem to influence this.
    We've tried altering the JDBC connection validation settings but this doesn't seem to have made any difference.
    Anyone have any ideas?
    Robski!

    There are no special options to handle this case in the current timer service implementation. Please file an issue describing the scenario here :
    https://glassfish.dev.java.net/servlets/ProjectIssues
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to send to Weblogic 9.1 JMS queue from EJB running in Glassfish?

    Hi.
    I hope this is the correct forum.
    I need to send a message to a jms queue on a remote weblogic 9.1 server. To this end I believe I will have to:
    1) Install one or more weblogic client libraries/jar files on my glassfish application server. The weblogic server expects communication in the "t3" protocol, which I believe tunnels iiop, jms etc. inside their own proprietary protocol
    2) Define the jms queue in my glassfish application server with a queue connection factory that creates the queue using classes from the weblogic jars?
    3) Otherwise code the EJB methods sending messages as I would code and send messages to any jms queue
    It's the first two steps that have me baffled. The more I dig in glassfish administrator's manual, the more confused I become.
    Anybody have any idea if/how this can be accomplished?
    Some reference to where I may find information as to how to accomplish this?
    Thank you,
    Jacob.

    Jacob,
    I suggest you try, either a GlassFish forum (http://forums.java.net/jive/forum.jspa?forumID=56), or perhaps the GenericJMSRA project https://genericjmsra.dev.java.net .This forum is primarily about the Sun JMS provider, Java MQ or Open MQ -- or the JMS Specification.
    -- Ed Bratt

  • Erroneous time in graphs in output cluster

    I have an application that reads a binary file and then displays, analyzes and presents the data in charts and indicators. The 'main' application is "06_ATP_Read and Analyze SubVIs.vi" with the "04_ATP_Read.vi" and "05_ATP_Analyze & Present Data.vi" subvis.
    The application with the problem is called "05_ATP_Analyze & Present Data.vi" and it is in the attached file. It was built on the LabView Basics II example.
    Everything works fine except in the graphs from the output cluster the time values are 5000 times bigger than the real ones displayed or selected in data graphs at the left of the cluster. The 5000 times value is exactly the sampling rate I am using (5kHz) but I am not sure if this is related because I am not sure where is the problem coming for. My feeling is that the feedback node is causing the problem but, again, I'm not sure.
    What could I do to make things right? Any suggestions/examples anybody?
    Thank you.
    Attachments:
    06_ATP_Read and Analyze SubVIs.zip ‏2076 KB

    Thank you Travs,
    I think I got the idea but how would I implement this in my vi? I tried a couple of connections and the attached file presents some of them. Look in 05_ATP_Analyze & Present Data.vi, in case structure 0.
    Another problem is that the sampling rate might vary from file to file and I will not know it before opening the file. I need some kind of automatic reading of sampling rate rather than manual insertion.
    This vi is very similar to the exercise from LabView Basics II and there I did not have to put any additional 'build waveform' components to make it work; probably because there was a chart and not graphs, I don't remember right now... Any way, the idea with the cluster is that it helps me to easily save processed data in one file. I'd like to stay with this solution only if there is nothing better that you or somebody else can suggest.
    Could you show me how would I implement the 'build waveform' in my vi?
    Attachments:
    05_ATP_Analyze & Present Data.zip ‏2525 KB

  • EJB Timer Service

    I've been trying to get the javax.ejb.TimerService working. As stated in the J2EE 1.4 tutorial, it is possible to use the TimerService in an entity bean. In fact, it states that if I wanted a timer for each instance of an entity bean, to create the timer in the entity bean's ejbCreate(). However, I keep getting an IllegalStateException when attempting to do so. I have implemented TimedObject in the entity bean, so I'm a little confused. Here's my ejbCreate:
    public String ejbCreate(String clientID, long timeout) throws CreateException {
    setClientID(clientID);
    TimerService timerService = context.getTimerService();
    //dies on next line
    Timer timer = timerService.createTimer(getTimeout(), "state 1");
    return clientID;
    Any help is appreciated....
    Thanks
    Raj

    getTimerService is allowed in ejbCreate but Timer Service Methods are not . You can use Timer Service methods in ejbPostCreate(), though.

Maybe you are looking for

  • Want to share this tool I found

    Real quick, in case someone was looking for the same thing as I did (on Windows). I found this little tool that can display the current CPU and memory while AE is rendering or doing some of its stuff. I don't know how to explain or even where I got i

  • Error in db13

    Hi, Due to security reasons we had disabled the RSH and enable SSH. After this DBCHECK & Update statistics not working in DB13 which was working perfectly when RSH was enabled. The error is "22.04.2009     23:00:36     No application server found on

  • 50 Hz interferen​ce with DSP

    I have a very sophisticated DSP package developed in LV that analyzes biomedical signals at 256 sps. In the US the code works perfectly but in Europe, with some laptops, the code does not function correctly and 50 Hz "noise" is present. There are a f

  • When using FaceTime the picture is delayed and goes black ever since I updated to iOS6.0.1???

    Since I updated to iOS 6.0.1 when using FaceTime the picture is delayed and goes black???

  • How can I derive Measures for coming periods like (Next Qtr – Measure)

    Hi All, How can I derive time series measures for coming periods just like Qtr Ago and Year Ago I want Next Qtr and Next Year columns in my fact, how can I achieve this? I have a report which talks about Actual recorded values to the projected values