Skip to main content

iiop and ssl

17 replies [Last post]
alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi guys,

I'm writing a brief howto (GlassFIsh wiki) about IIOP and SSL.
The supposed scenario is: two different instances of GlassFish (3.1.2) on two different jvms on two different nodes in a LAN. From an EJB I'm calling a remote EJB.
I bound, through glassfish admin console, orb-listener-1 to the Network address on both machines. Firewalls disabled

Here's the code:
ic = new InitialContext();
BankService bankservice = (BankService) ic.lookup("java:comp/env/ejb/BankServiceBean");

Here's the descriptor(glassfish-ejb-jar.xml):

BankServiceBean
corbaname:iiop@192.168.0.4:3700#java:global/ServerEAR/ServerEjb/BankServiceBean

I tried also with corbaname:iiop@192.168.0.4:3700#ServerEAR/ServerEjb/BankServiceBean

Here's the error I get:
WARNING: This bean [CallEjbBean] has no ejb reference by the name of [BankServiceBean]
SEVERE: DPL8006: get/add descriptor failure : ejb-ref TO BankServiceBean
WARNING: DPL8007: Unsupported deployment descriptors element jndi-name value corbaname:iiop@192.168.0.4:3700#java:global/ServerEAR/ServerEjb/BankServiceBean
SEVERE: javax.naming.NamingException: Lookup failed for 'java:comp/env/ejb/BankServiceBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/BankServiceBean]

Where did I go wrong????

Any suggestion highly appreciated

Regards
Alessandro

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cf126330
Offline
Joined: 2005-03-29
Points: 0

Hi, Alessandro,

(now I have escaped all the xml tags)

Looks like your xml snippets are not displayed correctly. But from what I can gather so far, you will need to declare a ejb-ref in your caller ejb-jar, with either ejb-jar.xml, or @EJB annotation. For example, with ejb-jar.xml, since you are using lookup:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<session>
<ejb-name>CallEjbBean</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/BankServiceBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>xx.xx.xx.xx.BankService</remote>
</ejb-ref>
</session>
</enterprise-beans>
</ejb-jar>

Then in your glassfish-ejb-jar.xml, map this ejb-ref to its global jndi name:
<ejb-ref>
<ejb-ref-name>ejb/BankServiceBean</ejb-ref-name>
<jndi-name>corbaname:iiop@192.168.0.4:3700#xx.xx.xx.BankService</jndi-name>
</ejb-ref>

The xx.xx... part is the global jndi name of your target EJB, you can find it in the target host's server.log after deploying it.

The configuration could be simpler when using annotations.

If you still see problems, pls post your test app.

-Cheng

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng

Still no success. I've got two nodes 192.168.0.2(client) and 192.168.0.4(server)
I bound orb-listener-1 on both machines to their network address:

<iiop-listener port="3700" id="orb-listener-1" address="192.168.0.2" lazy-init="true"></iiop-listener>

I can reach the server with the url http://192.168.0.4:8080/. The OS on both machines is fedora 14 64 bit with Glassfish 3.1.2.
The code in the client ejb is:

@Stateless
@LocalBean
public class CallEjbBean {

@EJB (beanName="BankServiceBean")
BankService bankservice;
---------------------------------------------
ejb-jar.xml:

<enterprise-beans>
    <session>
      <ejb-name>CallEjbBean</ejb-name>
    </session>
  </enterprise-beans>

---------------------------------------------
glassfish-ejb-jar.xml:
 <enterprise-beans>
   <ejb>
     <ejb-name>CallEjbBean</ejb-name>
     <jndi-name>CallEjbBean</jndi-name>
      <ejb-ref>
       <ejb-ref-name>BankServiceBean</ejb-ref-name>
        <jndi-name>corbaname:iiop@192.168.0.4:3700#ServerEAR/ServerEjb/BankServiceBean</jndi-name>
       </ejb-ref>
    </ejb>
   </enterprise-beans>

--------------------------------------------------------

I cannot deploy the application. The error I get is:
SEVERE: Class [ Lsession/BankService; ] not found. Error while loading [ class ee.example.ejb.CallEjbBean ]

WARNING: This bean [CallEjbBean] has no ejb reference by the name of [BankServiceBean]
SEVERE: DPL8006: get/add descriptor failure : ejb-ref TO BankServiceBean
WARNING: DPL8007: Unsupported deployment descriptors element jndi-name value corbaname:iiop@192.168.0.4:3700#ServerEAR/ServerEjb/BankServiceBean
SEVERE: Exception while deploying the app [ClienteEAR]
SEVERE: Error processing EjbDescriptor
java.lang.RuntimeException: Error processing EjbDescriptor

cf126330
Offline
Joined: 2005-03-29
Points: 0

first, change
@EJB (beanName="BankServiceBean")
BankService bankservice;

to

@EJB (name="BankServiceBean")
BankService bankservice;

since your glassfish-ejb-jar.xml uses BankServiceBean as the ejb-ref name, you should also use the same in the above @EJB name attribute.

second, package the interface classes of the target EJB into the client ejb jar. Looks like session.BankService is the business interface so it should be in the same ejb jar as your caller ejb jar.

-Cheng

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng,
I've done a little step forward. I packaged the interface classes of the target EJB into the client ejb jar just like you told. The caller ejb actually reaches the other node and I had to specify the port 3700 (corbaname:iiop@192.168.0.4:3700#java:global/ServerEAR/NewEjb/BankServiceBean!ale.com.org.BankService). I changed the annotation too (@EJB (name="BankServiceBean")). Then I get an exception (see attached).

This is the server ejb descriptor:

  <display-name>NewEjb </display-name>
  <enterprise-beans>
    <session>
      <ejb-name>BankServiceBean</ejb-name>
     </session>
  </enterprise-beans>

this is the server ejb sun-ejb-jar.xml

 
<sun-ejb-jar>
<enterprise-beans>
   <ejb>
     <ejb-name>BankServiceBean</ejb-name>
     <jndi-name>BankServiceBean</jndi-name>
   </ejb>
   </enterprise-beans>
</sun-ejb-jar>

Thanks for your help

Alessandro

cf126330
Offline
Joined: 2005-03-29
Points: 0

In the client ejb's glassfish-ejb-jar.xml, ejb-ref, jndi-name, change it to
corbaname:iiop@192.168.0.4:3700#BankServiceBean

Is the server side ejb (BankServiceBean) deployed successfully?

-Cheng

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng,
Still no success, same exception. The server side ejb deployed successfully with Portable JNDI names for EJB BankServiceBean : [java:global/ServerEAR/NewEjb/BankServiceBean, java:global/ServerEAR/NewEjb/BankServiceBean!ale.com.org.BankService]

Alessandro

cf126330
Offline
Joined: 2005-03-29
Points: 0

In the client ejb's glassfish-ejb-jar.xml, ejb-ref, jndi-name, change it to
corbaname:iiop:192.168.0.4:3700#BankServiceBean

This should work. Otherwise, post your entire app if you want and I can try it on my machines.

-Cheng

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng,
you'll find the sample apps (server & client) attached. Thanks
Alessandro

cf126330
Offline
Joined: 2005-03-29
Points: 0

OK, I was able to get it to work on my side, with some small changes.

client: Mac OS, GlassFish 4.0 trunk build latest
server: Oracle Linux, GlassFish 3.1.1

The output when running your test, in client server.log, showing the result from remote server:

[#|2012-04-07T23:03:56.681-0400|INFO|44.0|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=16;_ThreadName=Thread-2;|@@@@@@@@@@@@@@@@@@@@@@@@@@|#]

[#|2012-04-07T23:03:57.139-0400|INFO|44.0|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=16;_ThreadName=Thread-2;|@@@@@@@@@@@@@@@@@@@@@@@@@@Hello, nome.|#]

2 files were changed in client side app: ejb-jar.xml and glassfish-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>HelloClientEjb </display-name>
  <enterprise-beans>
    <session>
      <ejb-name>HelloClientBean</ejb-name>
      <transaction-type>Bean</transaction-type>
     </session>
  </enterprise-beans>
</ejb-jar>
<?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>HelloClientBean</ejb-name>
     <jndi-name>HelloClientBean</jndi-name>
     <ejb-ref>
       <ejb-ref-name>HelloServiceBean</ejb-ref-name>
        <jndi-name>corbaname:iiop:adc6140215.us.oracle.com:3700#HelloServiceBean</jndi-name>
       </ejb-ref>
   </ejb>
   </enterprise-beans>
</glassfish-ejb-jar>

The changes to glassfish-ejb-jar.xml is the same as I mentioned in my previous reply. Once you apply the above changes, this app should work as well in your environment.

-Cheng

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng,
It worked at last. I used your descriptors, I only changed the jndi-name in glassfish-ejb-jar : corbaname:iiop:192.168.0.7:3700#java:global/HelloServerEar/HelloServerEjb/HelloServiceBean!com.ee.HelloService. As you can see it's the portable jndi name. To make the sample work I had to deploy the server app on another machine (win xp). That makes me wonder: my problem might be OS related! Are there known issues about iiop and fedora? Could this be a new bug? On the app servers (glassfish 3.1.2 and 3.1.1) I didn't bind the iiop-listener to the network address. Is it a meaningful detail?

Regards
Alessandro

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng,
I'll try with your descriptors, thank you
regards
Alessandro

hyau
Offline
Joined: 2005-03-29
Points: 0

Sent from my iPhone

On Apr 7, 2012, at 8:12 PM, forums@java.net wrote:

> OK, I was able to get it to work on my side, with some small changes. client:
> Mac OS, GlassFish 4.0 trunk build latest server: Oracle Linux, GlassFish
> 3.1.1 The output when running your test, in client server.log, showing the
> result from remote server:
> [#|2012-04-07T23:03:56.681-0400|INFO|44.0|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=16;_ThreadName=Thread-2;|@@@@@@@@@@@@@@@@@@@@@@@@@@|#]
> [#|2012-04-07T23:03:57.139-0400|INFO|44.0|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=16;_ThreadName=Thread-2;|@@@@@@@@@@@@@@@@@@@@@@@@@@Hello,
> nome.|#] 2 files were changed in client side app: ejb-jar.xml and
> glassfish-ejb-jar.xml: <?xml version="1.0" encoding="UTF-8"?> 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">
> HelloClientEjb
> HelloClientBean
> Bean
> <?xml version="1.0" encoding="UTF-8"?> PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN"
> "http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd">
> HelloClientBean
> HelloClientBean
> HelloServiceBean
> corbaname:iiop:adc6140215.us.oracle.com:3700#HelloServiceBean
> The changes to
> glassfish-ejb-jar.xml is the same as I mentioned in my previous reply. Once
> you apply the above changes, this app should work as well in your
> environment. -Cheng
>
> --
>
> [Message sent by forum member 'cf126330']
>
> View Post: http://forums.java.net/node/884788
>
>

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng,
I really appreciate your efforts. I'll refactor the two sample applications and if I still am not getting any result, I'll post them.
Thanks man!

Alessandro

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Cheng
Thanks for your reply. I'll follow your advice and I'll post the outcome.

cf126330
Offline
Joined: 2005-03-29
Points: 0

Hi, Alessandro,

Looks like your xml snippets are not displayed correctly. But from what I can gather so far, you will need to declare a ejb-ref in your caller ejb-jar, with either ejb-jar.xml, or @EJB annotation. For example, with ejb-jar.xml, since you are using lookup:

<?xml version="1.0" encoding="UTF-8"?>
version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">


CallEjbBean

ejb/BankServiceBean
Session
xx.xx.xx.xx.BankService



Then in your glassfish-ejb-jar.xml, map this ejb-ref to its global jndi name:

ejb/BankServiceBean
corbaname:iiop@192.168.0.4:3700#xx.xx.xx.BankService

The xx.xx... part is the global jndi name of your target EJB, you can find it in the target host's server.log after deploying it.

If you still see problems, pls post your test app.

Kumar Jayanti Guest
Offline
Joined: 2011-04-02
Points: 0

Have you seen this : http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html
On 04-Apr-2012, at 2:55 AM, forums@java.net wrote:

> Hi guys, I'm writing a brief howto (GlassFIsh wiki) about IIOP and SSL. The
> supposed scenario is: two different instances of GlassFish (3.1.2) on two
> different jvms on two different nodes in a LAN. From an EJB I'm calling a
> remote EJB. I bound, through glassfish admin console, orb-listener-1 to the
> Network address on both machines. Firewalls disabled Here's the code: ic =
> new InitialContext(); BankService bankservice = (BankService)
> ic.lookup("java:comp/env/ejb/BankServiceBean"); Here's the
> descriptor(glassfish-ejb-jar.xml): BankServiceBean
> corbaname:iiop@192.168.0.4:3700#java:global/ServerEAR/ServerEjb/BankServiceBean
> I tried also with
> corbaname:iiop@192.168.0.4:3700#ServerEAR/ServerEjb/BankServiceBean Here's
> the error I get: WARNING: This bean [CallEjbBean] has no ejb reference by the
> name of [BankServiceBean] SEVERE: DPL8006: get/add descriptor failure :
> ejb-ref TO BankServiceBean WARNING: DPL8007: Unsupported deployment
> descriptors element jndi-name value
> corbaname:iiop@192.168.0.4:3700#java:global/ServerEAR/ServerEjb/BankServiceBean
> SEVERE: javax.naming.NamingException: Lookup failed for
> 'java:comp/env/ejb/BankServiceBean' in
> SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
> java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,
> java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is
> javax.naming.NameNotFoundException: No object bound to name
> java:comp/env/ejb/BankServiceBean] Where did I go wrong???? Any suggestion
> highly appreciated Regards Alessandro
>
> --
>
> [Message sent by forum member 'alessandrogentile']
>
> View Post: http://forums.java.net/node/884788
>
>

alessandrogentile
Offline
Joined: 2012-02-10
Points: 0

Hi Kumar
thanks for your advice, but that FAQ doesn't seem to be helpful. I followed the instructions on the official GlassFish Application Development Guide. Still here I am...