Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 查找后缓存EJB主对象_Java_Ejb_Weblogic - Fatal编程技术网

Java 查找后缓存EJB主对象

Java 查找后缓存EJB主对象,java,ejb,weblogic,Java,Ejb,Weblogic,我有一个swing应用程序,它调用部署在Weblogic 10.3.6上的无状态EJB(EJB2.1)。无状态EJB通过JAAS进行保护Web应用客户端通过JNDI查找获取远程接口。 为了提高性能,我希望缓存EJBHome,以便只在客户端创建一次EJBHome。出于同样的原因,我希望在客户端缓存远程接口 第一次调用无状态EJB方法成功。此后,每次远程方法调用都会导致javax.ejb.ejbaccesexception:[ejb:010160]安全冲突:用户“”没有足够的权限访问ejb 我的客户

我有一个swing应用程序,它调用部署在Weblogic 10.3.6上的无状态EJB(EJB2.1)。无状态EJB通过JAAS进行保护Web应用客户端通过JNDI查找获取远程接口。 为了提高性能,我希望缓存EJBHome,以便只在客户端创建一次EJBHome。出于同样的原因,我希望在客户端缓存远程接口

第一次调用无状态EJB方法成功。此后,每次远程方法调用都会导致
javax.ejb.ejbaccesexception:[ejb:010160]安全冲突:用户“”没有足够的权限访问ejb

我的客户端实现:

public class ServiceLocatorUtil {

        /**
         * Cached remote home (EJBHome). Uses lazy loading to obtain its value
         * (loaded by getHome() methods).
         */
        private static MyEJBProxyHome cachedRemoteHome = null;
        private static MyEJBProxy proxy = null;

        /**
         * Obtain remote home interface from default initial context
         */
        private static MyEJBProxyHome getHome()
                throws javax.naming.NamingException {
            if (cachedRemoteHome == null) {
                cachedRemoteHome = (MyEJBProxyHome) lookupHome(null,
                        MyEJBProxyHome.JNDI_NAME, MyEJBProxyHome.class);
            }
            return cachedRemoteHome;
        }

        public static Proxy getProxy() throws RemoteException, CreateException,
                NamingException {
            if (proxy == null) {
                proxy = getHome().create();
            }
            return proxy;
        }

        /**
         * Home interface lookup methods
         */
        private static Object lookupHome(java.util.Hashtable environment,
                String jndiName, Class narrowTo)
                throws javax.naming.NamingException {
            // Obtain initial context
            javax.naming.InitialContext initialContext = null;
            try {

                Hashtable env = new Hashtable();

                env.put(Context.PROVIDER_URL,props.getProperty("t3://localhost:6969"));
                env.put(Context.SECURITY_PRINCIPAL,props.getProperty("weblogic"));
                env.put(Context.SECURITY_CREDENTIALS,props.getProperty("welcome"));
                env.put(Context.INITIAL_CONTEXT_FACTORY, props
                .getProperty("weblogic.jndi.WLInitialContextFactory"));

                initialContext = new javax.naming.InitialContext(env);

                Object objRef = initialContext.lookup(jndiName);
                // only narrow if necessary

                if (java.rmi.Remote.class.isAssignableFrom(narrowTo))
                    return javax.rmi.PortableRemoteObject.narrow(objRef,
                            narrowTo);
                else
                    return objRef;
            } catch (Exception e) {
                getLogger().error(
                        "Remote EJB cannot be found. " + e.getMessage());
                return null;
            }

        }
}
我的用法:

public class MyTransactionService {
...
    public String getEJBRemoteData(String xmlTransaction) {
        String xmlData = null;
        try {
            synchronized ("A STRING")) {
                xmlData = ServiceLocatorUtil.getProxy().getDataByXMLFormat(xmlTransaction);

            }
        } catch (Exception ex) {
            getLogger().error("Cannot send transaction data to EJB remote: Exception: "+ ex);
        }
        return xmlData;
    }
....
}
我认为这不是因为远程接口的缓存,因为如果在每次调用无状态EJB方法之前创建initialContext,则不会发生异常

这是它的日志:

15/12/17 11:31:02 Executing thread : RMICallHandler-6
15/12/17 11:31:05 Initialized thread name :RMICallHandler-6

15/12/17 11:31:28 Executing thread : RMICallHandler-5
ERROR [RMICallHandler-5] (MyTransactionService.java:707) - Cannot send transaction data to EJB remote: Exception: java.rmi.AccessException: [EJB:010160]Security Violation: User: '<anonymous>' has insufficient permission to access EJB: type=<ejb>, application=RemoteEJB, module=integration-proxy-ejb.jar, ejb=MyEJBProxy, method=getDataByXMLFormat, methodInterface=Remote, signature={java.lang.String}.

15/12/17 11:31:29 Executing thread : HTTPThreadGroup-4
ERROR [HTTPThreadGroup-4] (MyTransactionService.java:707) - Cannot send transaction data to EJB remote: Exception: java.rmi.AccessException: [EJB:010160]Security Violation: User: '<anonymous>' has insufficient permission to access EJB: type=<ejb>, application=RemoteEJB, module=integration-proxy-ejb.jar, ejb=MyEJBProxy, method=getDataByXMLFormat, methodInterface=Remote, signature={java.lang.String}.

15/12/17 11:31:29 Executing thread : HTTPThreadGroup-8
ERROR [HTTPThreadGroup-8] (MyTransactionService.java:707) - Cannot send transaction data to EJB remote: Exception: java.rmi.AccessException: [EJB:010160]Security Violation: User: '<anonymous>' has insufficient permission to access EJB: type=<ejb>, application=RemoteEJB, module=integration-proxy-ejb.jar, ejb=MyEJBProxy, method=getDataByXMLFormat, methodInterface=Remote, signature={java.lang.String}.

15/12/17 11:31:30 Executing thread : HTTPThreadGroup-7
ERROR [HTTPThreadGroup-7] (MyTransactionService.java:707) - Cannot send transaction data to EJB remote: Exception: java.rmi.AccessException: [EJB:010160]Security Violation: User: '<anonymous>' has insufficient permission to access EJB: type=<ejb>, application=RemoteEJB, module=integration-proxy-ejb.jar, ejb=MyEJBProxy, method=getDataByXMLFormat, methodInterface=Remote, signature={java.lang.String}.

15/12/17 11:31:30 Executing thread : RMICallHandler-5
ERROR [RMICallHandler-5] (MyTransactionService.java:707) - Cannot send transaction data to EJB remote: Exception: java.rmi.AccessException: [EJB:010160]Security Violation: User: '<anonymous>' has insufficient permission to access EJB: type=<ejb>, application=RemoteEJB, module=integration-proxy-ejb.jar, ejb=MyEJBProxy, method=getDataByXMLFormat, methodInterface=Remote, signature={java.lang.String}.

15/12/17 11:31:31 Executing thread : RMICallHandler-6
15/12/17 11:31:02执行线程:RMICallHandler-6
17年12月15日11:31:05初始化的线程名称:RMICallHandler-6
17年12月15日11:31:28执行线程:RMICallHandler-5
错误[RMICallHandler-5](MyTransactionService.java:707)-无法将事务数据发送到EJB远程:异常:java.rmi.AccessException:[EJB:010160]安全冲突:用户“”没有足够的权限访问EJB:type=,application=RemoteEJB,module=integration-proxy-EJB.jar,EJB=MyEJBProxy,method=getDataByXMLFormat,methodInterface=Remote,signature={java.lang.String}。
17年12月15日11:31:29执行线程:HTTPThreadGroup-4
错误[HTTPThreadGroup-4](MyTransactionService.java:707)-无法将事务数据发送到EJB远程:异常:java.rmi.AccessException:[EJB:010160]安全冲突:用户:“”没有足够的权限访问EJB:type=,application=RemoteEJB,module=integration-proxy-EJB.jar,EJB=MyEJBProxy,method=getDataByXMLFormat,methodInterface=Remote,signature={java.lang.String}。
17年12月15日11:31:29执行线程:HTTPThreadGroup-8
错误[HTTPThreadGroup-8](MyTransactionService.java:707)-无法将事务数据发送到EJB远程:异常:java.rmi.AccessException:[EJB:010160]安全冲突:用户:“”没有足够的权限访问EJB:type=,application=RemoteEJB,module=integration-proxy-EJB.jar,EJB=MyEJBProxy,method=getDataByXMLFormat,methodInterface=Remote,signature={java.lang.String}。
17年12月15日11:31:30执行线程:HTTPThreadGroup-7
错误[HTTPThreadGroup-7](MyTransactionService.java:707)-无法将事务数据发送到EJB远程:异常:java.rmi.AccessException:[EJB:010160]安全冲突:用户:“”没有足够的权限访问EJB:type=,application=RemoteEJB,module=integration-proxy-EJB.jar,EJB=MyEJBProxy,method=getDataByXMLFormat,methodInterface=Remote,signature={java.lang.String}。
17年12月15日11:31:30执行线程:RMICallHandler-5
错误[RMICallHandler-5](MyTransactionService.java:707)-无法将事务数据发送到EJB远程:异常:java.rmi.AccessException:[EJB:010160]安全冲突:用户“”没有足够的权限访问EJB:type=,application=RemoteEJB,module=integration-proxy-EJB.jar,EJB=MyEJBProxy,method=getDataByXMLFormat,methodInterface=Remote,signature={java.lang.String}。
17年12月15日11:31:31执行线程:RMICallHandler-6
作为日志信息,我看到第一个执行线程(RMICallHandler-6)将初始化EJBHome并将其缓存在
ServiceLocatorUtil.cachedRemoteHome
中,该线程将成功完成其工作。但是当另一个像RMICallHandler-5或HTTPThreadGroup-4。。将引发匿名访问异常

我的实现有什么问题吗?
任何建议都会有帮助。

请帮助我(