trying to create ejb3 MDB with standalone client. When deployed tar file server throwing jms not found error. It is from ejb3 in action book.
My client
public static void main(String[] args) {
Destination destination;
ConnectionFactory connectionFactory;
long item = 10101;
String address = "101 Easy Street";
String method = "Snail mail";
double amount = 101.00;
try {
Context context = new InitialContext();
destination = (Destination) context
.lookup("java:comp/env/jms/ShippingRequestQueue");
connectionFactory = (ConnectionFactory) context
.lookup("ConnectionFactory");
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
and my MDB
@MessageDriven(name = "ShippingRequestProcessor", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/ShippingRequestQueue") })
public class ShippingRequestProcessorMDB implements MessageListener {
private Connection connection;
private DataSource dataSource;
@Resource
private MessageDrivenContext context;
@Resource(name = "jdbc/TurtleDS", mappedName = "java:/DefaultDS")
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@PostConstruct
public void initialize() {
try {
connection = dataSource.getConnection();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
Enev when i tried to run it it says same. JMS not bound..
Any help please?
The "destination" property should be the global jndi name
not the java:comp/env alias.
The java:/comp/env alias will only work in the client if you've configured jndi
to use an appclient context deployed in the appserver.