How can I deploy a simple stateless ssion EJB and call it from a standalone client

Hi,
I'm creating s simple staless session EJB that has a method that takes a name and prints "Hello" + name. This EJB is in a package called "com.demos.mydemo.ejbs.hello"
How can I deploy this to OC4J?
How can I call it from a standalone client(no JSP, no servlets)?
In Sun's J2EE is very easy to deploy and I don't have to know any XML stuff.
can I use the .ear file created by the Sun's "deploytool" to deploy my EJB to OC4J?
This is the code at I'm using and it works on Sun's j2sdkee1.2.1:
///////// Remote /////////
package com.demos.mydemo.ejbs.hello;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface Hello extends EJBObject {
public String sayHello(String name) throws RemoteException;
///////// Home //////////
package com.demos.mydemo.ejbs.hello;
import java.rmi.RemoteException;
import javax.ejb.EJBHome;
import javax.ejb.CreateException;
public interface HelloHome extends EJBHome {
public Hello create() throws CreateException, RemoteException;
/////////// Bean class ///////////
package com.demos.mydemo.ejbs.hello;
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import java.sql.Connection;
import java.sql.SQLException;
//import java.sql.PreparedStatement;
import javax.sql.DataSource;
import javax.naming.NamingException;
import javax.naming.InitialContext;
public class HelloEJB implements SessionBean {
private SessionContext context;
private Connection con;
private String dbName =
"java:comp/env/jdbc/Oracle";
public HelloEJB() {}
public void setSessionContext (SessionContext context) {
this.context = context;
public void ejbCreate() throws CreateException {
try {
makeConnection();
catch (Exception e) {
System.err.println("HelloEJB: exception in ejbCreate:" + e.getMessage());
e.printStackTrace();
throw new CreateException(e.getMessage());
public void ejbActivate() {
public void ejbPassivate() {
public void ejbRemove() {
try {
con.close();
catch (SQLException ex) {
throw new EJBException("HelloEJB: exception in ejbRemove: " + ex.getMessage());
public String sayHello(String name) {
return "Hello " + name;;
private void makeConnection() throws NamingException, SQLException {
try {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection();
catch (Exception e) {
System.err.println("HelloEJB: exception in makeConnection:" + e.getMessage() );
e.printStackTrace();
//////////// EJB client that uses a stateless session bean
package com.demos.mydemo.ejbs.hello;
import java.io.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class HelloClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objref = initial.lookup("HelloSession");
HelloHome home = (HelloHome)PortableRemoteObject.narrow(objref,HelloHome.class);
Hello h = home.create();
String msg = h.sayHello("John Doe");
System.out.println(msg);
//h.remove();
} catch (Exception ex) {
System.err.println("Caught an exception." );
ex.printStackTrace();
Thanks
Nabil
null

<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Nabil Khalil ([email protected]):
I deployed and .ear file created by Sun's J2EE deployment tool on the OC4J. It looks that it was deployed fine -- did not get a deployment error.
When I run the client I'm getting the following error: Caught an exception.
javax.naming.CommunicationException: Can't find SerialContextProvider
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:60)
at com.sun.enterprise.naming.SerialContext.<init>(SerialContext.java:79)
at com.sun.enterprise.naming.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:54)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:668)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.<init>(InitialContext.java:178)
at com.equifax.fms.ejbs.hello.HelloClient.main(HelloClient.java:18)
This makes me think that the client can't see the deployed EJB on the OC4J.
How can I fix this problem?
Thanks
Nabil
<HR></BLOCKQUOTE>
Nabil -
Your standalone client needs to obtain certain server-dependent properties. You can provide them in your code or grab them via a properties file.
For Orion - you need essentially the following setup, filling in your own information...
Define your standalone client class with "main" etc (this is orion specific - should work for 9i AS as well - perhaps there are some differences)
public class SomeClass {
try {
Properties p = new Properties();
p.setProperty("java.naming.factory.initial",
"com.evermind.server.ApplicationClientInitialContextFactory");
p.setProperty("java.naming.security.principal","server_admin_name");
p.setProperty("java.naming.security.credentials","server_password");
// THEN you can get your intitial context reference
InitialContext initial = new InitialContext (p);...........
Then go about your business.....
A good book to get is called "Professional Java Server Programming J2EE Edition" - there happens to be a reasonable amount of Orion/OCJ4 centric information since one of the authors is Karl Avedal - one of the principals behind Orion. Go out to java.sun.com and look at some of the J2EE tutorials - unfortunately a lot of it is hidden behind the J2EE Deployer, but you will get a good sense of what goes into outside-the-container standalone clients.
null

Similar Messages

  • How can I create a function using TestStand variables and call it from a step's Pre-Expression?

    In one sequence I have dozens of Pre-Expressions which are almost the same thing, like this...
    Locals.tagID = (Parameters.singlePhaseEnabled ? "L" : "D") & Str(Locals.phase) & "006"
    ...and the only thing different is that three digit string at the end ("006" will vary). How can I write a function that I can call from a step's Pre-Expression so it would look something like this? ...
    Locals.tagID = MyNewFunction("006")

    You cannot write custom commands for expressions.
    That being said, there are a couple of options:
    Create a subsequence with a single step. Use a parameter of the sequence as "function parameter".
    Create a custom step type including a substep module which implements the function. Add an edit substep to enable the user of the steptype to gracefully change the parameter.
    Store the variable parameter in a local/file global variable and modify the value in each step. This will, at least, keep the "function" the same for every step.
    Norbert

  • How can I Burn a Simple DVD with Chapters and Menus out of My Home Videos.

    I created an iMovie (unsig iMovie 10.0.2) of my daughter's volleyball season.  I inserted markers separating each game day, hoping these would create chapters in my DVD.  Then I did some research about DVD burning apps and finally downloaded BURN.  With Burn I created a DVD, but this DVD did not have chapters and also did not have a customizable menu.  The whole movie ended up as one 2 hour long chapter.
    I have hundresd of family vacation on a hard drive stored and would like to start making iMovies of them to put on DVD for easy watching and forbackup  storing.
    What is a simple way I can burn my iMovie with chapters onto a DVD?
    My macbook pro did not come with iDVD so I dont have it.
    Thanks.

    MY source is HD i beleive. I shot videos with an iPad Mini.
    I ventured into this because I offered this DVD to several team parents, so they are waiting for me to give them the DVD.  While I was making it, I added subtitles, showing the game dates, game scores and stats of each player, so it came out really nice.  However, not to concern about quality, i have burt the video in a dual layer dvd in SD.  I dont have a blue ray burner nor media.
    This made me want to do the same with my family vacations vieeos, whic now are a bunch of files in a hard drive, sort them by vacation and add titles like lications to actualy be abel to watch them on a dvd someday.
    I have apple tv in the family room, but do not use to watch these videos, will look into that. However, I would still want to make the DVD's.
    It seems odd how this, basic feature, has been dropped. I guess apple does not want us to use any more discs.
    Still hoping I can do this, if not, I will have to gie away the DVDs with the 2 hour long video in a single chapter.

  • How can I run a 27" Apple Cinema Display and another monitor from my MacBook Pro?

    Hi everyone,
    I recently purchased a brand new 15"  MacBook Pro to replace my old one. I was told when ordering it that I would be able to hook up two external monitors to it using the Matrox DualHead2Go hardware. So, I also bought a 27" Cinema Display (non-Thunderbolt since it wouldn't work with the DH2Go). However, when I contacted Matrox they said their products don't support screens as large as the 27" ACD.
    Bummer!
    So, my question is: does anyone know how I can hookup a 27" Apple Cinema Display at 2560x1440 and a Acer 22" monitor at 1685x1050 (or, anything less really) to my new MacBook Pro?
    I've looked around and haven't been able to find a good answer.
    Thanks for your help!

    Will something like this work? A USB to VGA adapter? Can I use this at the same time that I have a Cinema Display plugged into the Mini-DVI port and will they both work at the same time? Anyone know?
    http://www.amazon.com/StarTech-Monitor-External-Adapter-USB2VGAE2/dp/B002FJQXXC/ ref=sr_1_2?s=electronics&ie=UTF8&qid=1329870330&sr=1-2

  • How can I get my contacts to the icloud and my ipad from my iphone

    help me get my contacts from my iphone to the cloud and my ipad

    Have you already set up your iCloud account on your iPhone?

  • Help: How can I deploy my [TP4]  Applications in Simple Steps using OC4J 11

    deploy apps to OC4J standalone TP4
    Hi,
    I installed Oracle Continer OC4J 11 and Started OK
    but with this warning " J2EE JNDI-00002"
    Now : How can I deploy my Application pls in Simple Steps?
    is this link below Related to Version [TP4] or what ?
    http://www.oracle.com/technology/products/jdev/tips/muench/oc4j11gtp/index.html
    thanks
    Forakora

    Read this thread:
    Can Jdeveloper TP4 deploy apps to OC4J standalone TP4

  • I had water damage to my iphone5 when I was deployed w/ the military overseas. How can I find out what saved to icloud and how to see where my photos are. I don't know when it was able to back up as wi fi was pretty sketchy. please advise. thx in advance

    I had water damage to my iphone5 when I was deployed w/ the military overseas. How can I find out what saved to icloud and how to see where my photos are. I don't know when it was able to back up as wi fi was pretty sketchy. please advise. thx in advance
    My iphone is toast, I know I checked on icloud and see my emails from the day before it happened. Can I see when and what my phone backed up through itunes or icloud?
    Please please help i am lost.

    This was EXACTLY what I needed about the purchases I made from my device. However, is there a way to re-download other ones you've made from a computer? Because I realized some of them were not just purchased from my device.
    This is a picture of what it looks like now:
    http://tinypic.com/r/107quxu/7
    As you can see, the stuff circled in red doesn't give me an option to download from Cloud Beta because it already says "downloaded".
    any way to get around that?

  • How can i deploy adf-richclient-demo.war to tomcat?

    how can i deploy adf-richclient-demo.war to tomcat or
    how can i use adf faces 11G in tomcat or
    how long will the next version out?
    thank you!

    Hi,
    the demo is a WAR file. So if you have a tomcat version that supports JSF 1.2 then you should be able to deploy it like any other JEE WAR file
    Frank

  • How can i deploy macbooks and 802.1x authentication using PEAP/MSChap version 2

    How can i deploy macbooks and 802.1x authentication for wireless connectivity using PEAP/MSChap version 2. The Cert is generated by a 2008 Windows CA authority. I am trying to get to join but the MAC doesnt seem to want to accecpt the cert. Can i not validate the cert and still have it join the 802.1x wireless netqwotk? The wireless netwotk is using a Cisco 5508 wireless controller and Cisco 1142 access points. All works fine with Windows devices.

    Hi Tarik,
    Thanks for your answers,
    I've attached my configured AuthZ rules and AuthZ profile for provisioning,
    I want the process to be the same for iPhone, Android and Windows.
    1) Connect to the SSID
    2) Login using your AD credentials PEAP-MS-CHAP-v2
    3) Redirect to device registration portal (So I can set a limit of 3 devices per employee)
    4) As soon as the client click "register" no more redirects and PERMIT-ALL
    I think that I don't need to rely on profiling because In terms of AuthZ policies it should be something like this:
    1) if WIRELESS802.1x and PEAP-MS-CHAPV2 and BYODREGISTRATION=!YES(Unknown or not reg) then "Redirect to device registration(that is NSP right?)"
    2) if WIRELESS802.1x and PEAP-MS-CHAPV2 then PERMIT-ALL(no redirection)
    3) everything else = DENY-ALL
    But the NSP looks for Client Provisioning policies, so if I don't configure any policy it should Allow Network Access(See attachment photo3.png) but as I said on the post it shows that cannot retrieve the MAC-Address so the client can't register his device and don't have access to the network. (To grant access I've configured provisioning policies, that way the clients can register their devices but they are redirected to google play or are forced to install the profile at iOS and this is what I don't want because it is not necessary)
    What screenshoot do you need after the registration? the Auth report?
    Thank you very much for your time!

  • How can I PRINT a simple list (e.g., .txt or .doc) of my bookmarks?

    How can I PRINT a simple list (.txt or .doc) of my bookmarks?

    You can export your bookmarks to an HTML file by going to Bookmarks > Organize Bookmarks. From that window select Import/Export and then Export HTML...
    See [[Exporting bookmarks to an HTML file]].
    Once you have that file, open it in Firefox or a text editor and print from there.

  • How can I deploy the WAR application in the Tomcat

    How can I deploy the WAR application in the Tomcat. Do I have to do any manifest file.
    Thanks
    S. Nikov

    First of all, which version of Tomcat are you using?
    Deploying a WAR file in Tomcat is very easy. Just put the WAR file in the %TOMCAT_HOME%\webapps directory and start Tomcat. It will automatically find the WAR.
    Please read the Tomcat documentation: start Tomcat and point your browser to http://localhost:8080
    Jesper

  • How can I deploy VI on cRIO?

    Hello all..
         How can I deploy VI on cRIO using LabVIEW 8.5... I want to deploy the VI once on cRIO and then run it without computer... I want a stand alone system... I know how to make .exe file from a VI... But I don't know how to deploy VI on cRIO and then launch it without computer.... can anybody please help...?
    Thank you for any help from you...  

    Have a look at the following help page:
    Running a Stand-Alone Real-Time Application (RT Module)
    Post back if you have any questions.
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • How can I deploy jCom moniker Servlet on integration Domain?

    Hi All,
    I am trying to know, how can I deploy moniker servlet on integration
    domain. I know if I run moniker class at console I can see the moniker string.
    But, I want to deploy this sevlet in integration domain, unable to find any documentation
    or help. Does any one did this in the past?? looking for help...
    Thanks,
    Gary H.

    Yeah, i am able to see the J2EE engine clusters, there the message server port is given as 3601. becoz scs instance number is 1 here. so it is not the problem,
    the error it is giving as,
    Jun 6, 2005 11:37:28 AM /userOut/deploy (com.sap.ide.eclipse.sdm.threading.DeployThreadManager) [Thread[Deploy Thread,5,main]] ERROR:
    [001]Deployment aborted
    Settings
    SDM host : obtdev9
    SDM port : 50018
    URL to deploy : file:/C:/DOCUME1/sireesha.b/LOCALS1/Temp/temp56446MyServletEAR.ear
    Deployment exception : Server obtdev9 did not accept login request as apiadmin on port 50018 - CmdXmlFactory could not find Top Element within String: "null".
    Inner exception was :
    Server obtdev9 did not accept login request as apiadmin on port 50018 - CmdXmlFactory could not find Top Element within String: "null".
    is this may be the problem with port number?
    i am not knowing what is happening here...
    if you know the exact error based on the error messgae please help me,
    thanks to u for helping in this problem,
    Regards,
    sireesha.

  • How can I deploy the Operation find all

    Hello together,
    I have a big problem. 
    How can I deploy the operation find all so that I can see it in the WSNavigator.
    There I can just see the CRUD operations and if I try to select the operation in the Developer Studio ,when I expose the webservice, the operation is highlighted grey. But if I test the Service I can see the operation and it works.
    ?????? But why can I test the service with the operation find all and why is it not possible to see the operation in the WSNavigator.
    Thank you

    Hi Srinivasan;
    thanks a lot. I could solve the problem with my <Cars>. I just deleted it. Now I have just a warning - message.
    The code looks know like:
    @com.sap.caf.dt.CAFOperation(name="GetAllCars")
         public gennari.mhp.types.Ret_Cars GetAllCars() {
              Ret_Cars ret_cars = new Ret_Cars();
              try {
                   Collection docList = this.getcarsService().findAll();
                   ret_cars.setTest((List) docList);
              } catch (CAFFindException fe) {
              return ret_cars;
    But if I try to run the operation as a webservice in the webservice navigator I have following error message:
    "com.sap.engine.services.webservices.espbase.server.additions.exceptions.ProcessException "
    Is this a problem with my Java AS or is still something in my Application Service responible fort that???
    Thats the XML Content:
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
          <faultcode>SOAP-ENV:Server</faultcode>
          <faultstring>com.sap.engine.services.webservices.espbase.server.additions.exceptions.ProcessException</faultstring>
          <detail>
            <yq1:com.sap.engine.services.webservices.espbase.server.additions.exceptions.ProcessException xmlns:yq1="http://sap-j2ee-engine/client-runtime-error">
              <!-- com.sap.engine.services.webservices.espbase.server.additions.exceptions.ProcessException -->
            </yq1:com.sap.engine.services.webservices.espbase.server.additions.exceptions.ProcessException>
          </detail>
        </SOAP-ENV:Fault>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Thank you
    Regards Marco

  • How can I deploy the setting of clear cache on exit for all users?

    How can I deploy the setting of clear cache on exit for all users?

    Note that Firefox disables the disk cache if you use "Clear history when Firefox closes" to clear the cache (see about:cache), so you can either disable the disk cache via its related pref or set the prefs related to clearing this data,but then other items that have a check-mark by default are cleared as well.
    *browser.cache.disk.enable
    *privacy.clearOnShutdown.cache
    *privacy.sanitize.sanitizeOnShutdown
    You can use a mozilla.cfg file in the Firefox program folder to lock prefs or specify new (default) values.
    Place a local-settings.js file in the defaults\pref folder where also the channel-prefs.js file is located to specify using mozilla.cfg.
    pref("general.config.filename", "mozilla.cfg");
    These functions can be used in the mozilla.cfg file:
    defaultPref(); // set new default value
    pref(); // set pref, but allow changes in current session
    lockPref(); // lock pref, disallow changes
    See also:
    *http://kb.mozillazine.org/Locking_preferences
    *http://mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files/
    *http://mike.kaply.com/2014/01/08/can-firefox-do-this/

Maybe you are looking for