Issue in accessing EJB from plain java

Hi,
I am new to OAS. I am using OAS 10.1.2.
I want to access EJB which runs inside OAS, through a plain java program which runs from outside the OAS environment (standalone java program).
I am confused on what to use. RMIInitialContextFactory or ApplicationClientInitialContextFactory for the context in the java program.
what should be the provide URL ?
java.naming.provider.url","ormi://hostname:18140/
is it "ormi" or something else? what is the port number should i use. there are many ports in this OAS. i see that in the console("Ports") link.
also let me know what should i mention in the EJB xml descriptor.
Is this lookup to be done by retrieving from jndi?
pls help.
Thanks,
Sukumar
with this confusion i developed an EJB with the following details
ejb-jar.xml
<ejb-ref>
     <ejb-ref-name>ejb/testDetails</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
<home>com.xxx.xxx.testDetailsHome</home>
<remote>com.xxx.xxx.testDetails</remote>
     </ejb-ref>
orion-ejb-jar.xml
<entity-deployment name="ejb/testDetails" location="ejb/testDetails"
Client Java program
public class testDetailsClient
public static void main(String [] args)
testDetailsClient testDetailsClient = new testDetailsClient();
try
Context context =getInitialContext();
testDetailsHome testDetailsHome = (testDetailsHome)PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/testDetails"), testDetailsHome.class);
testDetails testDetails;
catch(Throwable ex)
ex.printStackTrace();
private static Context getInitialContext() throws NamingException
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial","com.evermind.server.rmi.RMIInitialContextFactory");
//env.put("java.naming.factory.initial","com.evermind.server.ApplicationClientInitialContextFactory");
env.put("java.naming.provider.url","ormi://host_name:18140/"); //23791 18140
env.put(Context.SECURITY_PRINCIPAL, "ias_admin");
env.put(Context.SECURITY_CREDENTIALS, "abc123");
InitialContext context = new InitialContext(env);
return context;
if i execute this, it says
javax.naming.NameNotFoundException: java:comp/env/ejb/testDetails not found
18140 is Application Server Control RMI port.
if i run the same code with ApplicationClientInitialContextFactory, it throws exception saying
java.lang.InstantiationException: No location specified and no suitable instance of the type 'com.testdetails.testDetails' found for the ejb-ref ejb/testDetails
     at com.evermind.server.administration.ApplicationResourceFinder.getEJBHome(ApplicationResourceFinder.java:268)
     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:324)
     at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
     at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
     at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
     at java.lang.Thread.run(Thread.java:534)
javax.naming.NamingException: Error reading application-client descriptor: No location specified and no suitable instance of the type 'com.testdetails.testDetails' found for the ejb-ref ejb/testDetails
     at com.evermind.server.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:161)
     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
     at javax.naming.InitialContext.init(InitialContext.java:219)
     at javax.naming.InitialContext.<init>(InitialContext.java:195)
     at com.testdetails.testDetailsClient.getInitialContext(testDetailsClient.java:89)
     at com.testdetails.testDetailsClient.main(testDetailsClient.java:20)
pls help

Hi,
you do not have to package your EJB and PAR together! You can deploy them separately and then reference the J2EE Application from your PAR or vice versa to access it.
For instance you can access the EJB from your PAR as described here:
http://help.sap.com/saphelp_nw2004s/helpdata/en/42/9ddf20bb211d72e10000000a1553f6/frameset.htm
Or you can access a Portal application from J2EE like described here:
http://help.sap.com/saphelp_nw2004s/helpdata/en/42/9ddd0cbb211d72e10000000a1553f6/frameset.htm
Even if you package your PAR in to the same EAR with your EJB they will result in two different containers on the J2EE Engine and you will have to reference them as described in the link above to access the functionality of one component from the other.
Best regards,
Stefan Brauneis

Similar Messages

  • Help me which JNDIFactory to use to access EJB from a java class of JAR

    I am confused in understanding the different JNDI factories
    RMIInitialContextFactory, ApplicationInitialContextFactory and ApplicationClientInitialContextFactory
    And the different namespaces like global, container local and component local.
    Especially is there any relationship between the JNDI factories and the namespaces?
    Or are they related to the deployment descriptors.
    Because in application specific deployment descriptors (orion-ejb-jar.xml), we just map the JNDI location with the object (or its reference from ejb-jar.xml). We dont specify it can be accessed from this factory or that.
    Shall we access an EJB from using any JNDI factory?
    Specifically, I am stuck with what Factory to use to access an EJB from a Java class in a library (jar). The JAR is packaged with the EAR which contains the EJB Jar that I am trying to access.
    THANK YOU

    Ed,
    As Robin said, I think you need code similar to this:
    Context c = new InitialContext();
    Object o = c.lookup("java:comp/env/Name");where Name is the name of your EJB as it appears in the "ejb-jar.xml"
    deployment descriptor XML file.
    Good Luck,
    Avi.

  • Access EJB from Servlet that in different archive?

    <font class="mediumtxt">package kyro.ejb.session;
    import javax.ejb.*;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    @Stateless(name="StandAlone")
    @Remote(StandAlone.class)
    public class StandAloneBean
    implements StandAlone, StandAloneLocal
    public StandAloneBean() {
    public String sayHello() {     
    return "sayHello";
    I want to access ejb from servlet that .war and .jar not in single .ear. I want to try that just with annotation not xml descriptor cause is easy to understand for me. I use Glassfish. But i can't lookup that ejb. How can i lookup that ejb with jndi? Can't you give me example of servlet to access that? I not use JNDI.properties, are that caused i can't access my ejb? I just thing .war and.jar in one server, are i have to used JNDI.properties. can you explain how to use JNDI.properties in servlet or separate file?
    </font>

    But i can't lookup that ejb. How are you trying and what exception is occurring?
    How can i lookup that ejb with jndi? [https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html|https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html]
    m

  • Looking up EJBs from a java client

    While trying to migrate my application from standalone-oc4j
    to Oracle Application Server 10g, I ran into the following problem.
    My application has a stateless session bean. When trying to lookup the bean (from a java client), I get the following exception:
    javax.naming.NamingException: Lookup error: javax.naming.AuthenticationException
    Invalid username/password for UnifyoccEAR (ias_admin)
    My code used the username/password I used to log into web-based console (which I used to deploy the application). The lookup code follows:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    OracleJASLayer.INITIAL_CONTEXT_FACTORY);
    env.put(Context.PROVIDER_URL, "ormi://localhost:3201/UnifyoccEAR");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, username);
    env.put(Context.SECURITY_CREDENTIALS, password);
    Context ctx = new InitialContext(env);
    Object obj = ctx.lookup("unify/nxj/controlCenters/occ/ControlCenterEJB");
    On a whim, I tried the old SCOTT/TIGER username/password and got the following
    exception:
    javax.naming.NoPermissionException: Not allowed to look up unify/nxj/controlCenters/occ/ControlCenterEJB,
    check the namespace-access tag setting in orion-application.xml for details
    So evidently, SCOTT/TIGER is in the security database used by the app (but isn't
    authorized) while the ias_admin user is not in the security database.
    I have the following questions:
    1. In the default configuration, is there a username/password I can use to
    lookup EJB homes in the jndi namespace of an OC4J instance? If so, what
    is it?
    2. Where is the security database? I tried looking in the web-based console
    to find how to configure security and could not figure it out. I did find
    the Security page for the application, but when I tried to add a user,
    it had no effect. Furthermore, this page did not show a user entry for
    SCOTT; hence, it doesn't seem that OC4J is actually using the information
    on this page. This is strange because the path to this page is:
    Farm > Application Server: ias_admin.lab10.sac.unify.com > OC4J: home > Application: UnifyoccEAR > Security
    I then went to the Security page for the default application and found
    that it did have a SCOTT user. So I added a new user and tried to run
    my java client. This resulted in the javax.naming.AuthenticationException
    described above (I was expected the NoPermissionException encounted when
    using SCOTT/TIGER). Next, I used the Security page for the default application
    to change the password for SCOTT and reran my java client using SCOTT/TIGER.
    This time I was expecting an AuthenticationException exception, but got the
    NoPermission exception. Therefore, it seems that OC4J isn't using this
    security data either.
    Hunting in the console (again) for the security database, I stumble accross
    the Infrasturcture page and see an Identity Management section and see that
    it is configure to use an Oracle Internet Directory server. Using
    <ORACLE_HOME>/bin/oidadmin, I connect to the directory server and look
    for the SCOTT user. I don't find it, so I believe that this can't be the
    security database either.
    3. Finally, how do I configure the OC4J instance such that it will allow
    anonymous users to lookup my EJB from a java client?
    Please help a confused and frustrated user.

    Looking at your example, it looks like you are using a J2EE client container or some properties file to specify the JNDI environment used to create the initial context (for you use the no-arg constructor to InitialContext). Since our application needs to the ability to dynamically connect to ejb's running on different Java application servers (e.g., WebLogic, WebSphere, JBoss), such an approach will not work. Instead we must do it the old-fashioned way and pass the jdni connection info to the InitialContext constructor.
    In any event, our problem isn't how to write the connection code, it is how to test it. Specifically, we can't figure out a valid username/password that will allow us to look up the home. Nor can we figure out how to configure security for the oc4j instance.

  • Accessing EJB from Java Mapping

    Hi all,
    I developed an EJB, deployed it to the J2EEServer via Visual Administrator. When I do a lookup from outside (NWDS) with the JNDI Name I gave it, everything works fine.
    Now I have to use this EJB in a Java Mapping. I do the same --> lookup and narrow with PortableRemoteObject and so on.
    But the problem is that I always get an java.lang.NoClassDefFoundError for the home interface.
    Any ideas?
    Thanks a lot
    Olli

    Hello.
    Check my wiki article:
    http://wiki.sdn.sap.com/wiki/display/stage/SapNetweaverProcessIntegration.CallEjb3.0methodfromJavaclassmappingPI7.1
    (SapNetweaver Process Integration. Call Ejb 3.0 method from Java class mapping PI 7.1)

  • Accessing EJBs from a Web project

    Hi,
    I am getting the error: "com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at java:comp, the whole lookup name is java:comp/env/ejb/UserInfoServer." when I try to access the session bean from my web project.  I have followed the instructions explicitly in http://help.sap.com/saphelp_nw04s/helpdata/en/55/29ed5eff965448941c0b42f01b9804/frameset.htm and also tried every other combination I can think of for configuring the references in both the EJB project & the web project (both in the same ear).  I do have a jndi name in the visual administrator for localebjs/sap.com/myEar/UserInfoServer.  Does anyone have any ideas?
    Thanks & merry Christmas/Happy New year to all the SDN folks!

    I've managed to get around the problem for the time being by using "/localejbs/provider/application/beanName" - bypassing (I think) the whole JNDI issue -  this is OK for now, but it's obviously not a long term fix. 
    Previously, I had used the default & so did not enter anything in the ejb-j2ee-engine.xml, and so my ejb's showed up nicely in the Visual Administrator JNDI Registry under the localejbs tab as you would expect. The problem appears to be in the Web project - The key is that the error is "Path to object not found" rather than "Name not found".  It seems to me that it knows what it is looking for & that it is valid, but doesn't know how to get there! Note that the EJB project is in the same EAR. The only reference to "Path" that I can find is in the help doc above where it says "If the name of the target enterprise bean is not unique in the enterprise application scope, you can enter the path to the JAR file that contains the bean...".  I've gone through the Car Rental Application pdf (I can't find the download that contains the entire application) & followed the instructions there explicitly for referencing ejbs from the web..

  • Acessing EJB from standard java applications

    Hello,
    What is the best way to access Enterprise Java Beans from a standard java Application? Any suggestions, documentation, links, ... are welcome.
    To illustrate the problem, take the shopping cart example (http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Session.html). Suppose I now want to create a shopping cart from another swing application started with the 'java' command and not the 'runclient' command. Is this possible? Has it been done before? What is the best thing to do ? Both the J2EE application (like the shopping cart) and the plain java application are already used by customers and cannot be fundamentally changed (the java command cannot be replaced by runclient).
    Thank you.

    Several options are available.
    The easiest is to have the java app call the EJB via RMI/IIOP. You should wrap that process in the "ejb-home factory" and "business delegate" design pattern. I recommend downloading this design pattern book and reading it through.
    http://www.theserverside.com/books/EJBDesignPatterns/index.jsp

  • Security exception while trying to access EJB from stand alone client

    Hi!, I am trying a sample EJB application to R&D some security related issues. I want to access EJB through a web application as well as a stand-alone client. I have set approriate <method-permission> in EJB deployment descriptor. I am using users.properties/roles.properties file for authentication mechanism. I am using JBoss 3.2.
    - On the web application side I am using BASIC authentication and the servlet is able to access the EJB OK, as long as I am using a login/password that has access to the EJB.
    - Now I am trying to access the EJB using a stand alone Java class. These are the things I have tried till now:
    =>Created a InitialContext with appropriate principal, credentials and tried getting a reference to EJB home interface. That resulted in security exception.
    =>Logged into a LoginContext by using appropriate JBossSX classes and then tried getting a EJB home interface. Again security exception.
    Now I am not sure what to do. I read at some places about client side container but not sure what that is. Does anyone has any ideas to try? Is there any other way I can make a swing application and a web application authenticate to EJB container?
    Also can anyone point me to any documentation that gives some idea about how the security credentials gets propagated from web application/standalone client to EJB container?

    It would be better if you can post your code...and DD that way we can help you better

  • Call ejb from a java project

    i have a steteless session bean and i want to access it from a standalone java application.It is working fine with a web client.
    My java code is
    public class TestEJBFromJava {
         public static void main(String[] args) {
              try {
                             Context ic= new InitialContext();
                             Object obj=ic.lookup("ejb/com/renault/test/TestHome");
                             TestHome home=(TestHome) PortableRemoteObject.narrow(obj,TestHome.class);
                             Test test=home.create();
                             System.out.println(test.printMyName);
                        } catch (NamingException e) {
                             e.printStackTrace();
                        } catch (RemoteException e) {
                             e.printStackTrace();
                        } catch (CreateException e) {
                             e.printStackTrace();
    and the exception i m getting is......
    vax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:255)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:292)
         at javax.naming.InitialContext.lookup(InitialContext.java:359)
         at com.renault.test.TestClient.main(TestClient.java:27)
    Please help me to know where i went wrong...

    You need to know that some questions like this are rather FAQ so check the other thread for similar problem
    http://forum.java.sun.com/thread.jspa?threadID=5297502&tstart=0

  • Accessing EJBs from a servlet

    Hi everyone,
    I deployed my EJB component in an Oracle 8.1.7 database and I try to access it from a servlet.
    If I run my servlet from JDeveloper 3.2 (Web-to-Go), it all works fine. If I run my servlet from JRun 3.01 or from Tomcat 3.2.1, I get the following exception:
    javax.naming.NoInitialContextException: Need to specify class name in environmen
    t or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at javax.naming.NamingException.<init>(NamingException.java:104)
    at javax.naming.NoInitialContextException.<init>(NoInitialContextException.java:58)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:279)
    at javax.naming.InitialContext.lookup(InitialContext.java:349)
    at com.cognicase.framework.base.U0003.AbstractORB.getBean(AbstractORB.java:285)
    at com.cognicase.framework.base.U0003.AbstractORB.getBean(Compiled Code)
    at com.cognicase.demo.U2007BL.U2007WP_Users.lookupBean(U2007WP_Users.java:60)
    at com.cognicase.framework.is.U0103.AbstractBeanWrapper.beforeBeanCall(AbstractBeanWrapper.java:121)
    at com.cognicase.demo.U2007BL.U2007WP_Users.valideUser(U2007WP_Users.java:77)
    at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.CallEjb(Compiled Code)
    at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.doValidateLogin(Compiled Code)
    at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.processService(U2000MW_WorkSpace.java:98)
    at Demo_0100_01.service(Demo_0100_01.java:128)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Compiled Code)
    at org.apache.tomcat.core.ServletWrapper.service(Compiled Code)
    at org.apache.tomcat.core.ContextManager.internalService(Compiled Code)
    at org.apache.tomcat.core.ContextManager.service(Compiled Code)
    at org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Compiled Code)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(Compiled Code)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(Compiled Code)
    at java.lang.Thread.run(Compiled Code)
    If I add my servlet classes, aurora_client.jar, mts.jar, vbjapp.jar and vbjorb.jar files to the CLASSPATH, it works fine.
    The behavior is the same in JRun and Tomcat.
    I don't like this solution since I have to make the CLASSPATH point to my application classes at the web server level instead of at the application context level.
    Has anyone been able to solve this problem?
    Thanks for your help.
    null

    Yes, I did. Actually, if I run my servlet in JDeveloper (Web-to-Go), it all works fine. I also extracted the code that calls the EJB from the servlet and I tested it in a small Java application, and it also works fine.
    Things stop to work when I deploy my servlet in JRun or in Tomcat.
    It appears that my code is correct, but the environment I try to run it is not, and I can't figure out what's wrong.
    Can anyone help me?
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sandeep Desai ([email protected]):
    Have you provided the environmental settings in the servlet.
    It should be :
    import oracle.aurora.jndi.sess_iiop.ServiceCtx;
    env.put(Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
    env.put(Context.SECURITY_PRINCIPAL, username);
    env.put(Context.SECURITY_CREDENTIALS, password);
    env.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN);
    InitialContext ctx = new InitialContext(env);
    Object obj = ctx.lookup("test/EJBHome");
    HomeObject home = PortableRemoteObject.narrow(
    obj,"HomeObject.class");
    RemoteObject remote = home.create();
    This should make it work!!
    <HR></BLOCKQUOTE>
    null

  • How to expose and call AM methods from plain java (testability etc)?

    Hello,
    my project is just starting out with the OA Framework. We just encountered our first hurdle - I hope someone here can help out or at least point me in the right direction. None of this stuff seems to be explicitly mentioned in the standard OAF documentation.
    This is the situation: We need to call the logic in our Application Modules directly. Two reasons for this:
    - We need to expose methods in the AM as web services
    - We really want to create unit\integration tests (probably JUnit) and set up some sort of continous integration environment (Cruisecontrol or similar).
    Now, how do we go about this? I see that controller code usually does something a la this:
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    This doesn't seem viable for plain javacode, since there is no pageContext or web beans in that situation.
    Now, I allready tried the most naive approach (tried it in the OAF Tutorial):
    EmployeeAMImpl employeeAMImpl = new EmployeeAMImpl();
    This of course doesn't work, since none of the VO\EO seem to be instantiated, db connection is probably not set up etc.
    The third approach is the one I found in the javadoc for OAApplicationModuleImpl:
    // load some basic properties
    Properties properties = loadProperties();
    javax.naming.Context ic = new InitialContext(properties);
    // 'defName' is the JNDI name for the application module
    // definition from which the root Application Module is to be created
    String defName = "abc.xyz.SampleApplicationModule";
    oracle.jbo.ApplicationModuleHome home = ic.lookup(defName);
    return home.create();
    This seems more promising this far, however I need help with the following two questions:
    1: Do I really need to go through JNDI to access my AMs from plain javacode (JUnit tests, webservices etc)? If not, how do I then instantiate AMs, complete with EOs, VOs etc?
    2: If I do need to go through JNDI: what is the easiest way to register and subsequently call my AMs and their logic\context, particularly for usage from web services and testing frameworks (JUnit etc)?
    I'm kinda stumped here, guys. How have you solved this, if you haven't then how would you go about doing it?

    Hello,
    my project is just starting out with the OA Framework. We just encountered our first hurdle - I hope someone here can help out or at least point me in the right direction. None of this stuff seems to be explicitly mentioned in the standard OAF documentation.
    This is the situation: We need to call the logic in our Application Modules directly. Two reasons for this:
    - We need to expose methods in the AM as web services
    - We really want to create unit\integration tests (probably JUnit) and set up some sort of continous integration environment (Cruisecontrol or similar).
    Now, how do we go about this? I see that controller code usually does something a la this:
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    This doesn't seem viable for plain javacode, since there is no pageContext or web beans in that situation.
    Now, I allready tried the most naive approach (tried it in the OAF Tutorial):
    EmployeeAMImpl employeeAMImpl = new EmployeeAMImpl();
    This of course doesn't work, since none of the VO\EO seem to be instantiated, db connection is probably not set up etc.
    The third approach is the one I found in the javadoc for OAApplicationModuleImpl:
    // load some basic properties
    Properties properties = loadProperties();
    javax.naming.Context ic = new InitialContext(properties);
    // 'defName' is the JNDI name for the application module
    // definition from which the root Application Module is to be created
    String defName = "abc.xyz.SampleApplicationModule";
    oracle.jbo.ApplicationModuleHome home = ic.lookup(defName);
    return home.create();
    This seems more promising this far, however I need help with the following two questions:
    1: Do I really need to go through JNDI to access my AMs from plain javacode (JUnit tests, webservices etc)? If not, how do I then instantiate AMs, complete with EOs, VOs etc?
    2: If I do need to go through JNDI: what is the easiest way to register and subsequently call my AMs and their logic\context, particularly for usage from web services and testing frameworks (JUnit etc)?
    I'm kinda stumped here, guys. How have you solved this, if you haven't then how would you go about doing it?

  • Accessing EJB from Console App.

    I have deployed in EJB with JNDI name "greeter" in Sun Java� System Application Server Platform Edition 8.
    Then i am trying to access EJB using a console app (given below).
    import javax.ejb.*;
    import javax.rmi.*;
    import java.util.*;
    import javax.naming.*;
    public class Client
    public static void main(String args[])
    Greeter myGreeterBean;
    GreeterHome myGreeterHome;
    Greeter myGreeterRemote;
    Context context = null;
    try
    context = new javax.naming.InitialContext();
    catch (Exception e)
    System.out.println( "Unable To Get Initial Context");
    return;
    System.out.println("Got Context...");
    try {
    String JNDIName = "greeter";
    Object objref = context.lookup(JNDIName);
    System.out.println("Got Access To Object");
    myGreeterHome =(GreeterHome) PortableRemoteObject.narrow(objref,
    GreeterHome.class);
    myGreeterRemote = myGreeterHome.create();
    String theMessage = myGreeterRemote.getGreeting();
    System.out.println(theMessage);
    catch(Exception ex) { System.out.println( ex.getMessage()); }
    } // end of main
    } // end of Client
    But, while i am running this program i am getting the following error:
    Got Context...
    Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    I don't know where i am wrong. Any idea about it ?
    Thank you,
    P.Srikanth.

    This is what you need to modify :)
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "<<your
    initial context factory>>");
    env.put(Context.PROVIDER_URL, "<<JNDI provider
    URL>>");
    // Check documentation for exact Strings to be set.
    // Pass the environment parameters to
    InitialContext.
    Context context = new InitialContext(env);
    Angel
    No this is not correct. Lookups in SUN AS works a bit differently.

  • Problems in accessing EJB from stand-alone client

    Hi,
    I am trying to access a EJB deployed in RI from a stand-alone client. When I run it, I got this exception:
    Exception in thread "main" java.rmi.AccessException: CORBA NO_PERMISSION 9998 Ma
    ybe; nested exception is:
    org.omg.CORBA.NO_PERMISSION: minor code: 9998 completed: Maybe
    org.omg.CORBA.NO_PERMISSION: minor code: 9998 completed: Maybe
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemExc
    eption(ReplyMessage_1_2.java:93)
    at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(
    ClientResponseImpl.java:108)
    at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOACli
    entSC.java:136)
    at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
    at TheBeanRemoteStub.test(Unknown Source)
    at Client.main(Client.java:19)
    The following is the code of the client:
    System.setProperty(Context.SECURITY_PRINCIPAL, "achong");
    System.setProperty(Context.SECURITY_CREDENTIALS, "achong");
    Context context = new InitialContext(System.getProperties());
    Object object = PortableRemoteObject.narrow(context.lookup("MyBean"), TheBeanHome.class);
    TheBeanHome home = (TheBeanHome) object;
    I have set "support client choice" while deploying the bean, and set which roles can access which methods. Any idea? Is my code is incorrect?

    I have the same problem like you.
    If you solve it, please give me a hint.
    Thank you very much!
    [email protected]

  • Accessing repository from a java app

    Hi, I am trying to develop a java app that access a portal repository. I got
    this error message when running the app:
    java.lang.NoClassDefFoundError:
    com/bea/content/manager/i18n/ManagerExceptionTextFormatter
    at
    com.bea.content.manager.internal.RepositoryManagerImpl.<clinit>(RepositoryMa
    nagerImpl.java:31)
    at
    com.bea.content.manager.RepositoryManagerFactory.create(RepositoryManagerFac
    tory.java:22)
    at
    com.bea.content.manager.RepositoryManagerFactory.connect(RepositoryManagerFa
    ctory.java:35)
    Anybody knows where that class is? Perhaps my approach was wrong.
    tia
    panji.a

    Hi Greg, thanks for the confirmation. I think I'm going to access the
    repository values in database directly, bypassing the repository API.
    panji.a
    "Gregory Smith" <[email protected]> wrote in message
    news:[email protected]..
    Whoops, I should have caught this in the first message.
    The repository code is based upon local EJBs, so the api doesn't support
    t3/rmi based access.
    So, to write a non-server based application to access the repository,
    you will need to construct a remoting piece which your application can
    access. One good way would be to create .jws's which access the
    repository code. .jws are WebServices, and I believe you can generate
    client jars for them (I don't know the details about that). But, then
    your client application would communicate via HTTP and SOAP to the .jws,
    which would then communicate to the repository code. If you do this, you
    won't need content_system.jar or wps_system.jar in your app's classpath.
    Greg
    Panji Aryaputra wrote:
    Thanks for the prompt reply. It works, but now I'm getting another error
    message: Repository configuration error
    Looks like I missed something. That error comes from this piece of code:
    RepositoryManagerFactory.connect()
    "Gregory Smith" <[email protected]> wrote in message
    news:[email protected]..
    portal/lib/content_system.jar. You can just add server/lib/weblogic.jar
    and portal/lib/wps_system.jar to your classpath to get most everything
    portal at runtime.

  • Accessing JNDI from Standalone JAVA application

    Hi,
    I want to access the JNDI tree from my
    standalone java application. (ie I have
    one weblogic server contains all my ejbs and client - swing - application which accesses that. )
    Here I don't want to ship weblogic.jar
    file to the client with swing application
    because it is of ~ 20 MP.
    Any other way to specify the INITIAL_CONTEXT_FATORY class.
    My code is
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL, DTEConfig.PROVIDER_URL);
    But since I don't want to give the
    weblogic.jar bundle to my client, how he
    could manage this with out weblogic.jndi.WLInitialContextFactory
    with him to get the initialContext ?
    -Rajan Kumar

    You can strip out the jndi related classes from the weblogic.jar which can be distributed
    to the client installation. I don't think you will be violating any bea licensing
    policies with this.
    Rajan Kumar <[email protected]> wrote:
    Hi,
    I want to access the JNDI tree from my
    standalone java application. (ie I have
    one weblogic server contains all my ejbs and client - swing - application
    which accesses that. )
    Here I don't want to ship weblogic.jar
    file to the client with swing application
    because it is of ~ 20 MP.
    Any other way to specify the INITIAL_CONTEXT_FATORY class.
    My code is
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL, DTEConfig.PROVIDER_URL);
    But since I don't want to give the
    weblogic.jar bundle to my client, how he
    could manage this with out weblogic.jndi.WLInitialContextFactory
    with him to get the initialContext ?
    -Rajan Kumar

Maybe you are looking for

  • Problems with portrait/landscape alignment at DIA show.

    Problems with portrait/landscape alignment at DIA show. At DIA show the landscape / portrait alignment is mixed up some times, and getting worse if I go forward backward. Also the size is sometimes not correct. I have roughly 2000 pictures. If I see

  • Receiver determination Vs Interface determination

    Hi Experts,       What is the difference between Receiver determination and Interface determination? In both the case we specify sender -> outbound interface -> Receiver Service -> Interface mapping Can't we use only interface mapping? Why SAP is pro

  • Loud fan when opening macbook

    Hi, Since the other day whenever I open my macbook the fan is very loud intermittentley for about a minute and then stops completely until I close it and open it again. I have an early 2008 macbook. The problem just started a few days ago. We recentl

  • Delete operation for SQL using Biztalk Service

    Dear All, I have scenario like this "I am trying to insert the record to  Multiple Tables in SQL. When i got the exception in during the insert of the second table, i want to delete the inserted record from first table. this task achieve from Biztalk

  • Terms of Payment table

    Hi All, Can you please help me to find out the table name forTerms of Payment key where I can see the changes made to them by user id and date etc?. Thanks, -Kumar