Letting EJB A (Glassfish A) communicate over IIOP to EJB B (Glassfish B) results in SecurityException -
i want let alice (ejb a; glassfish a) communicate bob (ejb b; glassfish b). both ejbs deployed on distinct glassfish (glassfish , glassfish b) servers. communication shall on iiop. however, experiments result in java.lang.securityexception. question is: why that, , how solve it?
alice , bob both implement remote interfaces.
aliceremote.java:
package com.fu.ba.alice.ejb; import javax.ejb.remote; @remote public interface aliceremote { void callbob(); }
bobremote.java:
package com.fu.ba.bob.ejb; import javax.ejb.remote; @remote public interface bobremote { void sayhello(); }
the implementation of alice , bob straight-forward.
alice.java:
package com.fu.ba.alice.ejb; import javax.ejb.ejb; import javax.ejb.stateless; import com.fu.ba.bob.ejb.bobremote; /** * session bean implementation class alice */ @stateless(mappedname = "alicemap") public class alice implements aliceremote { @ejb(name = "bobremote") private bobremote bob; /** * default constructor. */ public alice() { } @override public void callbob() { system.out.println("hello alice"); bob.sayhello(); } }
bob.java:
package com.fu.ba.bob.ejb; import javax.ejb.stateless; /** * session bean implementation class bob */ @stateless(mappedname = "bobmap") public class bob implements bobremote { /** * default constructor. */ public bob() { // todo auto-generated constructor stub } @override public void sayhello() { system.out.println("hello bob"); } }
in addition, alice's ejb includes ejb-jar.xml , glassfish-ejb-jar.xml specifying iiop communication.
ejb-jar.xml:
<?xml version="1.0" encoding="utf-8"?> <ejb-jar xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1"> <display-name>com.fu.ba.alice.ejb </display-name> <ejb-client-jar>com.fu.ba.alice.ejbclient.jar</ejb-client-jar> </ejb-jar>
glassfish-ejb-jar.xml:
<?xml version="1.0" encoding="utf-8"?> <!doctype glassfish-ejb-jar public "-//glassfish.org//dtd glassfish application server 3.1 ejb 3.1//en" "http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd"> <glassfish-ejb-jar> <enterprise-beans> <ejb> <ejb-name>alice</ejb-name> <ejb-ref> <ejb-ref-name>bobremote</ejb-ref-name> <jndi-name>corbaname:iiop:123.123.123.123:3700#java:global/com.fu.ba.bob/com.fu.ba.bob.ejb/bob!com.fu.ba.bob.ejb.bobremote</jndi-name> </ejb-ref> </ejb> </enterprise-beans> </glassfish-ejb-jar>
deploying ejbs different glassfish servers results in exceptions on bob's , alice's side.
bob's side:
warning: jts5071: unexpected error occurred in registersynchronization org.omg.corba.comm_failure: fine: 00410001: connection failure: sockettype: iiop_clear_text; hostname: 169.254.32.79; port: 3700 vmcid: omg minor code: 1 completed: no @ com.sun.proxy.$proxy142.connectfailure(unknown source) @ com.sun.corba.ee.impl.transport.connectionimpl.<init>(connectionimpl.java:253) @ com.sun.corba.ee.impl.transport.connectionimpl.<init>(connectionimpl.java:276) @ com.sun.corba.ee.impl.transport.contactinfoimpl.createconnection(contactinfoimpl.java:129) @ com.sun.corba.ee.impl.protocol.clientrequestdispatcherimpl.beginrequest(clientrequestdispatcherimpl.java:243) @ com.sun.corba.ee.impl.protocol.clientdelegateimpl.request(clientdelegateimpl.java:227) @ org.omg.corba.portable.objectimpl._request(objectimpl.java:449) @ org.omg.costransactions._coordinatorstub.register_synchronization(_coordinatorstub.java:235) @ com.sun.jts.costransactions.topcoordinator.register_synchronization(topcoordinator.java:2430) @ com.sun.jts.jta.transactionstate.registersynchronization(transactionstate.java:494) @ com.sun.jts.jta.transactionimpl.registersynchronization(transactionimpl.java:313) @ com.sun.enterprise.transaction.javaeetransactionmanagersimplified.createimportedtransaction(javaeetransactionmanagersimplified.java:1568) @ com.sun.enterprise.transaction.jts.javaeetransactionmanagerjtsdelegate.gettransaction(javaeetransactionmanagerjtsdelegate.java:279) @ com.sun.enterprise.transaction.javaeetransactionmanagersimplified.gettransaction(javaeetransactionmanagersimplified.java:915) @ com.sun.ejb.containers.ejbcontainertransactionmanager.preinvoketx(ejbcontainertransactionmanager.java:250) @ com.sun.ejb.containers.basecontainer.preinvoketx(basecontainer.java:4433) @ com.sun.ejb.containers.basecontainer.preinvoke(basecontainer.java:1921) @ com.sun.ejb.containers.ejbobjectinvocationhandler.invoke(ejbobjectinvocationhandler.java:204) @ com.sun.ejb.containers.ejbobjectinvocationhandlerdelegate.invoke(ejbobjectinvocationhandlerdelegate.java:79) @ com.sun.proxy.$proxy180.sayhello(unknown source) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie.dispatchtomethod(reflectivetie.java:143) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie._invoke(reflectivetie.java:173) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatchtoservant(serverrequestdispatcherimpl.java:528) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatch(serverrequestdispatcherimpl.java:199) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequestrequest(messagemediatorimpl.java:1549) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:1425) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handleinput(messagemediatorimpl.java:930) @ com.sun.corba.ee.impl.protocol.giopmsgheaders.requestmessage_1_2.callback(requestmessage_1_2.java:213) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:694) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dispatch(messagemediatorimpl.java:496) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dowork(messagemediatorimpl.java:2222) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.performwork(threadpoolimpl.java:497) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.run(threadpoolimpl.java:540) caused by: java.lang.runtimeexception: java.net.connectexception: connection timed out: connect @ org.glassfish.enterprise.iiop.impl.iiopsslsocketfactory.createsocket(iiopsslsocketfactory.java:344) @ com.sun.corba.ee.impl.transport.connectionimpl.<init>(connectionimpl.java:250) ... 35 more caused by: java.net.connectexception: connection timed out: connect @ sun.nio.ch.net.connect0(native method) @ sun.nio.ch.net.connect(net.java:364) @ sun.nio.ch.net.connect(net.java:356) @ sun.nio.ch.socketchannelimpl.connect(socketchannelimpl.java:623) @ com.sun.corba.ee.impl.misc.orbutility.opensocketchannel(orbutility.java:110) @ org.glassfish.enterprise.iiop.impl.iiopsslsocketfactory.createsocket(iiopsslsocketfactory.java:329) ... 36 more warning: ejb5184:a system exception occurred during invocation on ejb bob, method: public void com.fu.ba.bob.ejb.bob.sayhello() warning: javax.ejb.ejbexception: java.lang.securityexception @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2016) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:1979) @ com.sun.ejb.containers.ejbobjectinvocationhandler.invoke(ejbobjectinvocationhandler.java:212) @ com.sun.ejb.containers.ejbobjectinvocationhandlerdelegate.invoke(ejbobjectinvocationhandlerdelegate.java:79) @ com.sun.proxy.$proxy180.sayhello(unknown source) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie.dispatchtomethod(reflectivetie.java:143) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie._invoke(reflectivetie.java:173) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatchtoservant(serverrequestdispatcherimpl.java:528) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatch(serverrequestdispatcherimpl.java:199) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequestrequest(messagemediatorimpl.java:1549) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:1425) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handleinput(messagemediatorimpl.java:930) @ com.sun.corba.ee.impl.protocol.giopmsgheaders.requestmessage_1_2.callback(requestmessage_1_2.java:213) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:694) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dispatch(messagemediatorimpl.java:496) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dowork(messagemediatorimpl.java:2222) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.performwork(threadpoolimpl.java:497) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.run(threadpoolimpl.java:540) caused by: java.lang.securityexception @ com.sun.jts.jta.transactionmanagerimpl.rollback(transactionmanagerimpl.java:376) @ com.sun.enterprise.transaction.jts.javaeetransactionmanagerjtsdelegate.rollbackdistributedtransaction(javaeetransactionmanagerjtsdelegate.java:218) @ com.sun.enterprise.transaction.javaeetransactionmanagersimplified.rollback(javaeetransactionmanagersimplified.java:892) @ com.sun.ejb.containers.ejbcontainertransactionmanager.destroybeanandrollback(ejbcontainertransactionmanager.java:574) @ com.sun.ejb.containers.ejbcontainertransactionmanager.completenewtx(ejbcontainertransactionmanager.java:697) @ com.sun.ejb.containers.ejbcontainertransactionmanager.postinvoketx(ejbcontainertransactionmanager.java:503) @ com.sun.ejb.containers.basecontainer.postinvoketx(basecontainer.java:4475) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2009) ... 21 more
alice's side:
warning: context path servletcontext: /com.fu.ba.servlet differs path bundle: com.fu.ba.servlet information: hello alice warning: context path servletcontext: differs path bundle: / warning: ejb5184:a system exception occurred during invocation on ejb alice, method: public void com.fu.ba.alice.ejb.alice.callbob() warning: javax.ejb.ejbexception: java.lang.securityexception @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2016) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:1979) @ com.sun.ejb.containers.ejbobjectinvocationhandler.invoke(ejbobjectinvocationhandler.java:212) @ com.sun.ejb.containers.ejbobjectinvocationhandlerdelegate.invoke(ejbobjectinvocationhandlerdelegate.java:79) @ com.sun.proxy.$proxy180.sayhello(unknown source) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie.dispatchtomethod(reflectivetie.java:143) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie._invoke(reflectivetie.java:173) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatchtoservant(serverrequestdispatcherimpl.java:528) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatch(serverrequestdispatcherimpl.java:199) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequestrequest(messagemediatorimpl.java:1549) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:1425) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handleinput(messagemediatorimpl.java:930) @ com.sun.corba.ee.impl.protocol.giopmsgheaders.requestmessage_1_2.callback(requestmessage_1_2.java:213) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:694) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dispatch(messagemediatorimpl.java:496) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dowork(messagemediatorimpl.java:2222) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.performwork(threadpoolimpl.java:497) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.run(threadpoolimpl.java:540) caused by: java.lang.securityexception @ com.sun.jts.jta.transactionmanagerimpl.rollback(transactionmanagerimpl.java:376) @ com.sun.enterprise.transaction.jts.javaeetransactionmanagerjtsdelegate.rollbackdistributedtransaction(javaeetransactionmanagerjtsdelegate.java:218) @ com.sun.enterprise.transaction.javaeetransactionmanagersimplified.rollback(javaeetransactionmanagersimplified.java:892) @ com.sun.ejb.containers.ejbcontainertransactionmanager.destroybeanandrollback(ejbcontainertransactionmanager.java:574) @ com.sun.ejb.containers.ejbcontainertransactionmanager.completenewtx(ejbcontainertransactionmanager.java:697) @ com.sun.ejb.containers.ejbcontainertransactionmanager.postinvoketx(ejbcontainertransactionmanager.java:503) @ com.sun.ejb.containers.basecontainer.postinvoketx(basecontainer.java:4475) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2009) ... 21 more warning: standardwrappervalve[com.fu.ba.servlet.callbobservlet]: servlet.service() servlet com.fu.ba.servlet.callbobservlet threw exception javax.ejb.ejbexception: java.lang.securityexception @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2016) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:1979) @ com.sun.ejb.containers.ejbobjectinvocationhandler.invoke(ejbobjectinvocationhandler.java:212) @ com.sun.ejb.containers.ejbobjectinvocationhandlerdelegate.invoke(ejbobjectinvocationhandlerdelegate.java:79) @ com.sun.proxy.$proxy180.sayhello(unknown source) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie.dispatchtomethod(reflectivetie.java:143) @ com.sun.corba.ee.impl.presentation.rmi.reflectivetie._invoke(reflectivetie.java:173) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatchtoservant(serverrequestdispatcherimpl.java:528) @ com.sun.corba.ee.impl.protocol.serverrequestdispatcherimpl.dispatch(serverrequestdispatcherimpl.java:199) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequestrequest(messagemediatorimpl.java:1549) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:1425) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handleinput(messagemediatorimpl.java:930) @ com.sun.corba.ee.impl.protocol.giopmsgheaders.requestmessage_1_2.callback(requestmessage_1_2.java:213) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.handlerequest(messagemediatorimpl.java:694) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dispatch(messagemediatorimpl.java:496) @ com.sun.corba.ee.impl.protocol.messagemediatorimpl.dowork(messagemediatorimpl.java:2222) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.performwork(threadpoolimpl.java:497) @ com.sun.corba.ee.impl.threadpool.threadpoolimpl$workerthread.run(threadpoolimpl.java:540) caused by: java.lang.securityexception @ com.sun.jts.jta.transactionmanagerimpl.rollback(transactionmanagerimpl.java:376) @ com.sun.enterprise.transaction.jts.javaeetransactionmanagerjtsdelegate.rollbackdistributedtransaction(javaeetransactionmanagerjtsdelegate.java:218) @ com.sun.enterprise.transaction.javaeetransactionmanagersimplified.rollback(javaeetransactionmanagersimplified.java:892) @ com.sun.ejb.containers.ejbcontainertransactionmanager.destroybeanandrollback(ejbcontainertransactionmanager.java:574) @ com.sun.ejb.containers.ejbcontainertransactionmanager.completenewtx(ejbcontainertransactionmanager.java:697) @ com.sun.ejb.containers.ejbcontainertransactionmanager.postinvoketx(ejbcontainertransactionmanager.java:503) @ com.sun.ejb.containers.basecontainer.postinvoketx(basecontainer.java:4475) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2009) ... 21 more
Comments
Post a Comment