looks good except for the <ejb-link> tag, it's missing

JP

-----Original Message-----
From: John Pletka [mailto:[EMAIL PROTECTED]]
Sent: Viernes, 19 de Enero de 2001 12:01
To: Orion-Interest
Subject: RE: Accessing EJBs from Stand-alone app....


It's better if you respond to the list instead of directly -- this is
probably a common question and others may benefit from the discussion.
 
Let's pretend you have a the following bean
Remote Interface:    com.foo.Foo
Home interface:       com.foo.FooHome
Enterprise bean:      com.foo.FooEJB
 
Your ejb-jar.xml file would read
<ejb-jar>
   <enterprise-beans>
      <session>
         <ejb-name>Foo</ejb-name>
         <home>com.foo.FooHome</home>
         <remote>com.foo.Foo</remote>
         <ejb-class>com.foo.FooEJB</ejb-class>
         <session-type>Stateful</session-type>
         <transaction-type>Container</transaction-type>
     </session>
   <enterprise-beans>
</ejb-jar>

Now you will have to create an application-client.xml file in a META-INF
directory under the directory you launch your program from
For now, it will be empty, just containing:
 
<application-client>
</application-client>
 
 
// Connect to Orion
public static void main(String args[])
{
    Properties p = new Properties();
    p.setProperty(Context.PROVIDER_URL, "ormi://hostname/application_name");
    p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.evermind.server.ApplicationClientInitialContextFactory");
    p.setProperty(Context.SECURITY_PRINCIPAL, "admin"); // This can be the
user you setup when you installed Orion
    p.setProperty(Context.SECURITY_CREDENTIALS, "password");
    InitialContext ctx = new InitialContext(p);
 
    doSomething(ctx);
    doSomethingWithJNDI(ctx);
 
}
Here are your two options:
1)  Use the fully qualified RemoteInterface name for the lookup
    If you do this, you can leave the application-client.xml file empty and
you don't have to detail all your beans
    public void doSomething(InitialContext ctx) throws NamingException
    {
        FooHome home = (FooHome)
PortableRemoteObject.narrow(ctx.lookup("com.foo.Foo"), FooHome.class);
        Foo foo = home.create();
        foo.doSomething();
    }
    
2)  Use the JNDI Name
    If you use this option, you will have to modify your
application-client.xml file to read:
    <application-client>
        <ejb-ref>
            <ejb-ref-name>ejb/FooHome</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <home>com.foo.FooHome</home>
            <remote>com.foo.Foo</remote>
        </ejb-ref>
    </application-client>
 
    public void doSomethingWithJNDI(InitialContext ctx) throws
NamingException
    {
        FooHome home = (FooHome)
PortableRemoteObject.narrow(ctx.lookup("java:comp/env/ejb/FooHome"),
FooHome.class); 
        Foo foo = home.create();
        foo.doSomething();
    }      
 

-----Original Message-----
From: Mohan Krishna [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 19, 2001 4:07 AM
To: John Pletka
Subject: Accessing EJBs from Stand-alone app....


Hi, 
I am MohanKrishna, i heard your name in Orion Forums when u r in 
discussion with "how to access EJBs from stand-alone application". 
Actually what i want to do is i have to write one simple java program 
in that i have to access EJBs from my console...which r running Orion 
Server 
I am borrowing your help in this issue... 
1.let me know what is the code i have to add in my application 
2.what r the xml files i have to change(under Orion if necessary). 
3.have I to change my class path to run this... 
if u know plz give the detailed steps, if possible plz send the code 
i have to embed in my application.because i am new to this...so i am 
expecting detailed steps from u... 
Any help will be apprecited...and i am expecting a soon and detailed 
reply from u...because i have to rush it off very soon... 
plz take this one as a friend's problem and try to give the detailed 
reply... 
waiting for your mail... 
i hope u give detailed mail very soon... 
Regards 
MohanKrishna

  _____  

Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
<http://www.hotmail.com> .





Reply via email to