POC on JMS on Jboss - jboss

I am doing a POC for runnig JMS on JBoss 4.0.5 GA. can anyone privide me a link which shows examples on how to
Create a queue in Jboss
Crate a factory in Jboss.
Configuration
If the above are not applicable, the is there a default que, topic, factory in Jboss.

http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/Messaging_on_JBoss.html
http://www.outwardmotion.com/outwardmotion/jmsjboss1.php

The first thing to note is that JBoss 4.0.5 will be running JBossMQ by default (As opposed to the newer JBoss Messaging). The answers to some of your questions depend on what you're doing, i.e. MDBs/EJB3 or not?
Note, you'll have to add http:// to the beginning of these links, Stackoverflow is being lame and not letting me post links.
Take a look at this URL: www.java2s.com/Code/Java/EJB3/EJBTutorialfromJBossdemoformessagedrivenbean.htm
The Queue will be created for you automatically when JBoss loads the MDB in the example
Assuming you mean a JMS Connection Factory, you can inject factories and destinations into EJB3s using something like the following:
#Resource(mappedName = "queue/notification.EmailSender")
private javax.jms.Destination emailSenderQueue;
#Resource(mappedName = "QueueConnectionFactory")
private javax.jms.ConnectionFactory connectionFactory;
This is a good starting point: www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/Messaging_on_JBoss.html
Also if you're not doing EJB3 yet in Jboss 4.0.3, see: rwatsh.blogspot.com/2006/12/ejb3-development-using-jboss-405ga.html

Related

JMS web application with Eclipse and WebSphere Application Server

I am new to JMS and WAS. I am grateful if someone provides any reference that helps me to create a web application in eclipse with JMS and WAS 7.0.
Also want to get answers for below questions..
How to inject ConnectionFactory or Destination object (created in WAS) into application using jndi?
How to install and run JMS web application on WAS server?
First you need to decide on the provider for JMS. It could be WebSphere MQ, the JMS provider that comes inbuilt with WAS or some other provider too.
Refer to the redbooks https://www.redbooks.ibm.com/Redbooks.nsf/RedbookAbstracts/sg247770.html?Open.
You can use InitialContext to lookup connection factory and Destination.
You can deploy the JMS app just like any other app. But ensure that JNDI objects are configured.
This is also a nice info-center to use for reference: http://pic.dhe.ibm.com/infocenter/prodconn/v1r0m0/topic/com.ibm.scenarios.wmqwasusing.doc/topics/scenario_overview.htm

Several REST and EJB problems

I'm trying to deploy a Java EE web application with RESTful web services and an EJB connexion to another Java EE application.
I'm experiencing several problems and I fail to write down every specific question, so I have no choice but tell you all in a row.
1) First, I am using Tomcat to run the app and I cannot get EJB connexion to work. No matter what, I get a JNDI error : NamingContextFactory class not found. Why ?
My JNDI connexion is as follows :
String hostname = "localhost";
String port = "1099";
String url = "jnp://" + hostname + ":" + port + "/";
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
h.put(Context.PROVIDER_URL, url);
h.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
initialContext = new InitialContext(h);
2) Therefore, as the server used is not relevant, and as the app I'm trying to connect to is using JBoss (4.4.2.GA), I tried to deploy my app under the same JBoss. I cannot get it to deploy, I have a REST problem: ClassNotFoundException: javax.ws.rs.core.ApplicationConfig at deploy time.
2.1) I am compiling with Netbeans and the ApplicationConfig.class is not part of the 1.1 version of the JAX-RS api jsr311-api-1.1.jar I'm using at compile time. The implementation of the library was changed since 0.8 version, which I was using before, but I had to upgrade the jar because it didn't include #FormParam. Until now, I had found a workaround using com.sun.jersey.api.representation.FormParam instead but Jersey is not compatible with JBoss as far as I understand.
Why is the server looking for ApplicationConfig while it's not used in the war?
2.2) I understood I had to use RESTEasy, and JBoss 4 does not include it, so have to install it manually. But the RESTEasy doc suggest that I thoroughly modify my project my adding a lot of jars, servlets etc. From my point of view, I simply need a RESTful implementation on the server libs to which my JAX-RS API, which is only an interface, will refer once the app is deployed. I may have some serious misconceptions about how Java EE libraries linking work. Please help.
So I know there are several different problems here but I couldn't manage to separate them. I have lost so much time on this that I'm worried for my project. Thanks in advance.

TC Server Vs JBoss Server

We are planning to migrate to a new WebServer (bye bye Websphere), the main considerations are
transaction management
persistence
message/event handling
maintainability
distributed architecture
MBD/EJB support
We are very happy with TC Server but the only problem is that it does not support EJB's and MDB's and we use them pretty heavily here, I head that you can use TC Server and JBoss together, did anybody try using it that way or is there other way that we can use EJB's and MDB's with TC Server ?
Any help appreciated
/srm
If by TC you mean Apache's Tomcat, then yes: JBoss AS is bundled with an embedded Tomcat Servlet/JSP container. So, if you are happy with Tomcat, then JBoss might be a good option for you. And it supports all things you've mentioned.
JTA
JPA/Hibernate
JMS and MDB
Yes, you can have JBoss AS in cluster provided your application supports it
Of course. JavaEE containers must support MDB and EJB.

JMS without JNDI?

We are running portlets in WebSphere 6.01, using Java 1.4. We want to send JMS messages to a JBoss 5 queue, running Java 5 (or maybe 6, but it's certainly newer than 1.4). Trying to connect using JNDI is not working, since we have to include the JBoss client jars in the classpath of the portlet, and they are Java 1.5. So I get an unsupported major/minor error when I try to create the InitialContext.
Can we connect straight to JBoss without using JNDI? Or is there some way to get around this issue I can't think of?
Even if you were able to connect to JMS without going through JBoss's JNDI, you would still need to include the JBoss client JAR in order to use JMS. Both JNDI and JMS are APIs, and you need the server's implementation of that client API in order to talk to the server.
If it's just your JNDI classes that prereq Java 5 and not the JBoss classes then you can do this. But you would have to set all of the properties of the objects and that is provider-specific. The WebSphere MQ JMS samples show how to do this with WMQ and you would need to know the property and value names for JBoss to make the equivalent code. Here is a code snippet from the WMQ JmsProducer.java sample:
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();
// Set the properties
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, host);
cf.setIntProperty(WMQConstants.WMQ_PORT, port);
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channel);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManagerName);
// Create JMS objects
connection = cf.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
if (isTopic) {
destination = session.createTopic(destinationName);
}
else {
destination = session.createQueue(destinationName);
}
producer = session.createProducer(destination);
On the other hand, if your JBoss classes prereq Java 1.5 then you need to run Java 1.5 or better.
Depending on the JBoss version you can directly instantiate all the JMS objects.
One particular version:
see http://www.jboss.org/file-access/default/members/jbossmessaging/freezone/docs/usermanual-2.0.0.beta1/html/using-jms.html
(Section 5.5. Directly instantiating JMS Resources without using JNDI)
I think JNDI is the only way that you can create JMS connection factories and destinations (queue or topic), and these are your means of communication.
In fact using JNDI is a way to be independant of the JMS provider, because you can easly change it.
But if you've got no problem with that most provider offer facilities to create a connection factory and destinations
It sounds like the problem isn't with JNDI but with the conflicting classnames between the environments.
You could try doing the classloading yourself when you try to instantiate the JBOSS client classes. That way you get a separate classloader from the one that loaded the Portlet. Just make sure you understand whether you need Parent-first or Parent-last behavior. Also on that page is debugging classloading which can show you how to set the Classpath for the classloader so you can isolate the JBOSS libraries and avoid classname collisions. It is a good resource for understanding even advanced classloading issues.

Unable to see new MBeans in JBoss 5.0

I've been going through several examples on how to add MBeans to JBoss 5.0 so they can be configured though the JMX Console, but none of these examples have ever shown up in the JMX view. I've now tried to get ehCache's JMX integration to work to no avail.
I'm trying (as in the ehCache documentation) the following:
CacheManager manager = CacheManager.create("./ehcache.xml");
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ManagementService.registerMBeans(manager, mBeanServer, false, false, false, true);
I never see any errors with my own or now with the ehCache version, but it never shows up in the JMX view. I'm wondering - is there a setting I need to make to to the JBoss configuration to get it to pick up these additions? Am I missing something fundamental? Any hints?
Thanks for any help. I'm pulling my hair out here.
If you're running JBoss on Java 5 or above, then you'll likely have 2 MBean servers running: the "platform" mbean server, which is hosted by the JVM, and the JBoss MBean server, which is hosted by the JBoss code. The two have nothing to do with each other.
Your posted code will register ehcache's mbean in the JVM platform server, which is no use to you.
The easiest way to get a programmatic reference to the JBoss MBean server is
org.jboss.mx.util.MBeanServerLocator.locateJBoss()
Try using that instead of
ManagementFactory.getPlatformMBeanServer();