Enumerating deployed EJB's and mBeans on JBoss - 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.

Related

Can't Access ActiveMQ Web Console

I am having trouble accessing ActiveMQ's web console.
On their website it says you can access the console through the URL : localhost:8161/admin
But all I get when I try this is "This webpage is not available"
I found another site saying I can access it through port '61616', which gives me a response in the form of the following :
I have done some extensive searching on this issue, and have found others with the same problem, but have not come across a solution.
I am fairly new to using ActiveMQ so please excuse me if I have left out any relevant information.
Any help is greatly appreciated.
The admin console is a web application (WAR-file) deployed in an embedded Jetty server that starts up along with ActiveMQ standalone distribution.
Since you intend to run ActiveMQ inside a web application inside Tomcat, it would not make sense to fire up a jetty server.
Simply deploy the web console WAR to your Tomcat. You need to point out the JMS/OpenWire connection URI as well as JMX connection URI to ActiveMQ Web Console to get it going. Typically in Tomcat setenv.sh (or similar file):
JAVA_OPTS="$JAVA_OPTS -Dwebconsole.type=properties -Dwebconsole.jms.url=tcp://localhost:61616- Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi -Dwebconsole.jmx.user=admin -Dwebconsole.jmx.password=mypassw0rd"
This requires you to have JMX setup on your Tomcat instance. If not, check this Tomcat doc page out.
This will deploy the console just like any app in your Tomcat (not port 8161).
Off-topic, but a nice feature with decoupling the web console from the actual broker is that you can access a the activem broker of a master/slave pair using failover protocol and comma separated jmx settings.

Jboss EAR with EJB and webservice health monitoring and management

I am using Jboss5.1 and I have a EAR1 deployed which has a EJB3 component implemented using #Stateless annotation and the same EJB is also exposed as webservice using the annotation #webservice.
I want to check through a EJB service/management service bean(Packaged in another EAR2) from the start of deployment to un-deployment of EAR1 PERIODICALLY, if the EJB and Webservice is deployed and running properly and working normally and is not in deadlock/non responsive state.
I have looked into JMX and I am able to get notifications of create and destroy for EJB as well as webservice, but how to check periodically whether the EJB and webservice is working normally and is not in deadlock/non responsive state?
Also how to monitor Jboss ESB services?
Is the JMX is the only way or does jboss provides any other API's to do monitoring how about JBOSS MONITORING
Thanks in advance if you are looking at this.
Especially JBoss AS5.x is using the so called profile service (PS) as the main way to interact with the server. Unfortunately the PS is not JMX-based and on the other side you don't see all EJBs in the Platform MBean server.
RHQ has a plugin to monitor EJB instances inside AS5 as well as for other resource types like JBoss ESB or Apache Tomcat and is able to determine the availability of EJBs.
but how to check periodically whether the EJB and webservice is
working normally and is not in deadlock/non responsive state?
This is usually something that you can (only)(*) determine by hitting the relevant beans/methods and evaluating the outcome.
*) It may be possible to determine a bean in a deadlocked state by requesting a heap dump and looking for deadlocked periodically.

Deploying .ear file (contains rest services)

I have a few questions about deploying my .ear file (was provided to me, the file itself should not be the problem). I set up jBoss application server jboss-6.0.0.Final and was able to run a simple hello world app to ensure the server was functioning properly.
I was told to place the .ear file in /server/default/deploy so I did. When I ran jboss (through /bin/run.bat) I got no errors related to deploying the ear file.
Question
Is this all the software I need (jBoss)? Do I also need something like Apache or tomcat?
The .ear file contains RESTful service calls that should return xml. Will these be deployed (accessible through a jQuery ajax call after the server (jboss/bin/run.bat) is executed?
Currently when I try to make the calls, the resources do not seem to exist.
Thanks in advance for taking the time to help.
JBoss AS ships with an embedded Tomcat as a servlet container so you really don't need that anymore. Apache Web Server is NOT required for your .EAR to be deployed properly.
To answer your questions
No other software is needed to deploy the EAR. You simply copy your EAR file to deploy directory (which you have rightfully done so).
If your EAR contains RESTFul services, they will be deployed and you can access them using any client including jQuery or even a simple browsers. The trick is to know the access URL to the RESTFul services.
If you have difficulty identifying the URL for accessing your RESTFul services please refer [1] for more information.
Hope this helps.
Good luck!
[1] https://docs.jboss.org/author/display/AS7/JAX-RS+Reference+Guide
I can answer the first question. You need apache if you want to serve static content or you need to isolate the traffic (say keep apache in the dmz and then use apache to proxy traffic to the internal jboss servers). tomcat is bundled along with jboss, so you do not need it.

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