# Sending JMS messages from a WebService

## Overview

This example deploys a WebServices that sends messages to a queue. The same client will then read the message from the queue, validating if the WebService could complete the message send.
This example relies on having access to a running JBoss Messaging instance. The JBoss Messaging instance must be installed and started according to the "Installation" paragraph from the release documentation. However, the example will automatically deploy its own queue, unless a queue with the same name is already deployed.
This example also relies on having access to jboss-messaging-client.jar archive that comes with the release bundle. If you run this example from an unzipped installation bundle, the example run script is correctly configured to find the client jar. Otherwise, you must modify example's build.xml accordingly.
This example will also generate client classes using wsdltools from JBoss Web Services.

## Running the example

1. Set up the JBOSS_HOME environment variable to point to the JBoss instance you deployed JBoss Messaging into. For example, if you deployed JBoss Messaging in C:\jboss-4.2.0.GA\server\messaging\deploy, then your JBOSS_HOME value should be C:\jboss-4.2.0.GA
2. Go to the example's home directory
cd ...\examples\web-services
3. Run the example:
ant
The output of a successful run should be similar to:

example@example:/workspace/jboss-messaging-1.3.0.GA/examples/web-services$ ant Buildfile: build.xml identify: [echo] ########################################################################### [echo] # Running the WebServices example # [echo] ########################################################################### [echo] The queue: testQueue [echo] The client jar: ../..//jboss-messaging-client.jar sanity-check: init: compile: war: [jar] Building jar: /workspace/jboss-messaging-1.3.0.GA/examples/web-services/output/lib/jms-web-service.war deploy: [copy] Copying 1 file to /jboss-4.2.0.GA/server/messaging/deploy sleep: [echo] Sleeping for 5 seconds ... run-wsdl-client: [get] Getting: http://127.0.0.1:8080/jms-web-service/JMSWebServiceExample?wsdl [get] To: /workspace/jboss-messaging-1.3.0.GA/examples/web-services/output/service.wsdl [wstools] log4j:WARN No appenders could be found for logger (org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory). [wstools] log4j:WARN Please initialize the log4j system properly. compile-client: [mkdir] Created dir: /workspace/jboss-messaging-1.2.0.SP2/examples/web-services/output/client-classes [javac] Compiling 5 source files to /workspace/jboss-messaging-1.2.0.SP2/examples/web-services/output/client-classes run: send-and-receive: [java] log4j:WARN No appenders could be found for logger (org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder). [java] log4j:WARN Please initialize the log4j system properly. [java] Message was received ok! [java] [java] ##################### [java] ### SUCCESS! ### [java] ##################### undeploy: [delete] Deleting: /jboss-4.2.0.GA/server/messaging/deploy/jms-web-service.war BUILD SUCCESSFUL Total time: 12 seconds

## Troublesooting

### 1. I get "javax.jms.JMSSecurityException: User null is NOT authenticated"

You probably didn't install JBoss Messaging correctly. A fresh JBoss Messaging installation requires changes in the security configuration of a default JBoss instance, specifically a properly configured "messaging" security domain. Follow the instructions from the "Installation" paragraph of the release documentation.

### 2. wstools doesn't work

You could aways using "ant -debug" to verify what Exceptions wstools is generating. A common error is a NullPointerException due to a xerces update required by JBoss Web Services. You could have more information at this page:
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBWSFAQXercesNPE