Get a remote interface from a local instance

hi,
I want to construct a bean locally on a server and then I want to pass the remote interface for that constructed bean back to a client. Is this possible?
Thanks

Yes. Take a look at SessionContext class. You can't construct a bean yourself, as its life is managed by container.
     * Obtain an object that can be used to invoke the current bean through
     * the given business interface.
     * @param businessInterface One of the local business interfaces
     *        or remote business interfaces for this session bean.
     * @return The business object corresponding to the given business
     *         interface.
     * @exception IllegalStateException Thrown if this method is invoked
     *         with an invalid business interface for the current bean.
    <T> T getBusinessObject(Class<T> businessInterface) throws IllegalStateException;

Similar Messages

  • A problem while getting a EJB remote interface from SJSAS 9.0

    I hava deployed a session bean in SJSAS 9.0
    I wrote some codes to get the remote interface as follow:
    Context ctx = null;
    Hashtable env = new Hashtable();
    env.put ("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
    env.put("java.naming.provider.url","iiop://127.0.0.1:3700");
    try {
    ctx = new InitialContext(env);
    } catch (NamingException ex) {
    ex.printStackTrace();
    try {
    Object cs =ctx.lookup(ejb.MySessionBean);
    } catch (NamingException ex) {
    ex.printStackTrace();
    A exception occured during the lookup operation.
    javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
    at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
    at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:453)
    at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:492)
    at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:470)
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at demo.Main.run(Main.java:46)
    at demo.Main.main(Main.java:62)
    Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
    at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
    at org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:406)
    at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:440)
    ... 5 more
    Anyone can solve this problem for me???
    Thanks a lot

    We don't recommend explicitly instantiating the CosNaming provider within a stand-alone java client when accessing beans within the Java EE SDK. We have a simpler approach that involves just instantiating the no-arg InitialContext. Details are in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Calling Remote interface from client

    Hi there!
    I am working on a BMP (using weblogic 6.1)
    My problem is - How do I contact remote interface from client. In my jndi tree I have mentioned only Home interface. Right now I am calling my remote interface like this:
    //contact home interface
    Object obj = ctx.lookup("APIHome");
    APIHome home = (APIHome) javax.rmi.PortableRemoteObject.narrow(obj, APIHome.class);
    //creating remote somehow - I got this clue from a website
    rem = home.findByPrimaryKey(new EntityPK("test1","test2"));
    //calling getter & setter methods
    rem.setWidth()
    rem.getId();
    This works...but doesn't make any sense to me. Why should we initialize remote interface as above. Or is there any other option. Can somebody please explain me more clearly about this concept.
    Thanks very much
    regards
    -Manasvi

    The HomeInterface contains two types of methods - create and find. The create methods create an instance of the entity bean(i.e., a record in the database) and the finder methods finds an existing record in the database, constructs an entity bean representing this row and returns the remote interface of this bean to the client for further manipulations.

  • How can I get the remote directory from an FTPActivationSpec header?

    The header message generated for the oracle.tip.adapter.ftp.inbound.FTPActivationSpec contains the file name, FTP host and FTP port. Is there any way of getting the remote directory as well?
    <schema attributeFormDefault="qualified" elementFormDefault="qualified"
    targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:FTPAPP="http://xmlns.oracle.com/pcbpel/adapter/ftp/">
    <element name="InboundFTPHeaderType">
    <complexType>
    <sequence>
    <element name="fileName" type="string"/>
    <element name="ftpHost" type="string"/>
    <element name="ftpPort" type="string"/>
    </sequence>
    </complexType>
    </element>
    </schema>
    This is already specified in the activation spec parameters:
    <activationAgents>
    <activationAgent className="oracle.tip.adapter.fw.agent.jca.JCAActivationAgent" partnerLink="ReadFileService">
    <property name="ftpRemoteDir" type="LogicalDirectory">out</property>
    <property name="portType">Read_ptt</property>
    </activationAgent>
    </activationAgents>
    But I don't want to have to add a separate preference parameter to hold the same thing if I don't have to. Alternatively, is there any way of querying the activation agent parameters from within an xpath expression, similar to "ora:getPreference()"?
    Cheers,

    add:
    <element name="directory" type="string"/>
    to the FTP adapter header WSDL

  • Getting a VI reference from specific application instance via ActiveX

    I have a DLL that a C program calls to pass data into my application.  For performance sake, we had to use ActiveX to get the data into my application.  I Open an ActiveX reference to my application and then open a VI reference to a Packet Stack and throw the data right into a queue.  If I am developing, I change an INI setting to use the LabVIEW ActiveX server.  This worked fine in 7.1 with the EXE and LabVIEW.
    I recently upgraded the project to 8.5.  The EXE still works with no issues, but in LabVIEW, the DLL always opens up the VI in the Main Application Instance.  If I start my program in the Main Application Instance, then everything works fine.  The problem is if I launch my program froms its project.  Then my program is running in the My Application Instance, and when the DLL calls the Packet stack, the packets don't get put into the queues in My Application.
    I saw this thread where Ben used VI server to find out what project a VI belonged to.  This started me looking into using a similar method, but it seems I have to traverse the entire project to get to the VI to open a reference to it.  What I would prefer to do is look in two places, Main Application and My Application for the VI and determine its run state.  I was hoping there was some way in the VI name for open VI reference that I can specify the instance.
    Please note that I am using ActiveX, not TCP/IP VI Server, so I do not believe the method outlined here can be used.
    Thank you for any assistance.

    I think this should help. I have never used the ActiveX interface but this is what I think that you want.
    Off course you need to translate this into C but that shouldn't be the problem
    Ton
    Message Edited by TonP on 02-18-2008 07:16 PM
    Message Edited by TonP on 02-18-2008 07:16 PM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    GetVIFromActiveX1.png ‏5 KB

  • How to deside weather to write local interface or remote interface

    Hi All.
    in Ejb 2.0 the concept of local and remote interface is introduced.then how to deside weather to wrire local interface or to write remote interface.
    thanks

    Here in lies the problem. That decision shouldn't be up to a developer, it should be the role of the deployer who decides this. I think they got this wrong in 2.0, its been put at the wrong level. You as the coder need to make scalability decisions about the deployment, which you shouldn't need to. One of the big stengths of the EJB's is that anyone can code them because the container does the hard work for you. That paradigm has been broken now, IMHO.
    Having said that, I was at a SUN developer day just the other day and they suggested that the local interface was mainly for fine grained entity beans and that the course grained entity beans would access the fine grained over local interfaces thus allowing a 'cheaper' implementation of relationship modeling in the entity bean layer. In this scheme of things you would then use the remote interface from session beans to access the course grain entity beans.
    Cheers,
    Peter.

  • How to get creation date from Fuego.Papi.Instance

    I got all process instances from papi. The instances are Fuego.Papi.Instance.
    I also need the creation date of the process instance, but I cannot find it in Fuego.Papi.Instance.
    How to get the creation date from Fuego.Papi.Instance?
    Thanks,

    Yes, I knew Fuego.Lib.ProcessInstance is able to get creation date.
    But my code is not in the that process. I am using papi to get the process instance which returns me Fuego.Papi.Instance. Is there a way to get Fuego.Lib.ProcessInstance from Fuego.Papi.Instance?
    My code is like this
    businessProcess = ProcessService.getProcess(process : "processName");
    instances = businessProcess.getInstancesByFilter(filter : instFilter);
    //then loop each instance and I need the creation date

  • TraderService Remote Interface

    Why is the TraderService back end stateless session EJB implemented with remote
    interfaces instead of local interfaces. If I'm not mistaken, upon reaching this
    service, all processing will be co-located on one server, therefore, wouldn't
    it be more performant to implement this EJB with local interfaces?

    Hello,
    The examples are simply starting points to assist your own development
    work.
    You might want to take a look at the web service design guide [1] in the
    docs. If you are deploying to a cluster of WebLogic Server instances,
    by default the deployment targets all server instances in the cluster.
    This corresponds to homogenous module deployment, which is recommended
    in most clusters. See [2].
    Regards,
    Bruce
    [1]
    http://edocs.bea.com/wls/docs81/webserv/design.html
    [2]
    http://edocs.bea.com/wls/docs81/deployment/overview.html
    Sean Cohan wrote:
    >
    Why is the TraderService back end stateless session EJB implemented with remote
    interfaces instead of local interfaces. If I'm not mistaken, upon reaching this
    service, all processing will be co-located on one server, therefore, wouldn't
    it be more performant to implement this EJB with local interfaces?

  • Slowness in Retrieval of Remote Interface

    We are running Weblogic 6.1 with service pack 2. Recently we saw that it was taking
    from 1 to 2 minutes to get a remote interface to a session bean. Normally this
    takes less than a second. My question is, what "gotchas" are out there when it
    comes to the timeliness of accessing a session bean?

    The two lines of code causing the delay are:
    home = (TRSSessionHome)javax.rmi.PortableRemoteObject.narrow(contextForBean.lookup(TRSSessionHome.beanHomeName),TRSSessionHome.class);
    remote = home.create();
    What makes you think it is DNS? We are thinking that we are blocking on a thread
    somewhere? But this still doesn't account for the 2 minute delay. We saw no errors
    in our logs either. Any help is greatly appreciated because we haven't gotten a
    solution and the tech support guy is out of ideas until the problem happens again
    and I get him a thread dump.
    thanks,
    lisa
    Rob Woollen <[email protected]> wrote:
    Are you talking about the JNDI look-up, or the call to home.create. Is
    this a
    stateless session bean or a stateful session bean? Is the caller within
    the WebLogic
    Server or in an outside process/machine?
    My first guess is that you're having problems with your DNS. Try using
    the IP address
    instead.
    -- Rob
    Michael Dunnigan wrote:
    We are running Weblogic 6.1 with service pack 2. Recently we saw thatit was taking
    from 1 to 2 minutes to get a remote interface to a session bean. Normallythis
    takes less than a second. My question is, what "gotchas" are out therewhen it
    comes to the timeliness of accessing a session bean?

  • One remote interface vs. lots of interfaces

    Hi,
    I am now designing an API using RMI.
    I can do it in 2 ways: One remote interface which has lots of functions,
    or seperate it to lots of logical interfaces, which the client needs to get a remote interface of all of them.
    Does anyone face this problem before? what do you think?
    Thanks.

    If those are your only options, I would recommend using several smaller logically grouped interfaces, rather than one large one, because any changes to an interface require the generation and distribution of a new stub. In some cases, your client may not even need all the interfaces.
    However, there is another way to do it.
    You could use only one interface, containing only one method, which can support unlimited client interfaces, with no stubs. That is my favourite way to do it! Want to see more? Please come and visit, it is very easy to do, and it is completely free:
    https://cajo.dev.java.net/overview.html

  • Calling remote database obj in local procesure

    Dear Friends,
    If I want to refer any remote database object(Table or procedure)
    in my (local) procedure, should I be a valid user of that database?
    If so, how should I connect to that remote database from my local
    procedure?
    If I should not be a user of that Database, then how does the connection
    occur?
    Have a nice time,
    Tarek Khan

    You have to create a database link and use it
    RTFM about how to create them

  • Calling a Remote EJBSession Facade from a Local EJBSession Facade

    Hi, I'd like to understand the way of calling a remote ejb application from a local ejbsession facade using its methods (throught data control palette) without I have to generate a Java Client. To do this, where do I put the code to get the remote ejb facade instance?.
    Thanks in advance.

    My problem is to call a application server, using rmi/jndi from a local application which has been developed using ADF+JSF+Toplink.
    Concretely, into a backing bean method I need to call a method that this available one in the facade of the other application, which resides in OAS.
    Using simple clients,it works fine, but I don't know the way to do it within backing bean, since creating a remote interface of the facade with the declaration of the remote method, it does not allow me to declare this like abstract. Nevertheless, and since already I have commented using a simple client it works to me.
    Help please.

  • Trying to create a local instance of the remote object

    Hi,
    I have a ClassA on which I need to be able to invoke RMI calls. Problem is the interface which ClassA implements does not throw exceptions. To get around this problem I have created a wrapper class ClassWrap which has a ClassA attribute and calls made to ClassWrap are directed to this ClassA object. A facade type design I think it's called.
    ClassWrap implements Remote so it can be used as a Remote object.
    When I create an instance of ClassWrap and deploy it on a server, my client has no problem communicating with the remote ClassWrap object via a remote stub ClassWrap_Stub.
    Problem is I also want my client to be able to use a local instance of ClassWrap. Whan I try to create an instance of ClassWrap in my client I get a remote Exception ... but !! when I have a ClassWrap_Stub object in my classpath then there is no problem creating a ClassWrap object.
    Any ideas why this happens?

    What you are trying to do should work just fine. Do you have the wrapper class file in your client jar?

  • Lookup Local Interface from client app

    I have had an entity bean running using the remote interface.
    When I convert over to using a local interface I have problems
    with the jndi lookup. My environment is JDK 1.4, J2EE 1.3.1, Win 2k.
    The deployment using the J2EE RI works fine.
    I need to know what changes to the client code I need to make
    to locate the bean using lookup().
    I have tried two versions of the lookup:
    // same as the version which workds for the remote interface
    Properties p = new java.util.Properties();
    Context ctx = null;
    p.put (javax.naming.Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.cosnaming.CNCtxFactory");
    p.put(javax.naming.Context.PROVIDER_URL,
    "iiop://localhost:1050");
    ctx = new InitialContext(p);
    Object objref = ctx.lookup("LocalSPIConnector");
    cat.debug ("GOT THE OBJ REF");
    spiHome = (ServiceProviderBeanLocalHome)
    javax.rmi.PortableRemoteObject.narrow (objref,
    ServiceProviderBeanLocalHome.class);
    cat.debug ("AFTER NARROW");
    I get the following exception;
    javax.naming.NameNotFoundException. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosN
    aming/NamingContext/NotFound:1.0
    In the J2EE RI I can see that this JNDI is associated with the bean.
    Is there a different context factory to be used?
    I have tried to use the initialContext and then lookup
    various forms of the JNDi name:
    a. LocalSPIConnector
    b. java:comp/env/ejb/LocalSPIConnector
    c. java:comp/env/LocalSPIConnector
    d. the classpath to the home interface
    All these fail as the name has not been bound

    Thanks for the reply.
    I have simpliefied the lookup to the following:
    Context ctx = new InitialContext();
    spiHome = (ServiceProviderBeanLocalHome) ctx.lookup ("ServiceProviderBeanEJB");
    I still get the following exception:
    javax.naming.NameNotFoundException: ServiceProviderBeanEJB not found
    at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:174)
    I looked up the deployment descriptor from J2EE RI and took the name
    to lookup from the ejb-name:
    <ejb-jar>
    <display-name>localSPIJAR</display-name>
    <enterprise-beans>
         <entity>
              <display-name>ServiceProviderBeanEJB</display-name>
              <ejb-name>ServiceProviderBeanEJB</ejb-name>
    I presume that this is the correct name to use.

  • Calling a remote SSH script from a local script

    When I paste this in Terminal I get the expected output:
    ssh -2 root@$SERVER /Library/WebServer/Sectrum.com/Sectrum/RSS/Update.py
    However when I invoke the same command scriptomatically I get error:
    : No such file or directoryctrum.com/Sectrum/RSS/Update.py
    It looks like the command line is truncated by a control character? What's going on?
    Are there special rules when calling an SSH remote script from inside a script on the local machine?

    Just tried a test with
    #!/bin/sh
    ssh [email protected] command
    with a remote (non-Mac OS X) box, and it worked as expected. Can you post more of an example, or can you try (for instance) invoking a bash script on the remote box with, say, an echo command or two? Try to break down the problem space here.
    And in no particular order...
    The root user wouldn't be my choice for this sort of thing, given the sensitivity of that username.
    Try (for testing) using localhost as the host name, or the full host name.
    Confirm $SERVER (and I'd probably use the ${SERVER} notation for that) is working with an echo.
    And as a completely different approach, it might work to add and use a CGI path into the web server for this operation, too; to use a path other than ssh for the operation. Or (depending on what you're really doing here) maybe a periodic script. (Or Xgrid, maybe ARD or such, or any of various available distributed command environments.)

Maybe you are looking for

  • New problem printing from InDesign CS4 in Lion

    After having great success with Aisolve's earlier fix on printing from InDesign CS4 after upgrading to Lion, I'm having a new problems after installing the OS X 10.7.2 upgrade last week. When I try to print from  InDesign CS4 and Illustrator CS4 to m

  • How to use oJavaScript parameter in SubmitForm method?

    Hello, I have some difficulties to use the oJavaScript parameter in the submitForm method of document object. What I want to do is having a program filling some fields of my form from data the user write in some other fields. Then the updated fields

  • Disabled built-in mic

    Hi. I have a mac mini MC815BZ/A which has a built-in mic, but when I enter on garage band the program says that there are none "integrated MIDI in". Also, all the system doesn`t detect the presence of a integrated mic. But it's not all the problem: w

  • Colors of bar chart dynamically

    Hi, I need help on this requirement.  I have a product as a dimension and hex# color code as its attribute,  and they both coming over through the datasource.  I want to create a bar graph that would use the color hex from each product to display it

  • MobileMe Password Error

    I know that MobileMe has been inactive for some time, but a message pops up on my screen every 10 minutes telling me that I have "entered an invalid MobileMe member name or password." I can't remember my password, and cannot get the messages to stop.