0
votes

I have a Java ee 7 JMS app, I would like deploy it on CloudBees. I have tried a simple app with cloudAMQP, it work. But CloudAMQP offers hosted RabbitMQ service. I have to use JMS client, because my code is implement in java JMS.

The last day, I have create a glassfish 4 broker in Amazon Ec2, I have deployed a simple JMS app in CloudBees glassfish web profile platform and I have expected it can work with my Amazon glassfish broker. But there is a error.

My code is:

@JMSConnectionFactoryDefinition(
    name="java:comp/jms/__defaultConnectionFactory",
    maxPoolSize = 30,
    minPoolSize= 20,
    properties = {
        "addressList=mq://ec2-54-194-27-99.eu-west-1.compute.amazonaws.com:7676",
        "reconnectEnabled=true"
    }
) 

@JMSDestinationDefinition(
    name = "java:comp/jms/webappQueue",
    interfaceName = "javax.jms.Queue",
    destinationName = "PhysicalWebappQueue")

    @Named
    @RequestScoped
    public class ReceiverBean {

        static final Logger logger = Logger.getLogger("ReceiverBean");
        @Inject
        private JMSContext context;
        @Resource(lookup = "java:comp/jms/webappQueue")
        private Queue queue;
       .....

    public void getMessage() {
            try {
                JMSConsumer receiver = context.createConsumer(queue);
                String text = receiver.receiveBody(String.class, 1000);

                if (text != null) {
                    FacesMessage facesMessage =
                            new FacesMessage("Reading message: " + text);
                    FacesContext.getCurrentInstance().addMessage(null, facesMessage);
                } else {
                    FacesMessage facesMessage =
                            new FacesMessage("No message received after 1 second");
                    FacesContext.getCurrentInstance().addMessage(null, facesMessage);
                }
            } catch (JMSRuntimeException t) {
                logger.log(Level.SEVERE,
                        "ReceiverBean.getMessage: Exception: {0}",
                        t.toString());
            }
        }

The error is

|2013-11-17T22:34:09.146+0000|SEVERE|glassfish 4.0|javax.enterprise.system.core|_ThreadID=45;_ThreadName=AutoDeployer;_TimeMillis=1384727649146;_LevelValue=1000;|

Exception while loading the app : CDI deployment failure:Exception List with 2 exceptions:

Exception 0 :

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [JMSContext] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private javaeetutorial.websimplemessage.SenderBean.context]

Can you have some ideas for my case? Thanks in advance.

1

1 Answers

0
votes

Web profile don't include JMS, so this API and related annotation / injection isn't supported. For this to work you need a full-profile JavaEE + adequate configuration set in container to plug your broker. Probably simpler to use vanila JMS API vs annotation-driven integration