Can't lookup session bean in MBean and ApplicationLifeCyleListener

Hi,
i am migrating an application with mbean from OC4J to weblogic 10.3.2.
as my application don't have a web module. i try to use the ApplicationLifeCycleListener
to register the mbean (instruction from this oracle document page:
http://download.oracle.com/docs/cd/E12839_01/web.1111/e13729
/instmbeans.htm#i1099957).
i register the mbean in the ApplicationLifeCycleListener.postStart method, but in the
mbean's method (which is called by a javax.management.timer.Timer, created in the
MBeanRegistration.postRegister method), i can't lookup the session bean.
(i try to lookup the session bean in the ApplicationLifeCycleListener.postStart method, it fails too)
if i register the mbean in a ServletContextListener, there is NO problem that i can
lookup session bean in the mbean's method.
why there is inconsistence in registrating mbean by servlet context listerer and by
applicationlifecyclelistener???
can anybody tell me the solution???
is it impossible to call session bean in the MBean's method if the mbean is registered
in the ApplicationLifeCycleListener ???
*** i want to call a session bean's method periodically through the timer ***
thank you very much.

gimbal2 wrote:
r035198x wrote:
I put the interfaces in a separate XX-si-jar file always.
The implementation jar then depends on that service interface jar which gets deployed on both the client and the server.
This way I can distribute my si without including implementation which I can change without needing to affect the clients.Yeah, that seems like the only real solution to me. Using Maven it shouldn't be that hard to manage either now that I think about it. Did you ever get into trouble with a client being based on an outdated interface jar? I can imagine that it can be a bit of a release management drama to keep these things synced.Interface changes when they did happen resulted in full redeployments because the client usually has to change anyway to use the changed functionality. Most interactions are through static interfaces so this doesn't arise too much.
In volatile interactions, a common approach is to define a generic interface EJB whose implementation can delegate the calls to other (potentially future) services. The problem with this is that return types have to be simple.
>
It's one of the reasons why I'm not a fan of optional interfaces in 3.1.Well the optional part is optional ;) To me it is a very useful addition since I usually only deal with local interfaces when I use EJB technology. I always found it a bit of a bother to HAVE to create an interface also, I welcome the change.It is handy to be able to roll out an app with a few classes all bundled in one deployment file if there is no requirement for multiple implementations of an interface or for remote invocation support.
I just feel that it's a lot of flexibility to sacrifice when doing the interfaces is not really a lot of effort with today's development tools.

Similar Messages

  • Newbie question: Can't see session bean in business operations after deployment

    Hi,
    I've just deployed a session bean (using WLS 7.0) sucessfully, but I can't see
    the deployed EJB in the business operations in studio. Am I suppose to update
    something on the integrator side that references the EJB? Or is there something
    else? Any help would be greatly appreciated.
    Thanks
    Aashish

    Hi,
    Sorry, but I don't know what you mean.
    Could you explain it more detailed, please?
    I see following, when start integrator.bat:
    [code]
    Developer 4.7 Build 999
    Exception in thread "Thread-3" java.lang.NullPointerException
            at com.wm.app.b2b.dev.DevConnectDialog.itemStateChanged(DevConnectDialog.java:253)
            at javax.swing.JComboBox.fireItemStateChanged(Unknown Source)
            at javax.swing.JComboBox.selectedItemChanged(Unknown Source)
            at javax.swing.JComboBox.contentsChanged(Unknown Source)
            at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source)
            at javax.swing.DefaultComboBoxModel.setSelectedItem(Unknown Source)
            at javax.swing.JComboBox.setSelectedItem(Unknown Source)
            at com.wm.app.b2b.dev.DevConnectDialog.<init>(DevConnectDialog.java:210)
            at com.wm.app.b2b.dev.DevMainFrame.doConnect(DevMainFrame.java:759)
            at com.wm.app.b2b.dev.DevMain$1.run(DevMain.java:195)
            at java.lang.Thread.run(Unknown Source)
            at com.wm.ui.UiFrame$7.run(UiFrame.java:344)
    [/code]
    Thanks.

  • I create simple session bean in jdeveloper and it has a problem in lookup

    the code of bean
    import java.util.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import javax.naming.*;
    public class CartClient {
    public static void main(String[] args) {
    try {
    Context initial = getInitialContext() ;
    // Object objref = initial.lookup("java:comp/env/ejb/SimpleCart");
    Object objref = initial.lookup("Cart");
    CartHome home =
    (CartHome)PortableRemoteObject.narrow(objref,
    CartHome.class);
    Cart shoppingCart = home.create("Duke DeEarl","123");
    shoppingCart.addBook("The Martian Chronicles");
    shoppingCart.addBook("2001 A Space Odyssey");
    shoppingCart.addBook("The Left Hand of Darkness");
    Vector bookList = new Vector();
    bookList = shoppingCart.getContents();
    Enumeration enumer = bookList.elements();
    while (enumer.hasMoreElements()) {
    String title = (String) enumer.nextElement();
    System.out.println(title);
    shoppingCart.removeBook("Alice in Wonderland");
    shoppingCart.remove();
    System.exit(0);
    } catch (BookException ex) {
    System.err.println("Caught a BookException: " + ex.getMessage());
    System.exit(0);
    } catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    System.exit(1);
    private static Context getInitialContext() throws NamingException {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "admin");
    env.put(Context.PROVIDER_URL, "ormi://localhost:23791CartApp");
    return new InitialContext(env);
    } javax.naming.NameNotFoundException: Cart not found
         java.lang.Object com.evermind.server.rmi.RMIContext.lookup(java.lang.String)
              RMIContext.java:130
         java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
              InitialContext.java:350
         void CartClient.main(java.lang.String[])
              CartClient.ja
    exception

    Please post your question in jdeveloper forum at
    JDeveloper and ADF
    for quick response.
    Regards,
    Anupama
    http://otn.oracle.com/sample_code/content.html

  • Urgent: Can't lookup entity bean

    Dear all,
    I define a business process in workflow engine, which invoke a java class to get
    DB data through CMP entity bean. The entity bean was packed in to a ear and was
    workable/callable within the same ear.
    However, when the workflow engine can't invoke the entity bean, the workflow engine
    always throw exception as following.
         javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException:
    Unable to resolve 'app/ejb/ConsignmentEntityBean.jar#Consignments/local-home'
    Resolved: 'app/ejb' Unresolved:'ConsignmentEntityBean.jar#Consignments' ; remaining
    name 'ConsignmentEntityBean.jar#Consignments/local-home'
    I think the problem may occur in deployment/configuration. Since the problem is
    very urgent, anyone can help me? To all developers, How do you package/deploy
    Entity Bean in Integration Server?
    Thx,
    Philip

    I solved this.
    Since I was testing the action code only, I didn't define a navigation entry corresponding to the action string returned for this button:
    <h:commandButton value="Add" style="height:21px; width:51px;font-size:8pt; font-color: black;" action="#{resourceBean.addAction}">
    </h:commandButton>After I added a nav definition, it worked. I don't know why at this point. I suspect a key step in the lifecycle was pre-empted...someone else can probably explain why. If I get a chance to research it after I'm done with my project, I'll update this post.
    Thanks.
    -L

  • How can we share session information between browser and WebView

    Hi
    I have a web application which launches a instance of JavaFX web view on a click of a button. My issue is that when i launch this web view it creates a  new session of its own ,how can you transfer the session information of the parent (browser) to the web view.
    One of the solution i found was to add the JSESSION_ID cookie into the default(System-wide) cookie handler so it would override the existing cookie within the WebView cookiehandler.
    http headers - Setting a cookie using JavaFX&amp;#39;s WebEngine/WebView - Stack Overflow
    Are there any other solution for sharing session information between the web view instance and browser that launches it ?

    O.K. then, is it at least possible to access a wwsto_api_session
    from Java in the following way?
    Calling PL/SQL from Java
    JDBC and SQLJ allow you to call PL/SQL stored functions and
    procedures. For example, suppose you want to call the following
    stored function, which returns
    the balance of a specified bank account:
    FUNCTION balance (acct_id NUMBER) RETURN NUMBER IS
    acct_bal NUMBER;
    BEGIN
    SELECT bal INTO acct_bal FROM accts
    WHERE acct_no = acct_id;
    RETURN acct_bal;
    END;
    From a JDBC program, your call to the function balance might look
    like this:
    CallableStatement cstmt = conn.prepareCall("{? = CALL balance(?)}");
    cstmt.registerOutParameter(1, Types.FLOAT);
    cstmt.setInt(2, acctNo);
    cstmt.executeUpdate();
    float acctBal = cstmt.getFloat(1);

  • How we can make a session bean starts up automactically

    I have a session managed bean, and this managed bean instanse is created only when a JSF page where its componene is bakced by that bean.
    My question, I have a case in where I need to instantiate the same bean on starts up of the application automatically.

    Thanks a lot BalusC !
    Once I read you reply I immediately knew how wrong my question was!
    My case is that I wanted to use your method (explained in your blogs) to get an instance of a session scoped bean called (approvalInsertionBean) as following:
    FacesContext context = FacesContext.getCurrentInstance(); 
               ApprovalInsertionBean appInsBean = (ApprovalInsertionBean) context.getApplication().evaluateExpressionGet(context, "#{approvalInsertionBean}", ApprovalInsertionBean.class);But I go the follwoing checked exception once I finished completing the lines above
    The type javax.el.ELException cannot be resolved. It is indirectly referenced from required .class files I remember in one of your reply is that it is a classpath problem, but which El jar files I shoud check, becasue I have (commons-el.jar) and I couldn't find (el.jar). I use JSF 1.2
    There is no jar files in WebInf/lib
    Many thanks for your time in helping others !

  • Session bean lookup during MBean registration

    1 Timer Session bean is created but not started.
    1 static MBean is declared in orion-application.xml
    In the MBean constructor, a JNDI lookup is done on the timer session bean to start the timer (method from the Timer session bean)
    The JNDI lookup fails !!
    Is it possible to call a session bean from an MBean constructor ??
    It seems to be the same pb when i try to access a JNDI ressource (db) from any MBean constructor.
    Is there a way (post construct) to access JNDI or session bean after MBean registration ?

    javax.naming.Context c = new
    text c = new javax.naming.InitialContext();
    ejb.ejbCustomerDbLocalHome rv =
    calHome rv = (ejb.ejbCustomerDbLocalHome)
    c.lookup("ejb/ejbCustomerDbBean");
    ejb.ejbCustomerDbLocalHome rv = (ejb.ejbCustomerDbLocalHome)c.lookup("java:/comp/env/ejb/ejbCustomerDbBean");

  • How to get stateful and stateless session bean in second jsp

    I create stateful session bean in the first jsp, then how can I get the stateful session bean in the second jsp? I find that somebody store the bean in HttpSession.
    If I store the stateful session bean in HttpSession, then I can get it in the second jsp. My problem is that I can store the stateless session bean in HttpSession, and get it in the second jsp. Then, both stateful and stateless can maintain the state in the second jsp. What is the difference between stateful and stateless session bean in this case ?
    I understand the definition of stateful and stateless session bean, but I'm confuse how to use session bean. Can anyone provide sample jsp to show difference of stateful and stateless? How the stateful session bean can maintain the state for the client?

    Greetings,
    I create stateful session bean in the first jsp, then how can I get the stateful session bean in the
    second jsp? I find that somebody store the bean in HttpSession.Which is the correct scope for sharing client-specific data when 'request' scope is insufficient.
    If I store the stateful session bean in HttpSession, then I can get it in the second jsp. My problem is
    that I can store the stateless session bean in HttpSession, and get it in the second jsp. Then, bothWhy is that a "problem"? Does your application not require the stateless bean to be shared? If so, then don't store the EJBObject reference in the session...
    stateful and stateless can maintain the state in the second jsp. What is the difference betweenWhat do you mean by this exactly?..
    stateful and stateless session bean in this case ?Statefulness of session beans is in regard to maintaining client state (er, in all cases). If your "stateless" bean is receiving information from the client (i.e. its caller) - either through a create method or a business method - and that information is available (retrievable from the bean) on subsequent method calls, then that bean is, in fact, stateful - regardless of how it is deployed.
    I understand the definition of stateful and stateless session bean, but I'm confuse how to use
    session bean.The correct question, it here seems, is "when" to use which type... Use a "stateful" bean when information about (from) the client (i.e. the caller) must be maintained across method calls of the bean. Use a "stateless" bean for general business methods that do not depend on "prior knowledge" of the client (i.e. the caller).
    Can anyone provide sample jsp to show difference of stateful and stateless? How the statefulA "sample JSP" would yield nothing additional... The semantics of calling, using, and "persisting", bean references are always the same - regardless of type or class. However, the reason(s) for using one over the other depends entirely on the needs of your application.
    session bean can maintain the state for the client?I recommend that you spend more time learning about EJBs generally. In particular, it seems you require more fundamental understanding of their scope and lifecycle. Refer to sections 4, 6, and 7 of the EJB 2.0 Specification.
    Regards,
    Tony "Vee Schade" Cook

  • Can this be done only with Session Beans ?

    Hi all,
    suppose I have an airline web selling ticket application.
    This is the web flow:
    -The user chooses destinations & date
    -The user chooses seats
    -The user confirms to buy
    If it's NOT required to persist itineraries until the user confirms to buy,
    can this be done ONLY with Session Beans ?
    I think that there aren't cuncurrency problems because even if two persons will book the same flight, they'll get different sequence Id (if the sequence is generated by the DataBase).
    I think the worst scenario is if two person book the last seat at the same time, one will get an error.......
    What do you say to it ?
    Thanks
    Francesco

    If it's NOT required to persist itineraries until the
    user confirms to buy,
    can this be done ONLY with Session Beans ?Yes. Even if persistence is required, you can use only session beans with some persistence mechanism.

  • Static methods in Session Beans problem

    Can a Stateful Session Bean have a static method?
    public static String foo();
    I tried to add a static method to a Stateful Session bean but had two problems:
    When I tried to add the static modifier to the Remote interface:
    static String foo();
    I got the following error message:
    Error(12,17): modifier static not allowed here
    When I tried to compile code calling this function :
    MyClass.foo();
    I got this message:
    Error(795,42): non-static method getNewSuffix(java.lang.String) cannot be referenced from a static context
    Even though a static method was compiled in this class. I assume it can't find the static modifier in the Remote interface which wasn't allowed. Are static methods allowed in EJB's at all?

    dear friend,
    1) Interfaces may not contain static functions!
    2) EJBs doesnt support static methods !
    Maybe you should go and learn more about Java and EJB's ?

  • Stateful session bean purpose?

    Currently I am struggling with the purpose of stateful session beans. Any client program should be able to maintain the state itself. Why am I using a session bean for this and loading the server with something that is really not of much value?
    Can anyone give me a good example of when I need a stateful session bean, or at least a good use for one?
    Thanks!

    The jsp can certainly save the info in the "session" object. But I can see how this would be easier.
    I have come to believe that stateful session beans just allow you to commonize your web interfaces with your non-web interfaces by abstracting lots of functionality into the EJBs.

  • Is it usefull syncronized method in session bean?

    hi all
    I know that each time I call a session bean my appllication server create one instance.
    So i wonder if it's a wrong idea declaring each session bean methods syncronized.
    Regards

    It's generally not a good practice to call your business classes directly from javascript.
    But you can place a mediator (business delegate) java class inbetween and can access the session bean instead.
    To access any java class using ajax, you may need a remoting library like DWR or JSON-RPC.
    These libraries offer very powerful and easy way to use ajax in your application.
    But if you want a more simpler solution, then have a look at libraries like "ajax4jsf" or "ajaxanywhere".

  • How to call session bean's method in JSP

    Hi All,
    I am working on a JSF web application by using sun studio creator.
    The first page have a button, the onClick javascript is as following, which bring up a alert box showing user login name.
    In JSP file, how can I call session bean's setUserName(String name) function (which I would like to store this UserName). So the following pages can use this information.
    If I can not do it this way, is there any other way to do it?
    Thanks in advance.
    var net = new ActiveXObject("wscript.network");
    alert(net.UserName);
    In managed-beans.xml
    <managed-bean>
    <managed-bean-name>BasicInfo</managed-bean-name>
    <managed-bean-class>treepractice.BasicInfo</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>

    You can find more information/details/examples at their own website.
    On the other hand, do you realize that that ActiveX stuff is IE proprietary? And that it is a browser configuration whether to allow them or not? And that this configuration is in IE7 defaulted to an (annoying) warning box before execution which is just bad for the user experience?
    With other words, forget that ActiveX garbage. Alternatives are Applets (not recommended) or Java Web Start (recommended).

  • Need of session bean in ejb?

    We can have the session beans business logic in Servlet using some support class(may be bean).I would like to know exact purpose & use of session bean in ejb specification.

    We can have the session beans business logic in
    Servlet using some support class(may be bean).I would
    like to know exact purpose & use of session bean in
    ejb specification.You can think of a SessionBean as a script. It handles certain business logic, for example, like book a flight. It might get the itinerary, charge the credit card, book a flight, etc. Usually, it is used as a facade, or front to one or more entity beans.
    Now, you could do these exact same things with servlets, but the session bean allows you to have:
    1. A single transaction scope. If one of your processes throws an exception and you've updated, for example 2 database tables, this transaction can be rolled back and everything will be consistant.
    2. Servlets, by nature, are threaded and you have to take special care with synchronization issues of any member variables that you may use in the servlet. With EJBs there are no synchronization issues.
    3. Security. You can specifically disallow/allow access to methods based on roles that you define.
    These are the big reasons for using EJBs. Yes, you can do all of this with servlets, but you'd have to do it yourself ... but why do it, if it is already done for you.
    I hope that that clears things up.
    Regards,
    Paul

  • How to lookup a Bean?

    i have successfully deployed an EJB by using J2EE deploytool.
    my source code to lookup the Bean as following:
    Context ctx = new InitialContext(System.getProperties());
    java.lang.Object objref = ctx.lookup("skey");
    home = (SessionKeyHome)PortableRemoteObject.narrow(objref, com.ibm.sessionkey.SessionKeyHome.class);
    i have read serval books and articles,there are different codes for lookuping a bean.Why?and when should we use this or that?
    But i get the error msg:
    Warning: unable to read transaction.interoperability config property
    java.io.FileNotFoundException: /export/home/ass/config/security.properties
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:103)
    at com.sun.enterprise.util.Utility.getPropertiesFromFile(Utility.java:42)
    at com.sun.enterprise.iiop.security.SecurityMechanismSelector.<clinit>(SecurityMechanismSelector.java:102)
    at com.sun.enterprise.iiop.IIOPSSLSocketFactory.getEndPointInfo(IIOPSSLSocketFactory.java:211)
    at com.sun.corba.ee.internal.iiop.ConnectionTable.getConnection(ConnectionTable.java:73)
    at com.sun.corba.ee.internal.iiop.ConnectionTable.getConnection(ConnectionTable.java:68)
    at com.sun.corba.ee.internal.iiop.GIOPImpl.getConnection(GIOPImpl.java:70)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.locateObject(InitialNamingClient.java:769)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.getIORUsingHostInfo(InitialNamingClient.java:597)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveCorbaloc(InitialNamingClient.java:573)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveUsingORBInitRef(InitialNamingClient.java:544)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.cachedInitialReferences(InitialNamingClient.java:1080)
    at com.sun.corba.ee.internal.corba.InitialNamingClient.resolve_initial_references(InitialNamingClient.java:981)
    at com.sun.corba.ee.internal.corba.ORB.resolve_initial_references(ORB.java:2425)
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:52)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
    at javax.naming.InitialContext.lookup(InitialContext.java:347).java:23)
    javax.naming.CommunicationException: Can't find SerialContextProvider
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:63)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)

    Hi,
    There r two ways to lookup. One is that u specify the provider while running the client. E.g:
    java -D java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
    -Djava.naming.provider.url=t3://localhost:7001
    or alternatively u can specify these two properties in the Properties object of your client. e.g:
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL,"t3://localhost:7001");
    Context ctx = null;
    Object obj = null;
    try
    ctx = new InitialContext(props);               
    obj = ctx.lookup("HelloJNDI");
    Which method to use is matter of convenience.
    Values of provider url & initialContext will change depending on the app server u r using.
    I hope this will help u.

Maybe you are looking for

  • Itunes Match Wont Upload 2000 Songs

    I just got itunes match,  I let it do its thing for a few hours and it started to upload the music. Then my interent crashed because the bell lines in my aera suck some times. and now I'm trying to get it to work again and it just stays at the point

  • PDF file and Microsoft Word files

    I love all the big improvements apple is making to their product lines. But I am a practical person who needs to open pdf. files and Microsoft Word files on the go. That is why I will still pick a Treo, Dash, and any other pda over the Iphone. When i

  • ITunes album artwork screen saver possible with external library?

    I just moved my iTunes library to an external drive to free up space on my MacBook, and I was wondering if there's a way to still use the album artwork screen saver when the external drive is not connected? I still have my artwork folder on my intern

  • Dynamic(Switch Independent) NIC Teaming Mode Problem

    Hi, We are using Switch Independent Dynamic distribution NIC Teaming configuration on Hyper-V 2012 R2 cluster. In the following graphs between 19:48 - 19:58 you can see clearly how dynamic NIC teaming mode badly affected the web servers response tim

  • Security and roles in Nakisa TVN

    When a Nakisa role is mapped to an SAP role, does it limit the data that the person who is running that role sees?  For example, if an employee logs in and is assigned a "Employee" role, is it possible to limit the org chart that the employee sees to