1 2 Previous Next 16 Replies Latest reply on Sep 6, 2011 5:35 AM by Carmen Teich

    Timer not in the correct datasource - ejb2-timer-service.xml

    Carmen Teich Newbie

      Hello,

       

      my problem is, that the server (JBoss 6 Final) did not save the timer, wich I start with my application, in the correct datasource.

       

      I have create a new datasource like this: (edesk.ds.xml)

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- ===================================================================== -->
      <!--                                                                       -->
      <!--  JBoss Server Configuration                                           -->
      <!--                                                                       -->
      <!-- ==================================================================== -->
      <!--  Datasource config for Postgres                                      -->
      <!-- ==================================================================== -->
      
      
      <datasources>
        <local-tx-datasource>
          <jndi-name>EDeskDS</jndi-name>
          <!-- For log4jdbc do the following -->
          <!-- <connection-url>jdbc:log4jdbc:postgresql://localhost:5432/xline</connection-url> -->
          <!-- <driver-class>net.sf.log4jdbc.DriverSpy</driver-class> -->
          <!-- For jamon do the following -->
          <!-- <connection-url>jdbc:jamon:postgresql://localhost:5432/edeskjamonrealdriver=org.postgresql.Driver</connection-url> -->
          <!-- <driver-class>com.jamonapi.proxy.JAMonDriver</driver-class> -->
          <!-- For standard Postgres do the following -->
          <!-- <connection-url>jdbc:postgresql://localhost:5432/xline</connection-url> -->
          <!-- <driver-class>org.postgresql.Driver</driver-class> -->
          <connection-url>jdbc:postgresql://127.0.0.1:5432/xline</connection-url>
          <driver-class>org.postgresql.Driver</driver-class>
          <user-name>postgres</user-name>
          <password>postgres</password>
          <prepared-statement-cache-size>150</prepared-statement-cache-size>
          <share-prepared-statements>true</share-prepared-statements>
          <max-pool-size>40</max-pool-size>
              <!-- sql to call when connection is created
              <new-connection-sql>some arbitrary sql</new-connection-sql>
              -->
      
              <!-- sql to call on an existing pooled connection when it is obtained from pool 
              <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
              -->
          <metadata>
            <type-mapping>PostgreSQL 8.0</type-mapping>
          </metadata>
          <set-tx-query-timeout>false</set-tx-query-timeout>
          <query-timeout>3600</query-timeout>
        </local-tx-datasource>
      
      </datasources>
      

       

      And in the ejb2 -timer-service.xml I defined to use this datasource for saving timer in my timerstable ejbtimer:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!--
        The JBoss service configuration file for the EJB deployer service.
        
        $Id: ejb2-timer-service.xml 82920 2009-01-15 17:29:45Z pgier $
      -->
      <server>
      
        <!-- ==================================================================== -->
        <!-- J2EE Timer Service                                                   -->
        <!-- ==================================================================== -->
      
        <!--
          A persistence policy that persists timers to a database.
          
          The 2 supported db persistence plugins are:
            org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin
            org.jboss.ejb.txtimer.OracleDatabasePersistencePlugin
            
          The table name defaults to "TIMERS". It can be overriden using the
          'TimersTable' attribute if the persistence plugin supports it.
          When overriding the timers table, an optional schema can be specified
          using the syntax [schema.]table
        -->
        <mbean code="org.jboss.ejb.txtimer.DatabasePersistencePolicy" name="jboss.ejb:service=EJBTimerService,persistencePolicy=database">
          <!-- DataSourceBinding ObjectName -->
          <depends optional-attribute-name="DataSource">jboss.jca:service=DataSourceBinding,name=EDeskDS</depends>
          <!-- The plugin that handles database persistence -->
          <attribute name="DatabasePersistencePlugin">org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin</attribute>
          <!-- The timers table name -->
          <attribute name="TimersTable">EJBTIMERS</attribute>
          <depends>jboss.jdbc:datasource=EDeskDS,service=metadata</depends>
        </mbean>
      
        <!-- A persistence policy that does not persist the timer
        <mbean code="org.jboss.ejb.txtimer.NoopPersistencePolicy" name="jboss.ejb:service=EJBTimerService,persistencePolicy=noop"/>
        -->
         
         <!-- A retry policy that uses a fixed interval in milli seconds -->
         <mbean code="org.jboss.ejb.txtimer.FixedDelayRetryPolicy" name="jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay">
           <attribute name="Delay">100</attribute>
         </mbean>
      
        <!-- An EJB Timer Service that is Tx aware -->
        <mbean code="org.jboss.ejb.txtimer.EJBTimerServiceImpl"
          name="jboss.ejb:service=EJBTimerService">
          <attribute name="TimerIdGeneratorClassName">org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator</attribute>
          <attribute name="TimedObjectInvokerClassName">org.jboss.ejb.txtimer.TimedObjectInvokerImpl</attribute>
          <depends optional-attribute-name="RetryPolicy">jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay</depends>
          <depends optional-attribute-name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=database</depends>
          <depends optional-attribute-name="TransactionManagerFactory" proxy-type="org.jboss.tm.TransactionManagerFactory">
            jboss:service=TransactionManager
          </depends>    
        </mbean>
      
      </server>
      

       

       

      But all the timers are saved in the defaultDS hypersonic but they should save in my  EdeskDS.

       

      Has anybody an idea what I have to do so that the server is using the correct datasource????

      Please help!!!!!!!!!

        • 1. Re: Timer not in the correct datasource - ejb2-timer-service.xml
          Wolf-Dieter Fink Master

          What EJB version do you use?

          I delete the hsqldb deployment and DefaultDS complete and change the ejb2 -timer-service.xml to my own DS and it works for my EJB2.1 application and JBoss 5.1.

           

          If you delete the hsqldb you will find out where the DS is used ...

          • 2. Re: Timer not in the correct datasource - ejb2-timer-service.xml
            Carmen Teich Newbie

            hi,

             

            to delete the DefaultDS is not so easy, because I got many depencies missing errors. (ejb3-timerservice-mk2.jar).

             

            Did anybody knows what I can do???

            • 3. Re: Timer not in the correct datasource - ejb2-timer-service.xml
              jaikiran pai Master

              Carmen Teich wrote:

               

              But all the timers are saved in the defaultDS hypersonic but they should save in my  EdeskDS.

               

              Has anybody an idea what I have to do so that the server is using the correct datasource????

              Please help!!!!!!!!!

              Edit the JBOSS_HOME/common/deploy/jboss-ejb3-timerservice-mk2.jar/META-INF/persistence.xml to point to the jndi name of your new datasource, instead of the DefaultDS.

              • 4. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                Wolf-Dieter Fink Master

                What about your application. I suppose that you use EJB3 and this is the reason why the timer information is written to the wrong database because you change the ejb2-timer but not the ejb3-timerservice...

                • 5. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                  Carmen Teich Newbie

                  hi,

                   

                  by default the JBOSS_HOME/common/deploy/jboss-ejb3-timerservice-mk2.jar/META-INF/persistence.xml looks like this:

                   

                  <persistence xmlns="http://java.sun.com/xml/ns/persistence"

                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence

                     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

                     version="1.0">

                     <persistence-unit name="timerdb">

                        <jta-data-source>java:/DefaultDS</jta-data-source>

                        <class>org.jboss.ejb3.timerservice.mk2.persistence.TimerEntity</class>

                        <properties>

                            <property name="hibernate.hbm2ddl.auto" value="update"/>

                        </properties>

                     </persistence-unit>

                  </persistence>

                   

                  Did I have to change DefaultDS to my ownDS or shoult I also change the persistence-unit name to my own persistence-unit name?

                  • 6. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                    Carmen Teich Newbie

                    But I have to put a copy of this jar into the deploy folder of my configuration  and change than the datasource???

                    • 7. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                      Carmen Teich Newbie

                      when I make a copy of JBOSS_HOME/common/deploy/jboss-ejb3-timerservice-mk2.jar ant put into the deploy folder of my configuration  and change than the datasource, then I get this stacktrace-errors:

                       

                      WARN  [ClassLoaderManager] Unexpected error during load of:org.jboss.ejb3.timerservice.mk2.TimerServiceImpl: java.lang.LinkageError: loader (instance of  org/jboss/classloader/spi/base/BaseClassLoader): attempted  duplicate class definition for name: "org/jboss/ejb3/timerservice/mk2/TimerServiceImpl"

                       

                      ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:ear=edesk4postgres.ear,jar=ejb2beans.jar,name=ImportManager,service=EJB3 state=Create: java.lang.NoClassDefFoundError: javax/persistence/Query

                          at org.jboss.ejb3.timerservice.mk2.TimerServiceImpl.getActiveTimers(TimerServiceImpl.java:985)

                          at org.jboss.ejb3.timerservice.mk2.TimerServiceImpl.restoreTimers(TimerServiceImpl.java:738)

                          at org.jboss.ejb3.timerservice.mk2.TimerServiceFactoryImpl.restoreTimerService(TimerServiceFactoryImpl.java:123)

                          at org.jboss.ejb3.TimerServiceContainer.restoreTimerService(TimerServiceContainer.java:244) [:1.7.17]

                          at org.jboss.ejb3.TimerServiceContainer.afterStart(TimerServiceContainer.java:129) [:1.7.17]

                          at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:1113) [:1.7.17]

                      • 8. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                        Carmen Teich Newbie

                        And when I delete the JBOSS_HOME/common/deploy/jboss-ejb3-timerservice-mk2.jar

                        the server tells me:

                         

                        ERROR [AbstractKernelController] Error installing to Create: name=f202957f aliases=[ProfileKey@4e727e0e[domain=default, server=default, name=EJB3_OnDemand_Profile]] state=Configured mode=Manual requiredState=Installed: java.io.FileNotFoundException: failed to find artifact FileArtifactId[path=jboss-ejb3-timerservice-mk2.jar]

                            at org.jboss.profileservice.repository.artifact.DefaultNotFoundHandler.handleArtifactNotFound(DefaultNotFoundHandler.java:51) [:0.2.2]

                            at org.jboss.profileservice.repository.artifact.file.LocalFileArtifactRepository.getOriginalFile(LocalFileArtifactRepository.java:262) [:0.2.2]

                            at org.jboss.profileservice.repository.artifact.file.LocalFileArtifactRepository.getOriginalFile(LocalFileArtifactRepository.java:48) [:0.2.2]

                            at org.jboss.profileservice.repository.virtual.AbstractVirtualDeploymentRepository.getOriginalVirtualFile(AbstractVirtualDeploymentRepository.java:91) [:0.2.2]

                        • 9. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                          Wolf-Dieter Fink Master

                          I would prefer to change the persistence.xml directly without copying, this should work.

                          But remember if you use not only default config all other configs must have the correct *-ds.xml configuration.

                          • 10. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                            Carmen Teich Newbie

                            when I do this the server tells me:

                             

                            ERROR [ProfileServiceBootstrap] Failed to load profile:: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

                             

                            DEPLOYMENTS MISSING DEPENDENCIES:

                              Deployment "MK2TimerServiceFactory" is missing the following dependencies:

                                Dependency "persistence.unit:unitName=jboss-ejb3-timerservice-mk2.jar#timerdb" (should be in state "Installed", but is actually in state "Configured")

                             

                            ...

                            DEPLOYMENTS IN ERROR:

                              Deployment "jboss.jca:name=EdeskDS,service=DataSourceBinding" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.jca:name=EdeskDS,service=DataSourceBinding' **

                              Deployment "interface org.jboss.ejb3.timerservice.spi.TimerServiceFactory" is in error due to the following reason(s): Instantiated

                             

                                at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1228) [:2.2.0.GA]

                                at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:905) [:2.2.0.GA]

                                at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:87) [:6.0.0.Final]

                                at org.jboss.profileservice.deployment.ProfileDeployerPluginRegistry.checkAllComplete(ProfileDeployerPluginRegistry.java:107) [:0.2.2]

                                at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:135) [:6.0.0.Final]

                                at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.0.0.Final]

                                at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]

                                at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]

                                at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]

                            • 11. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                              Wolf-Dieter Fink Master

                              I've made a quick test:

                              - add a new xyz-ds.xml (DS DefaultDS2)

                              - rename it in 'JBOSS_HOME/common/deploy/jboss-ejb3-timerservice-mk2.jar/META-INF/persistence.xml'

                              start JBoss with no errors.

                              If I remove the xyz-ds.xml the startup is still with no errors.

                              So you have another problem.

                              What you see during startup WARN/ERROR ?

                              Also you might try a fresh configuration only with this change ...

                              • 12. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                                Carmen Teich Newbie

                                thanks for your help ..I solved it

                                 

                                I only spelled the name of my datasorce with one false capital letter  their for the mistake.

                                 

                                every thing works.

                                but the timers where saved more than one times in the table...so when I start the server twince I got TimerTask errors

                                So I have to delete the tables before starting the server

                                 

                                Do you know how to solve this?

                                • 13. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                                  Wolf-Dieter Fink Master

                                  If you delete the table and start two times the problem occour at the second start?

                                  Check your code whether the timer is initialized twice ...

                                  • 14. Re: Timer not in the correct datasource - ejb2-timer-service.xml
                                    Carmen Teich Newbie

                                    At the first server-start everything works fine. after the second server-start I get the timertask errors, because in the table are the timer from the first start.

                                     

                                    But it is implemented that the timer should be deleted before they will be create:

                                     

                                    @Override

                                        public void createTimers(TimerService timerService) {

                                            int duration = Integer.getInteger(Definitions.PROPNAME_LDAP_SYSTEM_REFRESH, DEFAULT_DURATION);

                                           stopPreviousTimers();

                                           

                                            // Create the timer to go off almost immediately, and then every 30 minutes or whatever after that.

                                            timerService.createTimer(10000L, duration * 1000L, LDAP_TIMER_NAME);

                                     

                                            initialTimerCreated = true;

                                        }

                                     

                                    @SuppressWarnings("unchecked")

                                        protected void stopPreviousTimers() {

                                            if (deletedTimers.contains(getClass())) return;

                                            log.info("deleting all historical timers for " + getClass());

                                            for (Timer timer : (Collection<Timer>)timerService.getTimers()) {

                                                if (isMyTimer((String)timer.getInfo())) {

                                                    timer.cancel();

                                                }

                                            }

                                            deletedTimers.add(getClass());

                                        }

                                     

                                    under jboss 4.2 it works fine. Under jboss 4.2 I could say in what table the timer should be saved (in the ejb2-timer-service.xml) But now I can't tell the server what table use to save timers.

                                    1 2 Previous Next