0

I am working on an application that utilizes a Message Driven Bean for sending e-mails. One thing I wanted to do was move most of the application constants to a constants file to make maintaining the application easier.

I tried to move the propertyValues for things like the mappedName, acknowledgeMode, destinationType, etc to a constants file, and use a static import to reference them, but that seemed to cause an error when trying to compile the application:

JMS resource not created

When I went back and removed the constants and used hardcoded strings it worked. So, my question is, in dealing with EJB's(or maybe annotations in general), must these properties be hardcoded?

user1154644
  • 4,491
  • 16
  • 59
  • 102

1 Answers1

0

The propertyValues must be a compile-time constant expresion, therefore, it can not be defined at runtime as you pretend. This limitation applies to all kinds of Java annotation it is not a restriction imposed for EJBs.

Take in mind that an alternative provided by the EJB specification is to use a deployment descriptor file instead of to annotate your code.

5.4.1Required MessageDrivenBean Metadata

A message-driven bean must be annotated with the MessageDriven annotation or denoted in the deployment descriptor as a message-driven bean.

Community
  • 1
  • 1
Gabriel Aramburu
  • 2,951
  • 2
  • 16
  • 20