[jboss-jira] [JBoss JIRA] (WFLY-4251) @DependsOn not adherent to Java EE 7 spec

Matteo Mortari (JIRA) issues at jboss.org
Wed Jan 14 14:04:49 EST 2015


     [ https://issues.jboss.org/browse/WFLY-4251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matteo Mortari updated WFLY-4251:
---------------------------------
    Description: 
*Premise*: actually, I'm leveraging this misalignment for implementing a functionality; however, I don't believe is correct behavior accordingly to Java EE 7 specs, hence reporting it.


h5. Executive summary
With reference to attached reproducer, and example scenario below; the {{@DependsOn}} annotation on wildfly 8.2.0.Final works also against Stateless EJB, but accordingly to Java EE 7 specs {{@DependsOn}} annotation:
{quote}
Used to express an initialization dependency between singleton components.
{quote}


h5. Detailed description
Assume you have a {{@Singleton}} and while on {{@PreDestroy}} you need to persist some entities, which are normally done through a Stateless EJB serving as a "Controller"/"DAO", example:
{code:java}
@Singleton
@Startup
//@DependsOn(value={"AStatelessEJB"})
public class SingletonEJB {
	private static final Logger LOG = LoggerFactory.getLogger(SingletonEJB.class);
	
	@EJB
	private AStatelessEJB sl;
	
	@PostConstruct
	public void init() {
		LOG.info("SingletonEJB is here.");
	}
	
	@PreDestroy
	public void shutdown() {
		LOG.info("SingletonEJB is about to shutdown...");
		sl.dummyPersist(); // line #30
	}
}
{code}
with the {{@DependsOn}} annotation currently commented, and where:
{code:java}
@Stateless(name="AStatelessEJB", mappedName="AStatelessEJB")
public class AStatelessEJB {
	private static final Logger LOG = LoggerFactory.getLogger(AStatelessEJB.class);
			
	public void dummyPersist() {
		LOG.info("called dummyPersist().");
	}
}
{code}
just for simulating a "controller"/"DAO" example as a Stateless EJB.

Invoking wildfly shutdown will produce the following stacktrace:
{noformat}
19:26:34,570 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 98671ms - Started 347 of 399 services (107 services are lazy, passive or on-demand)
19:26:45,136 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017535: Unregistered web context: /wildfly82-dependson
...
19:26:45,213 INFO  [com.acme.wildfly82_dependson.SingletonEJB] (ServerService Thread Pool -- 24) SingletonEJB is about to shutdown...
...
19:26:45,213 ERROR [org.jboss.as.ejb3.invocation] (ServerService Thread Pool -- 24) JBAS014134: EJB Invocation failed on component AStatelessEJB for method public void com.acme.wildfly82_dependson.AStatelessEJB.dummyPersist(): org.jboss.as.ejb3.component.EJBComponentUnavailableException: 
JBAS014559: Invocation cannot proceed as component is shutting down
...
	at com.acme.wildfly82_dependson.AStatelessEJB$$$view2.dummyPersist(Unknown Source) [classes:]
	at com.acme.wildfly82_dependson.SingletonEJB.shutdown(SingletonEJB.java:30) [classes:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_05]
{noformat}

However, with the annotation un-commented and active:
{noformat}
19:21:44,713 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 109462ms - Started 347 of 399 services (107 services are lazy, passive or on-demand)
...
19:22:17,908 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017535: Unregistered web context: /wildfly82-dependson
19:22:17,971 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017532: Host default-host stopping
...
19:22:18,017 INFO  [com.acme.wildfly82_dependson.SingletonEJB] (ServerService Thread Pool -- 68) SingletonEJB is about to shutdown...
19:22:18,033 INFO  [com.acme.wildfly82_dependson.AStatelessEJB] (ServerService Thread Pool -- 68) called dummyPersist().
...
19:22:18,236 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment wildfly82-dependson.war (runtime-name: wildfly82-dependson.war) in 334ms
{noformat}

But I'm puzzled because as stated above the Java EE specs javadoc describe the {{@DependsOn}} annotation as _Used to express an initialization dependency between singleton components._ , therefore although I'm happy it actually works, I'm puzzled about the misalignments, hence reporting it.


h5. Conclusions
I have the following questions, please?
* Can you clarify if this is the correct or intended behavior of the annotation on Wildfly?
* In the case the implementation of this annotation will be put in future release to adhere strictly to the Java EE 7 specs, what should be the correct way to implement the above scenario, in an alternative way?

(If this instead will not be modified, in other words the Wildfly implementation of the annotation will be more wide than the JavaEE 7 specs, then I got nothing to do as the application is already working and sorry for this report, but I thought worthy to mention).

  was:
*Premise*: actually, I'm leveraging this misalignment for implementing a functionality; however, I don't believe is correct behavior accordingly to Java EE 7 specs, hence reporting it.


h5. Executive summary
With reference to attached reproducer, and example scenario below; the {{@DependsOn}} annotation on wildfly 8.2.0.Final works also against Stateless EJB, but accordingly to Java EE 7 specs {{@DependsOn}} annotation:
{quote}
Used to express an initialization dependency between singleton components.
{quote}


h5. Detailed description
Assume you have a {{@Singleton}} and while on {{@PreDestroy}} you need to persist some entities, which are normally done through a Stateless EJB serving as a "Controller"/"DAO", example:
{code:java}
@Singleton
@Startup
//@DependsOn(value={"AStatelessEJB"})
public class SingletonEJB {
	private static final Logger LOG = LoggerFactory.getLogger(SingletonEJB.class);
	
	@EJB
	private AStatelessEJB sl;
	
	@PostConstruct
	public void init() {
		LOG.info("SingletonEJB is here.");
	}
	
	@PreDestroy
	public void shutdown() {
		LOG.info("SingletonEJB is about to shutdown...");
		sl.dummyPersist(); // line #30
	}
}
{code}
with the {{@DependsOn}} annotation currently commented, and where:
{code:java}
@Stateless(name="AStatelessEJB", mappedName="AStatelessEJB")
public class AStatelessEJB {
	private static final Logger LOG = LoggerFactory.getLogger(AStatelessEJB.class);
			
	public void dummyPersist() {
		LOG.info("called dummyPersist().");
	}
}
{code}
just for simulating a "controller"/"DAO" example as a Stateless EJB.

Invoking wildfly shutdown will produce the following stacktrace:
{noformat}
19:26:34,570 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 98671ms - Started 347 of 399 services (107 services are lazy, passive or on-demand)
19:26:45,136 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017535: Unregistered web context: /wildfly82-dependson
...
19:26:45,213 INFO  [com.acme.wildfly82_dependson.SingletonEJB] (ServerService Thread Pool -- 24) SingletonEJB is about to shutdown...
...
19:26:45,213 ERROR [org.jboss.as.ejb3.invocation] (ServerService Thread Pool -- 24) JBAS014134: EJB Invocation failed on component AStatelessEJB for method public void com.acme.wildfly82_dependson.AStatelessEJB.dummyPersist(): org.jboss.as.ejb3.component.EJBComponentUnavailableException: 
JBAS014559: Invocation cannot proceed as component is shutting down
...
	at com.acme.wildfly82_dependson.AStatelessEJB$$$view2.dummyPersist(Unknown Source) [classes:]
	at com.acme.wildfly82_dependson.SingletonEJB.shutdown(SingletonEJB.java:30) [classes:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_05]
{noformat}

However, with the annotation un-commented and active:
{noformat}
19:21:44,713 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 109462ms - Started 347 of 399 services (107 services are lazy, passive or on-demand)
...
19:22:17,908 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017535: Unregistered web context: /wildfly82-dependson
19:22:17,971 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017532: Host default-host stopping
...
19:22:18,017 INFO  [com.acme.wildfly82_dependson.SingletonEJB] (ServerService Thread Pool -- 68) SingletonEJB is about to shutdown...
19:22:18,033 INFO  [com.acme.wildfly82_dependson.AStatelessEJB] (ServerService Thread Pool -- 68) called dummyPersist().
...
19:22:18,236 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment wildfly82-dependson.war (runtime-name: wildfly82-dependson.war) in 334ms
{noformat}

But I'm puzzled because as stated above the Java EE specs javadoc describe the {{@DependsOn}} annotation as _Used to express an initialization dependency between singleton components._ , therefore although I'm happy it actually works, I'm puzzled about the misalignments, hence reporting it.



> @DependsOn not adherent to Java EE 7 spec
> -----------------------------------------
>
>                 Key: WFLY-4251
>                 URL: https://issues.jboss.org/browse/WFLY-4251
>             Project: WildFly
>          Issue Type: Bug
>          Components: EE, EJB
>    Affects Versions: 8.2.0.Final
>            Reporter: Matteo Mortari
>            Assignee: Jason Greene
>            Priority: Minor
>         Attachments: 20150114.wildfly82_dependson.zip
>
>
> *Premise*: actually, I'm leveraging this misalignment for implementing a functionality; however, I don't believe is correct behavior accordingly to Java EE 7 specs, hence reporting it.
> h5. Executive summary
> With reference to attached reproducer, and example scenario below; the {{@DependsOn}} annotation on wildfly 8.2.0.Final works also against Stateless EJB, but accordingly to Java EE 7 specs {{@DependsOn}} annotation:
> {quote}
> Used to express an initialization dependency between singleton components.
> {quote}
> h5. Detailed description
> Assume you have a {{@Singleton}} and while on {{@PreDestroy}} you need to persist some entities, which are normally done through a Stateless EJB serving as a "Controller"/"DAO", example:
> {code:java}
> @Singleton
> @Startup
> //@DependsOn(value={"AStatelessEJB"})
> public class SingletonEJB {
> 	private static final Logger LOG = LoggerFactory.getLogger(SingletonEJB.class);
> 	
> 	@EJB
> 	private AStatelessEJB sl;
> 	
> 	@PostConstruct
> 	public void init() {
> 		LOG.info("SingletonEJB is here.");
> 	}
> 	
> 	@PreDestroy
> 	public void shutdown() {
> 		LOG.info("SingletonEJB is about to shutdown...");
> 		sl.dummyPersist(); // line #30
> 	}
> }
> {code}
> with the {{@DependsOn}} annotation currently commented, and where:
> {code:java}
> @Stateless(name="AStatelessEJB", mappedName="AStatelessEJB")
> public class AStatelessEJB {
> 	private static final Logger LOG = LoggerFactory.getLogger(AStatelessEJB.class);
> 			
> 	public void dummyPersist() {
> 		LOG.info("called dummyPersist().");
> 	}
> }
> {code}
> just for simulating a "controller"/"DAO" example as a Stateless EJB.
> Invoking wildfly shutdown will produce the following stacktrace:
> {noformat}
> 19:26:34,570 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 98671ms - Started 347 of 399 services (107 services are lazy, passive or on-demand)
> 19:26:45,136 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017535: Unregistered web context: /wildfly82-dependson
> ...
> 19:26:45,213 INFO  [com.acme.wildfly82_dependson.SingletonEJB] (ServerService Thread Pool -- 24) SingletonEJB is about to shutdown...
> ...
> 19:26:45,213 ERROR [org.jboss.as.ejb3.invocation] (ServerService Thread Pool -- 24) JBAS014134: EJB Invocation failed on component AStatelessEJB for method public void com.acme.wildfly82_dependson.AStatelessEJB.dummyPersist(): org.jboss.as.ejb3.component.EJBComponentUnavailableException: 
> JBAS014559: Invocation cannot proceed as component is shutting down
> ...
> 	at com.acme.wildfly82_dependson.AStatelessEJB$$$view2.dummyPersist(Unknown Source) [classes:]
> 	at com.acme.wildfly82_dependson.SingletonEJB.shutdown(SingletonEJB.java:30) [classes:]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_05]
> {noformat}
> However, with the annotation un-commented and active:
> {noformat}
> 19:21:44,713 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.0.Final "Tweek" started in 109462ms - Started 347 of 399 services (107 services are lazy, passive or on-demand)
> ...
> 19:22:17,908 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017535: Unregistered web context: /wildfly82-dependson
> 19:22:17,971 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017532: Host default-host stopping
> ...
> 19:22:18,017 INFO  [com.acme.wildfly82_dependson.SingletonEJB] (ServerService Thread Pool -- 68) SingletonEJB is about to shutdown...
> 19:22:18,033 INFO  [com.acme.wildfly82_dependson.AStatelessEJB] (ServerService Thread Pool -- 68) called dummyPersist().
> ...
> 19:22:18,236 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment wildfly82-dependson.war (runtime-name: wildfly82-dependson.war) in 334ms
> {noformat}
> But I'm puzzled because as stated above the Java EE specs javadoc describe the {{@DependsOn}} annotation as _Used to express an initialization dependency between singleton components._ , therefore although I'm happy it actually works, I'm puzzled about the misalignments, hence reporting it.
> h5. Conclusions
> I have the following questions, please?
> * Can you clarify if this is the correct or intended behavior of the annotation on Wildfly?
> * In the case the implementation of this annotation will be put in future release to adhere strictly to the Java EE 7 specs, what should be the correct way to implement the above scenario, in an alternative way?
> (If this instead will not be modified, in other words the Wildfly implementation of the annotation will be more wide than the JavaEE 7 specs, then I got nothing to do as the application is already working and sorry for this report, but I thought worthy to mention).



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the jboss-jira mailing list