I'm getting familiar with Jboss 7.
I'm writing some application to try out technologies.
So I wanted to have some simple monitoring service that will allow me to do some counter on business methods.
I wanted to access counters through jmx and jndi.
The 'counter service' is part of jmx bean. During jmx registration it is also registered in jndi context.
Then it is being used in some interceptors.
And here problem occurs, when I want to get reference from jndi I got class cast exception.
java.lang.ClassCastException: com.cybercom.pl.jbmon.SystemMonitorService cannot be cast to com.cybercom.pl.jbmon.SystemMonitorService
The reason for this i believe is that there classloaders are different.
During service startup it is:
ModuleClassLoader for Module "org.jboss.as.standalone:main" from local module loader #a4d593 ....
During execution it is:
ModuleClassLoader for Module "deployment.jboss-mon-app.ear.jboss-mon-web.war:main" from Service Module Loader
JMX beans, monitoring service and interceptor exists in same ejb module.
I finally did workaround for this, instead of going through jndi I used jmx client (https://github.com/michaljedryszka/jboss-sample-monitoring/commit/dcc4f05a4d6d50e592f0517bfe0454033f8e3659)
But still I don't know how to fix that CCE with jndi lookup.
What can You suggest?
Regards
You can try to create and install JBoss module with classes that are part of the JMX mbeans. This will cause to be loaded in same classloader for all access.
After you must add the dependency to the new module in the application, for example you can use jboss-deployment-structure.xml file.
Related
I am using Apache Geronimo. I need a way to deploy an EAR application on an application server without starting the EAR module automatically.
When I deploy my EAR, it is automatically started. I need a way to specify, that it should only be deployed but not started.
Is there a way to do this?
In the past I've opened and closed gates to certain EJBs with the use of JMX.
The cool part:
100% Control your beans from outside using JConsole or your own JMX client.
The drawback:
Every bean instance has to be registered in the MBean Server which is not that cool as you are usually having multiple instances of the same bean.
The solution to this topic was having a #Singleton EJB working as a MBean/controller for all the instances of one EJB.
I'm having a problem with ejb load balancing inside glassfish 3 cluster.
I have one ear project witch contains EJB module and WEB module. All my EJB's are stateless and remote in EJB module. In WEB module I have one servlet which suppose to lookup for ejb and print on which instance in cluster he get ejb.
I'm calling EJB from servlet like this:
Properties props = System.getProperties();
props.setProperty("com.sun.appserv.iiop.endpoints", "10.8.10.202:23700,10.8.10.203:23700,10.8.10.204:23700,10.8.10.205:23700");
InitialContext ic = new InitialContext();
EJBRemote ejb = (EJBRemote) ic.lookup("java:global/app-name-ear/app-ejbs/EJB!com.tt.EJBRemote");
Problem is that my request always ends up on first instance of 4 possible.
How I can achieve load balancing in my case? Do I need stand alone client (web-app in separate project)? How glassfish cluster knows that there are another instances where my servlet can lookup for EJB?
Your issue is that you don't have enough load. and the way you look up EJBs is odd.
To look up remote EJB, rather than the properties in a servlet. but the CORBA / IIOP URL in the JNDI resources of the server. (in the admin console)
When you load balance, with IIOP each lookup binds to one instance and only switches to another instance for failover.
essentially you don't have enough load on the system to trigger the other instances of the EJB. Perhaps reduce the pool size to one to simulate high load.
I have a message-driven EJB deployed to a Glassfish 2.x system. When I get a message that causes an exception or isn't able to be sent or consumed, I would like to do one of the following things:
Pause the EJB's subscription to the Topic/Queue
Shut down the EJB itself
Cease consuming messages until I give an 'all clear' or something equivalent
This is all so that I can stop repeatedly throwing exceptions after calling context.setRollbackOnly() on the message.
I've tried connecting to the server via JMX, but from what I've looked at in documentation says that I'd have to persist:
username
password
jmx url
in my EJB somewhere. Can't I access the JMX server from within the EJB in Glassfish without having to know that?
I am successfully running an application in websphere 7.0.0.0 but it is failing in websphere 7.0.0.17. I am injecting the entitymanager using #PersistenceContext.
When I try to use entitymanager it is throwing NullPointerException. But the same code runs successfully in Websphere 7.0.0.0.
I am using JTA with defined data source in websphere.
My DAO is Stateless bean called from another stateless bean(DAO is Injected here). Both calling SLSB's method and DAO method are running in Trasaction scope(Transaction.Supported).
I am using openJPA 1.1 (default to websphere 7).
I tried to update the websphere runtime to the latest 7.0.0.23 but no use, still it is throwing Nullpointer exception whenever I am trying to inject Entity Manager.
Any help will be much appreciated.
If I create a MessageDriven bean - is it available to other components in my app via JNDI? If so, how can I find/specify the name to look it up by? I'm deploying to glassfish if that makes any difference?
Assigning a JNDI name for an MDB is not required by Java EE specification (chapter 21.2.3 of EJB 3.0):
At the minimum, the EJB container must provide a JNDI API name space to the enterprise bean
instances. The EJB container must make the name space available to an instance when the instance invokes the javax.naming.InitialContext default (no-arg) constructor.
The business interfaces of other enterprise beans
[...]
MDBs don't qualify, as they don't have a business interface. Besides, since wiring up an MDB in another EJB/MDB would have little sense (what's your use case, BTW?), is probably skipped in Glassfish.
I've seen that WebLogic, for example allows that in its proprietary deployment descriptor, but I've never used it.