AS7-5265 EJB timer - @Schedule and @Timer #317

Closed
wants to merge 1 commit into
from

3 participants

@OndraZizka

No description provided.

@pmuir pmuir and 1 other commented on an outdated diff Jul 30, 2012
ejb-timer/README.md
@@ -0,0 +1,95 @@
+wicket-war: Wicket Framework used in a WAR.
+===========================================
+Author: Ondrej Zizka <ozizka@redhat.com>
+Level: Basic
@pmuir
JBoss Developer member
pmuir added a line comment Jul 30, 2012

Should be "Beginner" :-)

@OndraZizka
OndraZizka added a line comment Jul 31, 2012

I will change this, as well as remove notions of Wicket (result of copy-paste)

@OndraZizka
OndraZizka added a line comment Aug 6, 2012

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pmuir pmuir and 1 other commented on an outdated diff Jul 30, 2012
ejb-timer/README.md
+ For Linux: JBOSS_HOME/bin/standalone.sh
+ For Windows: JBOSS_HOME\bin\standalone.bat
+
+
+Build and Deploy the Quickstart
+-------------------------
+
+_NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See [Build and Deploy the Quickstarts](../README.md#buildanddeploy) for complete instructions and additional options._
+
+1. Make sure you have started the JBoss Server as described above.
+2. Open a command line and navigate to the root directory of this quickstart.
+3. Type this command to build and deploy the archive:
+
+ mvn clean package jboss-as:deploy
+
+4. This will deploy `target/jboss-as-wicket-war.war` to the running instance of the server.
@pmuir
JBoss Developer member
pmuir added a line comment Jul 30, 2012

Needs an update :-)

@OndraZizka
OndraZizka added a line comment Aug 6, 2012

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pmuir pmuir and 1 other commented on an outdated diff Jul 30, 2012
...org/jboss/as/quickstarts/ejbTimer/TimeoutExample.java
+
+/**
+ * Demonstrates how to use the EJB's @Timeout.
+ *
+ * @author <a href="mailto:ozizka@redhat.com">Ondrej Zizka</a>
+ */
+@Singleton
+@Startup
+public class TimeoutExample {
+
+ @Resource
+ private TimerService timerService;
+
+ @Timeout
+ public void scheduler(Timer timer) {
+ System.out.println("SingletonTimer: Info="+timer.getInfo());
@pmuir
JBoss Developer member
pmuir added a line comment Jul 30, 2012

Some more spaces might be nice here.

@OndraZizka
OndraZizka added a line comment Aug 6, 2012

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pmuir pmuir and 1 other commented on an outdated diff Jul 30, 2012
ejb-timer/src/main/webapp/WEB-INF/web.xml
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <display-name>JBoss AS Quickstart: Wicket WAR</display-name>
+
+ <!-- A message displayed on the page, externalized into web.xml -->
+ <env-entry>
+ <env-entry-name>welcomeMessage</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>Welcome to the JBoss AS Quickstart showing the use of Wicket, packaged in an EAR</env-entry-value>
+ </env-entry>
+
+</web-app>
@pmuir
JBoss Developer member
pmuir added a line comment Jul 30, 2012

Do we need this file at all?

@OndraZizka
OndraZizka added a line comment Jul 31, 2012

Nope :) I originally intended to make it a web app, but keeping web out keeps it much clearer.

@OndraZizka
OndraZizka added a line comment Aug 6, 2012

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pmuir pmuir and 1 other commented on an outdated diff Jul 30, 2012
...r/src/main/webapp/WEB-INF/ejb-timer-quickstart-ds.xml
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_1.xsd">
+ <!-- The datasource is bound into JNDI at this location. We reference
+ this in META-INF/persistence.xml -->
+ <datasource jndi-name="java:jboss/datasources/EjbTimerQuickstartDS"
+ pool-name="ejb-timer-quickstart" enabled="true"
+ use-java-context="true">
+ <connection-url>jdbc:h2:mem:ejb-timer-quickstart;DB_CLOSE_ON_EXIT=FALSE</connection-url>
+ <driver>h2</driver>
+ <security>
+ <user-name>sa</user-name>
+ <password>sa</password>
+ </security>
+ </datasource>
+</datasources>
+
@pmuir
JBoss Developer member
pmuir added a line comment Jul 30, 2012

Probable we don't need a DS at all?

@OndraZizka
OndraZizka added a line comment Jul 31, 2012

Regarding DS - I thought it might be necessary for persistent timeouts. But that's probably only true for AS 5 and 6, right? AS 7 puts this to files?

@pmuir
JBoss Developer member
pmuir added a line comment Aug 3, 2012

I think the app server will just use it's own persistent store for that, not one you define.

@OndraZizka
OndraZizka added a line comment Aug 6, 2012

Removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pmuir pmuir and 1 other commented on an outdated diff Jul 30, 2012
ejb-timer/src/main/webapp/WEB-INF/beans.xml
+ the copyright.txt in the distribution for a full listing of individual contributors.
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+<!-- This file can be an empty text file (0 bytes) -->
+<!-- We're declaring the schema to save you time if you do have to configure
+ this in the future -->
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
@pmuir
JBoss Developer member
pmuir added a line comment Jul 30, 2012

Does this use CDI?

@OndraZizka
OndraZizka added a line comment Jul 31, 2012

I am so messy. Will fix.

@OndraZizka
OndraZizka added a line comment Aug 6, 2012

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda

Following the instructions in the README, I get a deployment errror. This is in the server log:

14:25:11,069 INFO org.jboss.weld.deployer JBAS016005: Starting Services for CDI deployment: jboss-as-ejb-timer.war
14:25:11,093 INFO org.jboss.as.connector.subsystems.datasources JBAS010400: Bound data source [jboss/datasources/EjbTimerQuickstartDS]
14:25:11,228 INFO org.jboss.as.server JBAS015870: Deploy of deployment "jboss-as-ejb-timer.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"jboss-as-ejb-timer.war#primary\"jboss.naming.context.java.jboss.datasources.WicketQuickstartDSMissing[jboss.persistenceunit.\"jboss-as-ejb-timer.war#primary\"jboss.naming.context.java.jboss.datasources.WicketQuickstartDS]"]}
14:25:11,237 INFO org.jboss.as.connector.subsystems.datasources JBAS010409: Unbound data source [jboss/datasources/EjbTimerQuickstartDS]
14:25:11,251 INFO org.jboss.as.server.deployment JBAS015877: Stopped deployment jboss-as-ejb-timer.war in 24ms
14:25:11,253 INFO org.jboss.as.controller JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.jboss.datasources.WicketQuickstartDS (missing) dependents: [service jboss.persistenceunit."jboss-as-ejb-timer.war#primary

As Pete suggested, maybe the datasource isn't needed?

@sgilda

I got it to work by doing the following:

  • I removed the resources/ directory and its contents as you don't need the persistence.xml file.
  • I removed the webapp/WEB-INF/ejb-timer-quickstart-ds.xml file.

Removing the web.xml file resulted in the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project jboss-as-ejb-timer: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

I got around that by adding this plugin to the pom.xml build section:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<!-- Java EE 6 doesn't require web.xml, Maven needs to catch
up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

@OndraZizka

I've reflected all comments and pushed the result.

@sgilda

When I build and deploy this, I get BUILD FAILURE and this error in the server log:

10:33:47,348 INFO org.jboss.as.server JBAS015870: Deploy of deployment "jboss-as-ejb-timer.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"jboss-as-ejb-timer.war#primary\"jboss.naming.context.java.jboss.datasources.WicketQuickstartDSMissing[jboss.persistenceunit.\"jboss-as-ejb-timer.war#primary\"jboss.naming.context.java.jboss.datasources.WicketQuickstartDS]"]}
10:33:47,357 INFO org.jboss.as.server.deployment JBAS015877: Stopped deployment jboss-as-ejb-timer.war in 8ms
10:33:47,358 INFO org.jboss.as.controller JBAS014774: Service status report
JBAS014776: Newly corrected services:
service jboss.naming.context.java.jboss.datasources.WicketQuickstartDS (new available)

You removed the datasource, but I believe you also need to remove the persistence.xml file as well since it is not needed. It deploys fine when I remove it.

Also, would you mind squashing all the commits into one so it's easier to review? :-)

@pmuir
JBoss Developer member

@OndraZizka just a quick status check

@OndraZizka

Ah, right... I will fix this during this week, hopefully.

@sgilda

20121217: Sent email reminder.

@sgilda

2013-04-09: At the time we last talked, this only had a minor issue to remove the persistence.xml file and squash the commits.

I ran the QS Tools report and believe the only other changes required are the following:

  • Add the following metadata to the README.md file:

    Target Product: EAP
    Source: <https://github.com/jboss-jdf/jboss-as-quickstart/>
    
  • Make sure the licenses match the license template in the root of the quickstart directory.

@sgilda

@OndraZizka : Just checking in to see how things are going with your quickstart. Please let me know when it's ready for review again.

@sgilda

@OndraZizka : Just checking on the status of this quickstart. :-)

@sgilda

@OndraZizka thinks this will be a quick fix and hopes to finish it up in the next week.

@sgilda

Sent email to @OndraZizka to let him know we will be closing pull requests in a few days to reorganize the quickstarts, so this needs to be finished ASAP.

@sgilda

Since I haven't had a response from Ondra, I will close this one for now. He can repen it at a later date.

@sgilda sgilda closed this Aug 21, 2013
@sgilda sgilda reopened this Aug 21, 2013
@OndraZizka

Now it should be okay to merge.

@sgilda

Thanks Ondra. I'll check it out next!

@sgilda

@OndraZizka : There 41 files changed in your 6 commits. The first commit even says
Java source 1.6 for some quickstarts, mostly DeltaSpike

I believe you should only have 4 files committed for this quickstart. Can you clean up the commits so that only the ejb-timer source is included?

Also, can you run the QS tools utility on your quickstart? It's reporting some violations. Some are due to changes since you started this quickstart. See step 8 here: https://github.com/jboss-jdf/jboss-as-quickstart/blob/master/CONTRIBUTING.md

I did test the quickstart and it compiles, deploys, and works fine.

@sgilda sgilda and 1 other commented on an outdated diff Aug 23, 2013
ejb-timer/README.md
@@ -0,0 +1,98 @@
+ejb-timer: EJB Timers example - @Schedule and @Timeout
+===========================================
+Author: Ondrej Zizka <ozizka@redhat.com>
+Level: Beginner
+Technologies: EJB 3.1 Timer
+Summary: Demonstrates how to use EJB 3.1 Timer (@Schedule and @Timeout) with the JBoss AS server.
+
@sgilda
sgilda added a line comment Aug 23, 2013

Please add the following:

Target Product: EAP
Source: https://github.com/jboss-jdf/jboss-as-quickstart/

@OndraZizka
OndraZizka added a line comment Aug 24, 2013

Can't get rid of Content for metadata [Source: = https://github.com/jboss-jdf/jboss-as-quickstart/] should follow the [<(http|https)://\w.*>] pattern

The other warnings are gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda and 1 other commented on an outdated diff Aug 23, 2013
ejb-timer/pom.xml
+ </licenses>
+
+ <description>
+ A sample JAVA EE 6 project demonstrating how to use EJB 3.1 timer (@Schedule and @Timeout).
+ </description>
+
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <!-- Define the version of JBoss' Java EE 6 APIs we want to import. -->
+ <jboss.spec.version>3.0.0.Final</jboss.spec.version>
+ <!-- Alternatively, comment out the above line, and un-comment the
+ line below to use version 3.0.0.Final-redhat-1 which is a release certified
+ to work with JBoss EAP 6. It requires you have access to the JBoss EAP 6
+ maven repository. -->
+ <!-- <jboss.spec.version>3.0.0.Final-redhat-1</jboss.spec.version> -->
@sgilda
sgilda added a line comment Aug 23, 2013

These property names were changed and the versions have been updated. This section should now be:

    <version.jboss.spec.javaee.6.0>3.0.2.Final</version.jboss.spec.javaee.6.0>
    <!-- Alternatively, comment out the above line, and un-comment the 
        line below to use version 3.0.2.Final-redhat-3 which is a release certified 
        to work with JBoss EAP 6. It requires you have access to the JBoss EAP 6 
        maven repository. -->
    <!-- <version.jboss.spec.javaee.6.0>3.0.2.Final-redhat-3</version.jboss.spec.javaee.6.0> -->
@OndraZizka
OndraZizka added a line comment Aug 24, 2013

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda and 1 other commented on an outdated diff Aug 23, 2013
ejb-timer/pom.xml
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- JBoss distributes a complete set of Java EE 6 APIs including
+ a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
+ a collection) of artifacts. We use this here so that we always get the correct
+ versions of artifacts. Here we use the jboss-javaee-6.0-with-tools stack
+ (you can read this as the JBoss stack of the Java EE 6 APIs, with some extras
+ tools for your project, such as Arquillian for testing) and the jboss-javaee-6.0-with-hibernate
+ stack you can read this as the JBoss stack of the Java EE 6 APIs, with extras
+ from the Hibernate family of projects) -->
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${jboss.spec.version}</version>
@sgilda
sgilda added a line comment Aug 23, 2013
    <version>${version.jboss.spec.javaee.6.0}</version>
@OndraZizka
OndraZizka added a line comment Aug 24, 2013

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda and 1 other commented on an outdated diff Aug 23, 2013
ejb-timer/pom.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0"?>
+<!-- JBoss, Home of Professional Open Source Copyright 2012, Red Hat, Inc.
+ and/or its affiliates, and individual contributors by the @authors tag. See
+ the copyright.txt in the distribution for a full listing of individual contributors.
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
@sgilda
sgilda added a line comment Aug 23, 2013

This license text is out of date. You can copy it from one of he other quickstart POM files. It should be:

@OndraZizka
OndraZizka added a line comment Aug 24, 2013

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda and 1 other commented on an outdated diff Aug 23, 2013
ejb-timer/pom.xml
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <distribution>repo</distribution>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+ </license>
+ </licenses>
+
+ <description>
+ A sample JAVA EE 6 project demonstrating how to use EJB 3.1 timer (@Schedule and @Timeout).
+ </description>
+
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <!-- Define the version of JBoss' Java EE 6 APIs we want to import. -->
+ <jboss.spec.version>3.0.0.Final</jboss.spec.version>
@sgilda
sgilda added a line comment Aug 23, 2013

Before this line, define the maven plugin property here:

    <version.jboss.maven.plugin>7.3.Final</version.jboss.maven.plugin>
@OndraZizka
OndraZizka added a line comment Aug 24, 2013

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda and 1 other commented on an outdated diff Aug 23, 2013
ejb-timer/pom.xml
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <!-- Set the name of the war, used as the context root when the app
+ is deployed. -->
+ <finalName>${project.artifactId}</finalName>
+
+ <plugins>
+ <!-- JBoss AS plugin to deploy the war. -->
+ <plugin>
+ <groupId>org.jboss.as.plugins</groupId>
+ <artifactId>jboss-as-maven-plugin</artifactId>
+ <version>7.4.Final</version>
@sgilda
sgilda added a line comment Aug 23, 2013

We don't use hard-coded versions. Use the property:

    <version>${version.jboss.maven.plugin}</version>
@OndraZizka
OndraZizka added a line comment Aug 23, 2013

Just for this one or any plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda commented on the diff Aug 23, 2013
...rg/jboss/as/quickstarts/ejbTimer/ScheduleExample.java
@@ -0,0 +1,21 @@
+
@sgilda
sgilda added a line comment Aug 23, 2013

This file is missing the license header.

@OndraZizka
OndraZizka added a line comment Aug 24, 2013

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda commented on the diff Aug 23, 2013
...org/jboss/as/quickstarts/ejbTimer/TimeoutExample.java
@@ -0,0 +1,44 @@
+
@sgilda
sgilda added a line comment Aug 23, 2013

This file is missing the license header.

@OndraZizka
OndraZizka added a line comment Aug 24, 2013

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@OndraZizka

Regarding "Java source 1.6 for some quickstarts, mostly DeltaSpike", that's because those were unbuildable. They need the changes, otherwise fail to compile as Java 1.3 source format. But I'll remove these changes and offer as separate PR.

@OndraZizka

Squashed to one commit. Removed DeltaSpike stuff.

@sgilda

@OndraZizka : This looks much better. I'll review it tomorrow.

@sgilda

@OndraZizka - This looks good. One minor issue is still reported by the QS tools utility. The URL for the 'Source:' metadata tag should be linkable: Source: <https://github.com/jboss-jdf/jboss-as-quickstart/>. I can fix what when I merge it.

@VineetReynolds will do a code review on this tomorrow and if he gives the word, I will merge.

@VineetReynolds VineetReynolds and 1 other commented on an outdated diff Aug 27, 2013
...org/jboss/as/quickstarts/ejbTimer/TimeoutExample.java
+@Singleton
+@Startup
+public class TimeoutExample {
+
+ @Resource
+ private TimerService timerService;
+
+ @Timeout
+ public void scheduler(Timer timer) {
+ System.out.println("EJB Timer: Info=" + timer.getInfo());
+ }
+
+ @PostConstruct
+ public void initialize( InvocationContext ctx ) {
+ ScheduleExpression se = new ScheduleExpression();
+ // Set schedule to every 10 seconds.
@VineetReynolds
JBoss Developer member
VineetReynolds added a line comment Aug 27, 2013

The 'second' expression for the ScheduleExpressions is '0/3' which implies 'every 3 seconds starting at second 0' i.e. 0,3,6,9,...57,60 seconds. So this comment should not read 'every 10 seconds'. Maybe you could incorporate what I wrote in the previous sentence.

Otherwise this looks good.

@OndraZizka
OndraZizka added a line comment Aug 27, 2013

Right. I changed to more frequent and forgot to change the comment. Changing.

@OndraZizka
OndraZizka added a line comment Aug 28, 2013

// Set schedule to every 3 seconds (starting at second 0 of every minute).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda

Made minor adjustments to fix new qstools issues and merged.

@sgilda sgilda closed this Aug 28, 2013
@OndraZizka

I see, so the <...> brackets are meant literally... I thought it's JUnit's style string comparison. Get it.

@sgilda

@OndraZizka : Are you referring to the change I made to the Source metadata URL?

@OndraZizka

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment