Can't get the Home interface of a Session bean,please!

when I run a client of a SessionBean,(use command "java ....";
the Exception was thrown:
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at clientTest.ClientTest.main(ClientTest.java:35)
the mothed main() :
java.util.Properties jndiProperties = new java.util.Properties();
jndiProperties.put("java.naming.provider.url","iiop://localhost:3700");
jndiProperties.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
try {
javax.naming.directory.DirContext jndiCtx = new javax.naming.directory.InitialDirContext(jndiProperties);
Object obj = jndiCtx.lookup("ejb/Stock");
System.out.println(obj);
StockHome sh = (StockHome)PortableRemoteObject.narrow(obj, StockHome.class); //exception was thrown
}catch (javax.naming.NamingException ne) {
ne.printStackTrace();
} catch (Exception e){
e.printStackTrace();
Must I run it in the jar file deployed to appServer?
it's very inconvenient!
Thanks!!

Hello
Inline there are the answers
[email protected] (Grand Gana) wrote:
Hi !
I want to know how to get the local interface of a session ejb from a
jsp page ???
My session ejb is in a jar, and my jsp page is in a war. (they're not
together in a ear)You cannot call your EJB by a local interface by this way.
The war and the ejb-jar must be in the same ear.
This is due to classloading architecture.
I can have access to a remote interface of an other session ejb from
a
jsp page doing :
     InitialContext ctx = new InitialContext();
     Object objref = ctx.lookup("article.ArticleManagerHome");
     ArticleManagerHome home = (ArticleManagerHome)
PortableRemoteObject.narrow(objref,
ArticleManagerHome.class);
But I can't have access to the local interface from the same jsp page
doing :
     MyManagerLocalHome home = (MyManagerLocalHome)ctx.lookup
("article.MyManagerLocalHome");
I get the following error :
javax.naming.NameNotFoundException: Unable to
resolve 'article.ArticleManagerLocalHome' Resolved: 'article'
Unresolved:'ArticleManagerLocalHome' ; remaining
name 'ArticleManagerLocalHome' This is another problem.
Check the jndi name in the ejb-deployment descriptor or check the jndi on your
server to verify that a local interface implementation has been bound to it.
>
What should I do ???
(I don't want to put them in the same ear)
An EJB reference in the web.xml of my war ??? How ?
A lookup with java/comp/... ??? How ?
I don't understand !!! It's so difficult to do simple things !
Bloody EJBs !!!Noooooo ;)
But I can agree with you on local interfaces ....
The J2EE specs speak about "same virtual machine" ....
But classloading architecture "speaks about" "same classloader" (same ejb-jar)
or "related classloaders" (war and ejb in same ear).
I think something is still missing ....
>
TIA
JCMark

Similar Messages

  • How to get the UserTransaction object in  stateless session bean

    Hi, I am using jboss server and jdk5 version and using EJB.
    My Application flow :
    JSP à Action(Struts) à Service Locator à Session bean à Entity Bean(cmp) à DB.
    I tried to get the UserTransaction object in my Action. Its my code.
    InitialContext ctx = new InitialContext();
    UserTransaction uTrans = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
    After used uTrans.begin(),uTrans.commit() and uTrans. rollback () also.
    Its working fine .
    But, I used the the same code inside in my session bean its not working.
    Stateless Session Manager Bean code :
    public class SampleManagerBean implements SessionBean {
    public void ejbCreate() throws CreateException {  }
    public void ejbRemove() {  }
    public void ejbActivate() {   }
    public void ejbPassivate() {   }
    public void setSessionContext(SessionContext sessionContext) {
    this.sessionContext = sessionContext;
         public void createSample() throws EJBException
         try{
                   InitialContext ctx = new InitialContext();
                   UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
              }catch(Exception e) {
              System.out.println(“ Exception === > “+e)
    Its throws the error ie: javax.naming.NameNotFoundException: UserTransaction not bound
    How to get the UserTransaction object in my session bean. Kindly give solution the above errors.
    - Thendral

    first of all, you could just use sessionContext.getUserTransaction(). however, that would only work if your bean is using bean-managed transactions. the default is container-managed transaction, in which case you cannot get a UserTransaction object. if you want to manage transactions, you need to add the TransactionManagementType.BEAN annotation to your ejb.

  • HT204053 Why can'T I get the store to work. I have tried the search and nothing happens. I want to buy more spongs and can only get the home page to show the music

    I have been trying to get an album of George Jones to load to my Ipad i can't get the store to let me search ? What am O doing wrong

    (for an example of what I mean, my site: http://www.katesilsby.com (retouch page) and what old iweb did and what I want to happen: http://web.mac.com/vogier/iWeb/vivian%20ogier/wardrobe.html
    iWeb2 photos page is completely different from that of iWeb1.
    iWeb2 photos page can be retro back to iWeb1, but not without major javascript coding.
    or using completely different previewing method for larger image, example: http://hdl.50webs.com/Lytebox/Photos.html

  • I hit Reset and lost everything.  I have the apple and a line under it.  How can I get the Home Page back?

    How can I get back to the Home Page?  I hit reset and lost everything.  I have a dark screen with the white apple and a line under it. 

    Wait until it finishes restoring. It would be a good idea to connect it to the charger so it won't run out of power during this process.

  • My macbook air won't load.  Says start up disk is full but I can't get the home page to open

    My Macbook air won't load.  Says the start up disk is full but won't open the home page so I can do anything about it

    Step 1   
    The first step in dealing with a startup failure is to secure the data. If you want to preserve the contents of the startup drive, and you don't already have at least one current backup, you must try to back up now, before you do anything else. It may or may not be possible. If you don't care about the data that has changed since the last backup, you can skip this step.
    There are several ways to back up a Mac that is unable to start. You need an external hard drive to hold the backup data.
    a. Start up from the Recovery partition, or from a local Time Machine backup volume (option key at startup.) When the OS X Utilities screen appears, launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.” The article refers to starting up from a DVD, but the procedure in Recovery mode is the same. You don't need a DVD if you're running OS X 10.7 or later. 
    b. If Step 1a fails because of disk errors, and no other Mac is available, then you may be able to salvage some of your files by copying them in the Finder. If you already have an external drive with OS X installed, start up from it. Otherwise, if you have Internet access, follow the instructions on this page to prepare the external drive and install OS X on it. You'll use the Recovery installer, rather than downloading it from the App Store.
    c. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, start the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    d. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.
    Step 2
    You might be able to start up in safe mode even though you can't start up normally. Otherwise, start up from an external drive, or else use the technique in Step 1b, 1c, or 1d to mount the internal drive and delete some files. According to Apple documentation, you need at least 9 GB of available space on the startup volume (as shown in the Finder Info window) for normal operation.

  • Can't get the arrangement I want in JPanel. Please Help!

    Hi all,
    I'm using a GridBagLayout to position several JLabels, JTextFields and JButtons...with the JLabels and it's respective JTextFields side by side and the JButtons at the bottom in a straight column.
    Thing is, no matter how I change the GridBagConstraints, the whole thing will still spread out to cover all the space available which is not what I want...is there a way to go about this using GridBagLayout??
    I've read about how you use the GridBagLayout in the Java doc but still unsure how the weightx and weighty works...suspect they might be the key to getting the result I want but so far no luck....
    can anyone please help? Thanks a lot :D

    hi yuhijen,
    when i replied to u last time, i ddin't explore the capabilities of the weightx or weighty fields of the GridBagConstraints!!
    so i'm sending u a code that'll give u exactly what u had wanted!! :-)
    import java.awt.*;
    import java.applet.*;
    /* <applet code="trialGridBL" width="500" height="400"></applet> */
    public class trialGridBL extends Applet{
         GridBagConstraints gbc;
         GridBagLayout gbl;
         Label L1,L2,Blank1,Blank2,Blank3;
         TextField T1,T2;
         Button B1,B2;
         public void init(){
              L1=new Label("Name");
              L2=new Label("Password");
              Blank1=new Label("");
              Blank2=new Label("");
              Blank3=new Label("");     
              T1=new TextField(15);
              T2=new TextField(15);
              B1=new Button("Submit");
              B2=new Button("Reset");
              gbc=new GridBagConstraints();
              gbl=new GridBagLayout();
              gbc.gridy=0;
              gbc.anchor=GridBagConstraints.WEST;
              gbc.weightx=1;
              gbl.setConstraints(L1,gbc);
              gbl.setConstraints(T1,gbc);
              gbl.setConstraints(Blank1,gbc);
              gbl.setConstraints(Blank2,gbc);
              gbc.gridwidth=GridBagConstraints.REMAINDER;
              gbl.setConstraints(Blank3,gbc);     
              gbc.gridy=1;
              gbc.gridwidth=1;
              gbl.setConstraints(L2,gbc);
              gbc.gridwidth=GridBagConstraints.REMAINDER;
              gbl.setConstraints(T2,gbc);
              gbc.gridy=2;
              gbc.weighty=5;
              gbc.anchor=GridBagConstraints.NORTHWEST;
              gbc.gridwidth=1;
              gbl.setConstraints(B1,gbc);
              gbc.gridwidth=GridBagConstraints.REMAINDER;
              gbl.setConstraints(B2,gbc);
              // now set the layout for the contentPane (by default its BorderLayout)
              setLayout(gbl);
              // finally add the components
              L1.setBackground(Color.orange);
              add(L1);
              add(T1);
              add(Blank1);
              add(Blank2);
              add(Blank3);
              add(L2);
              add(T2);
              add(B1);
              add(B2);
    this is for awt, u just change it for swings.
    rgds,
    JP

  • I received a update yesterday and from then on I can't get the "home" page of Firefox, just a mostly blank sheet with "done" at the bottom??

    Nothing else will load when I'm on Firefox, Yahoo nothing just the white page.

    did that solve the issue? i still believe it has more likely to do something with faulty cache (maybe the restart of the browser really triggered it );
    if it was an issue with dns prefetching it would be rather strage since you already were on the domain instructables.com & wouldn't have had to resolve the domain for the subsites again. and since the server, your isp or your local hardware might not support ipv6 fully yet, it can always cause some glitches too...

  • Can't get the Window Media pluggin to work! Please help!!!

    I dragged the Windows Media thing over to my page and went over to the inspector and linked my wma music file to it. I previewed it in my browser. The small player that includes a slider, play button, stop button, previous button, and next button (all of which are unclickable) showed up but that's it. It won't play. It won't let me press play. What am I doing wrong?
    THANKS!

    Upload it to your FTP. This happens to be all the time, but once it's on the web (FTP) it works fine when you view it out of Adobe.

  • Where can I get the tutorial on the photoshop elements 11?

    Where can I get the photoshop elements tutorial?

    Hi asazakpam,
    Please refer the following links to learn more about Photoshop Elements 11 :
    Getting Started : http://helpx.adobe.com/photoshop-elements/topics/getting-started-tutorials.html
    Videos :
    http://tv.adobe.com/show/learn-photoshop-elements-11/
    http://prodesigntools.com/adobe-photoshop-elements-11-free-tutorials-pse.html
    http://www.youtube.com/user/photoshopelements
    Help file : http://helpx.adobe.com/pdf/photoshop-elements_reference.pdf

  • How can i get the IP & Hostname of remote pc?

    how can i get the IP & Hostname of remote pc?

    Please don't [double-post|http://forums.sun.com/thread.jspa?threadID=5403700]!

  • Hello, I forgot what apple ID and password i have in order to go into game center. All I know is the username. How can i get the apple ID and password back?

    hello, I forgot what apple ID and password i have in order to go into game center. All I know is the username. How can i get the apple ID and password back? Please help!

    i have the same problem did you find out how please ?

  • How can I get Connection(Database Connection)on my backing bean

    hello guys!
    How can I get the Database Connection on my managed bean?
    I want to use this connection for my reports.
    thanks a lot!
    alvin

    Alvin,
    You can access the data provider through ADF the binding. The data provider represents the business service you use. Once you have a handle to this you can get the connection.
    You don't mention the business service, so I cannot help you more than this. If it is ADF BC, have a look at http://download.oracle.com/docs/html/B25947_01/toc.htm and the stored procedure section. Steve Muench explains a trick to access the "real" JDBC connect used by ADF BC
    Frank

  • My iphone is broken,and i came to store to change a new one today. When I come home, I found I lost my backup and may be mistake is made during before backup.The information in my previous iphone is really important for me? how can I get the backup back?

    my iphone is broken,and i came to store to change a new one today. When I come home, I found I lost my backup and may be mistake is made during before backup.The information in my previous iphone is really important for me? how can I get the backup back?

    If you don't have a backup then the only possible solution is to go back to the store and see if they can get your old phone and create a backup of that. I know very often that Apple employees will wipe the returned iPhones clean before shipping them back to wherever they ship them.
    When you say your old phone was "broken" does this mean it is dead and won't turn on?
    Do you have a Time Machine backup of your computer, or a clone that might have this info on it?
    Other than that I hate to say you may be out of luck. Time Machine and/or a cloning program performed regularily will inevitably save your a** in situations like this.
    Good luck
    PM

  • Hello, so today I realized that my iPhone with iOS 6 is frozen on the music. I can get back to the home screen but I can't get the music player to work because its frozen on the w's and will not respond to touch. I would be grateful for any help on this.

    Hello, so today I realized that my iPhone with iOS 6 is frozen on the music. I can get back to the home screen but I can't get the music player to work because its frozen on the w's and will not respond to touch. I would be grateful for any help on this.

    Hi deamayfield,
    Thanks for visiting Apple Support Communities.
    If your Music app is unresponsive, try restarting/resetting your iPhone:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    Best,
    Jeremy

  • When I open a new tab, how can I get the second tab to be me my home page also?

    I know how to right click and open a new tab when I am browsing but if I want to open just a blank new tab, how can I get the second tab to be my home page also?

    I know how to right click and open a new tab when I am browsing but if I want to open just a blank new tab, how can I get the second tab to be my home page also?

Maybe you are looking for

  • Purchase order to sales order without third party

    Hi,   I have a requirement, we have one trading plant (depot)  the process is first we create the sales order as per or quoted sales price  then for each sales order we create one PO on our vendor,  the material is same as per sales order only,  so i

  • Pls convert this piece of SQL code to oracle

    Following is the SQL code---- Update reg_dim set reg_dim.Region_Description = st_reg.Region_Desc , reg_dim.Process_Date = sysdate from st_glt_region st_reg left join Dim_Region reg_dim on st_reg.Region_Abbreviation = reg_dim.Region where reg_dim.Regi

  • Error " the document has moved "

    on updated mozilla firefox 25 i go to my yahoo home page, every other thing i click on sending me to new page, ends up with error at top left, blank white page, says: the document has moved. then i am forced to click on the link to go to page, so its

  • Need help on Collecting Objects in Transports

    Hi All, I am collecting the Application Component for Transporting.While Collecting , i have given the grouping as "Neccessary Objects". But while executing,it is acting as a "Data Flow Before". It is installing all the below Objec ts.Please help on

  • Iisproxy conf iguratoin in weblogic5.1

              HI group           Am try to configure iisproxy, I am using weblogic5.1 sp6 and iis4.0.           I have the iis and the weblogic server in different machines, on iis machine i put           the iisproxy.dll, iisforward.dll and the iisproxy