0

I'm facing the following exception while migrating to JBOSS EAP 7.3 from EAP 6.4.9.

ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 72) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "xxx.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"xxx.war\".WeldStartService" => "Failed to start service Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000805: Cannot have more than one post construct method annotated with @PostConstruct for [EnhancedAnnotatedTypeImpl] public @ManagedBean class com.xxxx.xxxx.SampleManagedBean"}} ERROR [org.jboss.as.server] (ServerService Thread Pool -- 72) WFLYSRV0021: Deploy of deployment "xxxx.war" was rolled back with the following failure message: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"xxxx.war\".WeldStartService" => "Failed to start service Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000805: Cannot have more than one post construct method annotated with @PostConstruct for [EnhancedAnnotatedTypeImpl] public @ManagedBean class com.xxxx.xxxxx.SampleManagedBean"}}

It worked well in EAP6.4.The issue is occuring in EAP 7 and above versions. Any suggestions on this would do a great favor. Thanks in advance.

tgallei
  • 827
  • 3
  • 13
  • 22
subha
  • 1
  • 1
  • 1
    Check your `com.xxxx.xxxx.SampleManagedBean` class, it apparently has two `@PostConstruct` methods which EAP 7.3 doesn't seem to like. I would suggest creating a new method `@PostConstruct` which will call the two current `@PostConstruct` methods from which you should remove the annotation – Aaron May 14 '20 at 10:38
  • Do we have any other options rather than changing the code..I mean,like importing any dependency libs? – subha May 15 '20 at 05:12
  • I doubt so, your JBoss EAP is correctly following specifications. I'm surprised EAP 6.4 didn't, as this constraint [isn't new](https://docs.oracle.com/javase/6/docs/api/javax/annotation/PostConstruct.html) – Aaron May 15 '20 at 08:42
  • If [this](https://stackoverflow.com/questions/22400705/multiple-postconstruct-methods) is still true and your app runs on Spring maybe you could try desactivating WELD. That said updating your code to conform to the standards would definitely be best – Aaron May 15 '20 at 08:49

1 Answers1

1

The javadoc for @PostConstruct specifies that :

Only one method can be annotated with this annotation

The error log shows us JBoss EAP 7.3 complaining that the com.xxxx.xxxx.SampleManagedBean class has more than one such methods. I suggest creating a new method @PostConstruct in this class which would call the two other methods, from which the annotation should be removed.

This is not a bug of JBoss EAP 7.3 and I doubt you can avoid fixing the class.

Aaron
  • 24,009
  • 2
  • 33
  • 57