gpt4 book ai didi

java - JBoss MBean 通知监听器问题

转载 作者:行者123 更新时间:2023-12-02 08:29:15 25 4
gpt4 key购买 nike

我在 JBoss 上的 NotificationListener 方面遇到了一些问题。

我在 JBoss 上有一个 MBean,我可以连接并调用他们的方法。但是当我尝试添加通知时,您会遇到下一个异常:

org.jboss.invocation.JBossLazyUnmarshallingException: getArguments failed    at org.jboss.invocation.MarshalledInvocation.getArguments(MarshalledInvocation.java:513)    at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerAdaptorService.java:230)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:138)    at org.jboss.mx.server.Invocation.invoke(Invocation.java:90)    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:140)    at org.jboss.jmx.connector.invoker.SerializableInterceptor.invoke(SerializableInterceptor.java:74)    at org.jboss.mx.server.Invocation.invoke(Invocation.java:90)    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)    at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:180)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)    at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:855)    at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:422)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)    at sun.rmi.transport.Transport$1.run(Transport.java:159)    at java.security.AccessController.doPrivileged(Native Method)    at sun.rmi.transport.Transport.serviceCall(Transport.java:155)    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)    at java.lang.Thread.run(Thread.java:637)Caused by: java.lang.ClassNotFoundException: ar.com.cube3.test.msn.MyListener    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)    at java.security.AccessController.doPrivileged(Native Method)    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)    at java.lang.Class.forName0(Native Method)    at java.lang.Class.forName(Class.java:247)    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:292)    at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1119)    at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:798)    at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:441)    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)    at java.lang.Class.forName0(Native Method)    at java.lang.Class.forName(Class.java:247)    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)    at org.jboss.invocation.MarshalledValueInputStream.resolveClass(MarshalledValueInputStream.java:109)    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)    at org.jboss.invocation.MarshalledValue.get(MarshalledValue.java:91)    at org.jboss.invocation.MarshalledInvocation.getArguments(MarshalledInvocation.java:509)    ... 40 more

我正在从 JBOSS 外部的客户端调用 MBean

主要代码是:

Properties env = new Properties();            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");            env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");            env.put(Context.PROVIDER_URL, "jnp://localhost:1099");            InitialContext ctx;            ctx = new InitialContext(env);            MBeanServerConnection server = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");               // get reference to CacheMgmtInterceptor MBean              String cache_service = "ar.com.cube3.framework.modulos.msn:jndiName=msnControl,service=MSNControlAcceso";              //String cache_service = "jboss:service=JNDIView";               ObjectName mgmt_name = new ObjectName(cache_service);//                            server.addNotificationListener(mgmt_name,(NotificationListener) new MyListener(), new NotificationFilter() {                private static final long serialVersionUID = 6404657810887052083L;                public boolean isNotificationEnabled(Notification notification) {                    // TODO Auto-generated method stub                    return true;                }            }, null);            Object obj[]= {"test"};            Object temp = server.invoke(mgmt_name, "registrarMsnMessenger", obj, new String[]{String.class.getName()});            System.out.println(temp);        } catch (Exception e) {            // TODO Auto-generated catch block            e.printStackTrace();        }

以及 notificationListener 实现:

import java.io.Serializable;import javax.management.Notification;import javax.management.NotificationListener;public class MyListener  implements   NotificationListener, Serializable{    /**     *      */    private static final long serialVersionUID = 1L;    public void handleNotification(Notification notification, Object handback) {        System.out.println("objecto "+ notification.getMessage());    }}

提前致谢。安德烈斯。

最佳答案

问题是您的 JBoss 服务器在其类路径中没有监听器实现 (ar.com.cube3.test.msn.MyListener),因此它无法实例化它以将其注册为听众。将所有自定义类(如监听器)打包到一个 jar 中,并将该 jar 放入目录 [jboss-home]/server/[server-name]/lib 中。

关于java - JBoss MBean 通知监听器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3835966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com