[JNDI/Naming/Network] - I am getting a strange class cast exception when doing a jn
by price34
I am trying to access the RMIAdaptor on a remote jboss server running 4.0.4. from a different 4.0.4 jboss server using the following code.
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.jboss.jmx.adaptor.rmi.RMIAdaptor;
public class MBeanTester {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext ic = new InitialContext(env);
RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
Set name_set = null;
ObjectName on = null;
name_set = server.queryNames(new ObjectName("jboss.jca:service=ManagedConnectionPool,*"), null);
if(name_set.isEmpty())
System.out.println("no pools returned");
for (Iterator it = name_set.iterator(); it.hasNext() ; ) {
on = (ObjectName)it.next();
String pool_name = on.toString();
String status = server.getAttribute(on, "State").toString();
System.out.println("Pool Name: " + pool_name + " , " + status);
}// end for
}catch(Exception e){
e.printStackTrace();
}
//testConnectionList("1099", "localhost");
}
}
When I run the app I am getting the following exception.
java.lang.ClassCastException: org.jboss.invocation.InvokerInterceptor
09:03:21,637 ERROR [STDERR] at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:80)
09:03:21,637 ERROR [STDERR] at java.io.ObjectInputStream.readExternalData(Unknown Source)
09:03:21,652 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
09:03:21,652 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(Unknown Source)
09:03:21,652 ERROR [STDERR] at java.io.ObjectInputStream.readObject(Unknown Source)
09:03:21,652 ERROR [STDERR] at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:80)
09:03:21,652 ERROR [STDERR] at java.io.ObjectInputStream.readExternalData(Unknown Source)
09:03:21,652 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
09:03:21,652 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(Unknown Source)
09:03:21,652 ERROR [STDERR] at java.io.ObjectInputStream.readObject(Unknown Source)
09:03:21,652 ERROR [STDERR] at org.jboss.proxy.Interceptor.readExternal(Interceptor.java:80)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readExternalData(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readObject(Unknown Source)
09:03:21,668 ERROR [STDERR] at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:156)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readExternalData(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readSerialData(Unknown Source)
09:03:21,668 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
09:03:21,684 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(Unknown Source)
09:03:21,684 ERROR [STDERR] at java.io.ObjectInputStream.readObject(Unknown Source)
09:03:21,684 ERROR [STDERR] at java.rmi.MarshalledObject.get(Unknown Source)
09:03:21,684 ERROR [STDERR] at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
09:03:21,684 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:652)
09:03:21,684 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
09:03:21,684 ERROR [STDERR] at javax.naming.InitialContext.lookup(Unknown Source)
09:03:21,684 ERROR [STDERR] at com.mig.prodverification.util.MBeanTester.main(MBeanTester.java:34)
09:03:21,684 ERROR [STDERR] at com.mig.prodverification.TestInitializer.doPost(TestInitializer.java:48)
09:03:21,684 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
09:03:21,684 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
09:03:21,684 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
09:03:21,684 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
09:03:21,684 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
09:03:21,699 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
09:03:21,699 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
09:03:21,699 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
09:03:21,699 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
09:03:21,699 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
09:03:21,715 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
09:03:21,715 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
09:03:21,715 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
I when I change the code to cast the returned lookup value as a plain old Object I get the same error message. Which does not make sense since everything should be able to be casted to the raw Object type.
However, when I take out the env hashmap and do a local lookup the code works fine.
InitialContext ic = new InitialContext();
RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
There is somthing not working with a remote lookup.
Does anyone know if I do not have something on jboss configured correctly or what the problem is?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049714#4049714
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049714
17 years, 6 months