Unable to see new MBeans in JBoss 5.0 - jboss

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();

Related

JBoss 4.0 HotDeploy

good day.
I am trying to enable hot deploy on my JBoss 4.0.
I have tried to access to localhost:9990, but it doesn't work.
Is there any alternative way to enable it?
Thanks in advance.
JBoss 4.0 contradicts to port 9990.
The port 9990 is the management console access for JBossAS7 and WildFly.
JBoss 4.0 might have a JMX console which is accessible via 8080.
You can simpel use localhost:8080 and navigate from the welcome page.
Note that hot deploy is not recommended for productional JBossAS4/5 instances because of class loading issues, OOM errors.
You might use it for development.
Also JBossAS4 does not have managed deployments, simple drop the file to server/yourProfile/deploy and it will be picked up and deployed.

Jboss EAP 6.4 Server logs are not properly updated

JBoss startup and Server logs are not getting updated completely like started in XXXX ms. But all the services are being deployed successfully. Is there any way to debug why the logs are not printing?
Thanks,
Kusuma
Just check on your the logging subsystem configuration in your standalone.xml.
If that's not the issue, this is probably a problem with your application configuration and not JBoss, probably you just have to exclude some logging libraries in your jboss-deployment-structure.xml, to use the provided and not the jboss instance libs.

Enumerating deployed EJB's and mBeans on JBoss

I am trying to find a way to enumerate the EJB's and MBeans that have been deployed to a JBoss server. I was looking down the path of somehow using the JDI Context, but all I can get are the binding names and classes. Am I barking down the wrong path looking at JNDI? What should I do?
Thx!
~Bolt
You need to look on the JMX console, rather than JNDI. You'll see a lot of stuff on there, including multiple entries for each deployed EJB. You can get a connection to the JMX server using MBeanServerLocator.locateJBoss(), and from there you can use the JMX API to iterate over the various beans.

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.

POC on JMS on 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