RemoteExceptions and Entity bean failover

The documentation gives an example of how to achieve failover with
          entity beans. (See below). How can one tell that the RemoteException
          is due to the server being down rather than some other reason.
          For example in EJB 1.0 aren't many exceptions generated in the bean
          wrapped in a RemoteException? For example if there is an SQLException
          the bean might throw a RemoteException that wraps the SQLException. In
          such a case it doesn't make sense to try it again.
          So what is the correct way to find out whether the exception is due to a
          server failure rather than some other reason?
          dan
          AccountHome home =
          (AccountHome)ctx.lookup("example.AccountHome");
          Account account;
          int attempts;
          while (attempts < LIMIT) {
          try {
          tx.begin();
          account = home.findByPrimaryKey(ACCOUNT);
          account.deposit(500);
          account.withdraw(10);
          tx.commit();
          break;
          catch (RemoteException re ) {
          // Retry
          try {
          tx.rollback();
          attempts++;
          catch (Exception e) {
          // Something unrecoverable has happened
          throw e;
          

Yes, this is the "nasty" case as I've heard several people put it. It's among the
          problems that make distributed programming difficult. Since the database is managing
          the transaction log, the other app servers in the cluster do not know if the tx was
          committed or not either.
          -- Rob
          dan benanav wrote:
          > If a remote exception is thrown from an entity bean then is it the case that we know
          > the transaction has rolled back? What if the server went down after the transaction
          > was committed?
          >
          > dan
          >
          > Rob Woollen wrote:
          >
          > > dan benanav wrote:
          > >
          > > > Isn't there a more definitive way to determine whether the problem is due to a
          > > > connection error or the server being down?
          > > >
          > >
          > > My first answer to your question is why do you need this? Both a db
          > > connection error and the server going down should be relatively rare events in a
          > > production system. RemoteException is meant to indicate that a system-level
          > > error has occured and the transaction has rolled back. Doing another find in
          > > this case is not going to limit your application's performance / scalability.
          > >
          > > -- Rob
          > >
          > > >
          > > > Rob Woollen wrote:
          > > >
          > > > > dan benanav wrote:
          > > > >
          > > > > > The documentation gives an example of how to achieve failover with
          > > > > > entity beans. (See below). How can one tell that the RemoteException
          > > > > > is due to the server being down rather than some other reason.
          > > > >
          > > > > Any application error should be thrown as an application exception that
          > > > > you could obviously distinguish from RemoteException.
          > > > >
          > > > > As you correctly point out, db errors like SQLException are often
          > > > > wrapped in RemoteException when they reach the client.
          > > > >
          > > > > I would code the application to give up if it gets an application
          > > > > exception. For instance, if you try to withdraw more money than you have,
          > > > > there is no sense in retrying.
          > > > >
          > > > > I would retry (up to a small limit) on RemoteExceptions if it makes
          > > > > sense in your application. Even SQLExceptions may be transient. For
          > > > > instance, Oracle may not have been able to serialize your transaction on
          > > > > the first attempt, but your second try might go through.
          > > > >
          > > > > -- Rob
          > > > >
          > > > > >
          > > > > >
          > > > > > For example in EJB 1.0 aren't many exceptions generated in the bean
          > > > > > wrapped in a RemoteException? For example if there is an SQLException
          > > > > > the bean might throw a RemoteException that wraps the SQLException. In
          > > > > > such a case it doesn't make sense to try it again.
          > > > > >
          > > > > > So what is the correct way to find out whether the exception is due to a
          > > > > > server failure rather than some other reason?
          > > > > >
          > > > > > dan
          > > > > >
          > > > > > AccountHome home =
          > > > > > (AccountHome)ctx.lookup("example.AccountHome");
          > > > > > Account account;
          > > > > > int attempts;
          > > > > >
          > > > > > while (attempts < LIMIT) {
          > > > > > try {
          > > > > > tx.begin();
          > > > > > account = home.findByPrimaryKey(ACCOUNT);
          > > > > > account.deposit(500);
          > > > > > account.withdraw(10);
          > > > > > tx.commit();
          > > > > > break;
          > > > > > }
          > > > > > catch (RemoteException re ) {
          > > > > > // Retry
          > > > > > try {
          > > > > > tx.rollback();
          > > > > > attempts++;
          > > > > > }
          > > > > > catch (Exception e) {
          > > > > > // Something unrecoverable has happened
          > > > > > throw e;
          > > > > > }
          > > > > > }
          

Similar Messages

  • Flow of sessiob bean and entity bean

    Hi All,
    Can any one help me how is the flow of session and entity beans i.e
    What method is called first and what method is called next.
    There are so many methods like create(),ejbcreate(),
    ejbActivate(),ejbPassivate(),ejbDelete() etc.
    What is the flow of these methods and when they are called.

    Hi vasudulla,
    If you can, go to the bookstore and look for the book:
    Entreprise JavaBeans 3rd Edition by Richard Monson-Haefel.
    In the Appendix B, you can see the State and Sequence Diagrams, all the things you want to know about the Flow.
    --Paul.

  • How many ejbCreate() can be in Session and Entity Bean???

    Hi,
    How many ejbCreate() method can be in a Session and Entity
    Bean???
    How many can be in Stateless and Stateful SessionBean???
    How many can be in CMP and BMP SessionBean???
    Thanks,
    JavaCrazyLover

    How many ejbCreate() method can be in a Session
    ion and Entity
    Bean???For Stateful Session Beans and Entity Beans, as many as you'd like.
    Stateless Session beans can only have one, since their ejbCreate methods can not take any parameters.
    >
    >
    How many can be in CMP and BMP SessionBean???If you mean CMT/BMT(Container-Managed transactions / Bean-Managed Transactions), then
    the answer is the same. The create method requirements are independent of the transactional nature of the bean.
    If you really mean CMP/BMP(Container-Managed Persistence / Bean-Managed Persistence) , it doesn't apply to session beans, only entity beans. However, even for entity beans, CMP vs. BMP has no bearing on the rules regarding # of create methods.
    --ken
    >
    >
    Thanks,
    JavaCrazyLover

  • JSF and entity beans

    I'm trying to create an application using JSF for the presentation layer and entity beans and stateless session beans in the model layer using CMP, for deployment with JBoss. I'm basically stuck though on the communication between the backing bean and the session bean (where do I define the JNDI names, the database connection etc). Can anybody suggest a good tutorial/example showing JSF with EJBs?

    Well I was interested in the same topic, I once thought `Sun Java Studio Creator EA2` will have an easier approach ... well it dun seems easy to me neither.
    Anyone of you tried acheiving the purpose by using that approach b4?
    I'm currently working on a `JSF-based portlet` project with `entity beans + managed beans` ... well its very much source shared ... but I'm still green :P
    Anywhere, I'm starting a new thread called `JSF Portlet developement` in my blog (`http://avatar21.superihost.com`), feel free to comment(any ideas will be mostly appreciate).
    Regards,
    Avatar
    there is no specific support in JSF for EJBs.
    the definition of connection pools and other JNDI
    resources are subject to the servlet spec which JSF
    is built on top of.
    you can find usefull examples in the sun J2EE
    tutorial.

  • 8.1.7 and Entity Beans. Where is Patch 8.1.7.1???

    I would like to be able to deploy CMP Entity Beans to 8.1.7 on Solaris using JDeveloper 3.2.2
    The release notes indicate that this is a bug and is awaiting a patch. My two questions are:
    1. When can we expect Patchset 8.1.7.1 for Solaris?
    2. Could someone please describe for me the best way to write a CMP Entity Bean in JDeveloper 3.2.2 (w/descriptors & JAR'ed etc...) and then use the Oracle Command Line tools to load this bean? ie. what are the pitfalls?
    Thanks in advance.

    Thx alot..
    When will JDev 3.2 be available for evaluation download ?
    (The firm im working for is about to buy a complete system from the east, and i need to know how things perform before recommending purchase of system/archtecture and oracle tools).
    Incedently, i experienced a problem with session beans on 8.1.6, if i killed my client app somewhere along a lookup and remote.create the sessionbean would completely die, only thing to do was to redeploy it(not even reboot cured it) (i could create it, but reading serilized objects gave a marshall exception every single time..)
    I want to know if this is a known issue? and if it is, has it been 'fixed' in 8.1.7?
    By the way, everything is running on localhost on a win2k pro box.
    Thx alot for your time.

  • Proxy object and entity Bean interaction

    Hello,
    I'd like to have some precisions on the interactions between the proxy object (client) and the entity bean(server):
    - does J2EE provides ways for a bean to manage clients, to define roles and permissions, lock, etc ... ? What informations an entity bean can know about the clients ?.
    - how does the context mechanism work on the entity bean side ?
    - how does an entity bean identify different clients ? how does it recognize one from another ? I mean if client c1 and client c2 use same entity bean B, how B can manage different roles for c1 and c2, and how can B returns specific values to a particular client.
    Thx.

    If you can read some tutorial, you will get all the information.
    I'll suggest a book EJB by richard manson publicvations oreilly.
    The activities you are talking about is responsibility of container and user developed bean are totally absytracted from this system level activities.
    Primary service include security which take care of activities like Authentication, access control and secure communication.
    for role based access control u have container providing the identity by Principal object. DDescriptors declare which logical roles are allowed to access even perticular method of the bean.

  • DAO and entity bean

    I have an entity bean which has a lot of gets and set methods. i am calling all the methods in a DAO. The DAO Recognizes all the old methods but not the last one, i dont understand why a single get Set is not being recognized.

    Your question is not very clear. Could you tell the problem in details?

  • Web services and entity beans

    Hi,
    I want to implement a web service which stores some information.
    I decided to bulid it using ejb.
    Can i expose a web service as an entity bean?
    If so,can anybody introduce me some example?
    If not,what is the solution?

    Yes, u can do that by creating EJB controls first and then add that EJB control to WebService.
    Which Editor is using . if u r using Weblogic Workshop 8.1
    Creat project and then just right click and create EJB Control for that and then add this to web Service
    If u wanna any other information reply ..

  • Basic difference between stateful and entity beans???

    Could anyone please explain the basic diff between stateful bean and an entity bean.as per my understanding,stateful beans are extensions to clients.they perform a job of a client and they r not persistent.also their state goes off when the server crashes or the machine is reeboted.while in contrast,an entity bean can retain its session coz' they represent a persistent field in the DB.What i have seen in few books(O'reilly,etc)where a session bean can insert some values into the DB,which means it also represents a persistent object in the DB,which contradicts the statement that "stateful session beans dont represent any persistent object in the DB".Could anyone please elaborate on this.Thanks in advance.
    Jameel

    Thank u very much crackers for ur valuable
    suggestions.I'll throw a different one in here for free: clarity of writing is a highly-valued and useful skill in a software professional. This is especially true these days when concepts need to be clearly explained to a variety of technical peoples from all over the world. And then there's the other side of the coin: Management.
    You have to get your thoughts across in a very precise manner and, unfortunately for those who have to learn it as a second lanugage, English seems to be the overall preferred medium. Which makes it even more important to use "correct" English in written communications. If you don't, your credibility diminishes and you appear to be (horrors!) unprofessional It's not that much harder to type "you" than it is to use a single letter. Besides, most people that "pay by the byte" appreciate the clarity, as well (as I've seen on Usenet, by way of covering my ass).
    Now, back to our regularly scheduled post...
    Is this wat u were trying to say if i
    understood u correctly.Yes, the EntityBean is directly related to the data being persisted: in this case, a database table. So, using your example from below, the DB table would have two fields: a VARCHAR 'Name' and an INT 'Age.' The EntityBean would have corresponding fields/properties/variables, String name and int age.
    "WHICH BEAN (Entity
    or Sateful Session) SHOULD I GO 4???"No easy answer. The best one is: it depends. On what? It depends upon what you're trying to do with the data, how it's presented/manipulated, load requirements, environmental requirements, caching strategies, and about another dozen or so other high-level requirements.
    My personal preference is if I need caching and the number of EntityBeans actually in existence is pretty "low" (another nebulous and arbitrary value, depending), I'll use a StatelessSessionBean as a Facade (search for "patterns" here in the forum), with the persistence in CMP EntityBeans. Which is influenced by the fact that I like playing with CMP. ;D

  • Object Oriented Databases and entity beans?

    Does one of the authors care to comment on the benefits of using OODBMS models versus RDBMS models for entity beans? Any differences between BMP and CMP in this scenario?
    Thanks!
    Peter

    Bump?

  • Plaese  HELP  JAVA DEVELOPER DAO and ENTITY BEAN

    WHEN DO WE USE ENTITY BEAN INSTEAD OF DAO

    Generally DAO's are used with Stateless Session beans where the transactions may involve in different query executions. We go for Entity beans for persistence.

  • Multiple create methods of entity beans in single transcation

    Hi,
    I have some entity beans with CMR. I am managing these entity beans with a Stateful session bean whose transaction type is Container Managed for all its methods.
    In one particular method of this Session bean I am calling two entity bean's create method. i.e I am creating two entity beans through home.create() methods. There are two home.create() methods one after another inside a try catch block.
    I want that the entire operation be under just one transcation so i have also given the transaction attribute as Required for all methods of Session bean and Entity Beans.
    However if i pass invalid parameters to second create method so that it generates exception then still the first create statement is successful and database is updated.
    what i want is that the first create also should be roll backed.
    How can i acheive this through Container Managed Transaction Session Bean?

    Hi Ashwini,
    "Ashwini" <[email protected]> wrote in message news:400291af$[email protected]..
    I have some entity beans with CMR. I am managing these entity beans with a Stateful session bean whose transactiontype is Container Managed for all its methods.
    >
    In one particular method of this Session bean I am calling two entity bean's create method. i.e I am creatingtwo entity beans through home.create() methods. There are two home.create() methods one after another inside a try catch
    block.
    >
    I want that the entire operation be under just one transcation so i have also given the transaction attribute asRequired for all methods of Session bean and Entity Beans.
    >
    However if i pass invalid parameters to second create method so that it generates exception then still the firstcreate statement is successful and database is updated.
    what i want is that the first create also should be roll backed.
    How can i acheive this through Container Managed Transaction Session Bean?o Do you use TXDatasource with your entity beans?
    o In CMT transactions are automatically rolled back only when RuntimeExceptions
    are thrown. What kind of exception is thrown in your case?
    Regards,
    Slava Imeshev

  • RE: Accessing a CMP Entity Bean

    Hi There,
    I have written a couple of CMP entity beans. When I run the client application, I am getting a ORB minor code 257. The error message follows. My code works with both BMP entity beans and session beans. Can anyone help? Thanks in advance.
    Aug 21, 2005 10:24:57 PM com.sun.corba.ee.impl.encoding.CDRInputStream_1_0 read_value
    WARNING: "IOP00810257: (MARSHAL) Could not find class"
    org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
         at com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:7987)
         at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1013)
         at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:259)
         at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1989)
         at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2213)
         at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1221)
         at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400)
         at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:330)
         at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:296)
         at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034)
         at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879)
         at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:255)
         at com.sun.corba.ee.spi.servicecontext.UEInfoServiceContext.<init>(UEInfoServiceContext.java:30)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
         at com.sun.corba.ee.spi.servicecontext.ServiceContextData.makeServiceContext(ServiceContextData.java:114)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.unmarshal(ServiceContexts.java:195)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:365)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:353)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:470)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:327)
         at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:158)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:129)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
         at ctaejb.entitybean.order._IOrderHome_DynamicStub.findByPrimaryKey(_IOrderHome_DynamicStub.java)
         at mainapp.CTestApplication.main(CTestApplication.java:32)
    Caused by: java.lang.ClassNotFoundException
         ... 27 more
    org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe
         at com.sun.corba.ee.spi.servicecontext.UEInfoServiceContext.<init>(UEInfoServiceContext.java:34)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
         at com.sun.corba.ee.spi.servicecontext.ServiceContextData.makeServiceContext(ServiceContextData.java:114)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.unmarshal(ServiceContexts.java:195)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:365)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:353)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:470)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:327)
         at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:158)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:129)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
         at ctaejb.entitybean.order._IOrderHome_DynamicStub.findByPrimaryKey(_IOrderHome_DynamicStub.java)
         at mainapp.CTestApplication.main(CTestApplication.java:32)

    This is probably not the best forum to get an answer. Try this one instead:
    http://forum.java.sun.com/forum.jspa?forumID=13
    Its difficult to know exactly the source of your problem. If your code works for session beans and Entity beans using BMP then I can only think of the following:
    In a CMP Bean, the ejbLoad and ejbStore methods do nothing. The container performs the load and store for you. I don't know whether leaving code in these methods will cause any problems though.
    You will need to make a few changes to your ejbCreate method though. Suppose your ejbCreate method looks like this:
    public PersonKey ejbCreate(String aFirstName, String aLastName) You still need to initialise the firstName and lastName fields in the bean.
    firstName = aFirstName;
    lastName = aLastName;Normally, the ejbCreate method returns the key value for the created object. Using CMP, you must return null. The container generates the new key value and returns it to the client.
    Not sure if that will help. Post on the link above if not.
    Simon

  • Re: junit test for entity beans ... ejb 3.0

    I'm confused. I'm trying to test my entity bean.
    I have:
    - an entity bean
    - a stateless session bean for accessing the entity bean (facade)
    - an interface for accessing the the stateless bean
    And I'm trying to write a JUnit test class to test this bean. However, I am uncertain as to how to test this (I'm new to EJB 3.0, JBoss and Eclipse).
    What would the JUnit test look like? I'm confused as to whether or not I should be injecting the interface/bean/what???
    I've tried several variations. I either get "NameNotFound" - not bound exceptions or Null pointer exceptions.
    What would the @EJB syntax look like or how would I do it through the context?
    For Example:
    @EJB private TestFacade myTest; //interface to stateless bean ?
    OR
    InitialContext ctx = new InitialContext();
    TestResultFacadeBean myTest = (TestResultFacadeBean) ctx.lookup("localTest");
    I'm confused at to which method I should be using and what object I should be accessing. If I could get either one to work, I'd be happy. :)
    How do I ensure my bean is deployed to the container? What do I need to do?
    If anyone has a simple example or explanation as to which method I should use and how to use it, I'd be very grateful.
    Thanks very much,
    LisaD

    OK, you need to have several layers of testing.
    Layer 0. Test the entity beans are deployable (more on this later). Basically, you need to know that all your annotations work. Things to watch out for are multiple @Id fields in one class or @EmbeddedID or @IdClass in conjuction with @ManyToOne, @ManyToMany, @OneToMany, @OneToOne and fun with @JoinTable, @JoinColumn and @JoinColumns. Once you know how these are supposed to work with the spec, it's not too bad to write it correctly each time. But there are some gotchas that will break things later on.
    Layer 1. Do the functions in the classes that don't depend on annotations work as expected. Typically, this is just going to be the getters and setters in your entity classes. Of course JUnit best practice says we don't bother testing functions that look like:
    public T getX() {
    return this.x;
    or
    public void setX(T x) {
    this.x = x;
    as there is nothing that can go wrong with them. So in that case, your level 1 tests will just be initial values specified from constructors and verifying that the non-get/set pairs work, and that the getters you have tagged @Transient work (because you've likely put some logic in them)
    Layer 2. Test the session bean methods that don't require injection to work.
    Layer 3. Test the session bean methods that require injection (Mock Objects). Simulate the injection for yourself, injecting Mock Objects for the entity manager. Then you can confirm that the correct methods are being called in the correct sequences, etc.
    [Note this may require some skill in designing the mock.  I'm working on developing my own entitymanager mock, and if it looks usefull I'll release it to the world.
    Layer 4. Test the session bean methods that require injection (Real entity manager) (See Layer 0)
    For this you will need an out of container persistence implementation.  Currently Hibernate and Glassfish provide beta versions.  You will need a different persistence.xml file that lists all the entities.  You will have to use reflection to inject the entity manager(s) that you create from an entity manager factory unless you provide a constructor that takes an EntityManager as a parameter.  You may need to use reflection to call any @PostConstruct method if you made it private.
    Layer 5. Navigate the relationships in the objects returned from Layer 4 using a database that has been loaded with test data.
    I am currently using Layers 0, 1, 2 & 4 to test my session beans and entity beans.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Do JNDI look up for entity beans from a session bean  in different  jars

    I have a problem doing entity beans JNDI look up from a session bean which is deployed
    as a separate package (session.jar) from the entity beans (entity.jar)
    I believe if both session bean and entity beans are deployed into one jar and
    I specify ejb-local-reference-description for session bean, it should work. However,
    due to some reason, they have to be in separated packages but still in the same
    container. Then question how to do JNDI lookup given entity beans only have local
    interfaces?
    FYI.
    1 both session.jar and entity.jar are self-contained. i.e., no deployment error.
    each JNDI name can be viewed from JNDI tree
    2. weblogic-ejb-jar.xml for session.jar
    <weblogic-ejb-jar>
    <description><![CDATA[Generated by XDoclet]]></description>
    <weblogic-enterprise-bean>
    <ejb-name>PetstoreLogic</ejb-name>
    <stateless-session-descriptor>
    </stateless-session-descriptor>
    <reference-descriptor>
    </reference-descriptor>
    <jndi-name>PetstoreLogic</jndi-name>
    <local-jndi-name>PetstoreLogicLocal</local-jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    3. weblogic-ejb-jar.xml (code snip) for entity.jar
    <weblogic-enterprise-bean>
    <ejb-name>Account</ejb-name>
    <entity-descriptor>
    <persistence>
    <persistence-type>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>6.0</type-version>
    <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
    </persistence-type>
    <persistence-use>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>6.0</type-version>
    </persistence-use>
    </persistence>
    </entity-descriptor>
    <reference-descriptor>
    </reference-descriptor>
    <local-jndi-name>net.sourceforge.cpetstore/AccountLocalHome</local-jndi-name>
    </weblogic-enterprise-bean>
    4. if I do
    accountLocalHome = (AccountLocalHome) ic.lookup("net/sourceforge/cpetstore/AccountLocalHome");
    get error like:
    javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException:
    While trying to look up /app/ejb/net.sourceforge.cpetstore-entity.jar#Account/local-home
    in /app/ejb/cpetstore-ejb.jar#PetstoreLogic.; remaining name '/app/ejb/net/sourceforge/cpetstore-entity/jar#Account/local-home'
         at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:869)
         at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:150)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:338)

    In weblogic-ejb-jar.xml use jndi-name instead of local-jndi-name in reference-descriptor
    element.
    "Qiming He" <[email protected]> wrote:
    >
    I have a problem doing entity beans JNDI look up from a session bean
    which is deployed
    as a separate package (session.jar) from the entity beans (entity.jar)
    I believe if both session bean and entity beans are deployed into one
    jar and
    I specify ejb-local-reference-description for session bean, it should
    work. However,
    due to some reason, they have to be in separated packages but still in
    the same
    container. Then question how to do JNDI lookup given entity beans only
    have local
    interfaces?
    FYI.
    1 both session.jar and entity.jar are self-contained. i.e., no deployment
    error.
    each JNDI name can be viewed from JNDI tree
    2. weblogic-ejb-jar.xml for session.jar
    <weblogic-ejb-jar>
    <description><![CDATA[Generated by XDoclet]]></description>
    <weblogic-enterprise-bean>
    <ejb-name>PetstoreLogic</ejb-name>
    <stateless-session-descriptor>
    </stateless-session-descriptor>
    <reference-descriptor>
    </reference-descriptor>
    <jndi-name>PetstoreLogic</jndi-name>
    <local-jndi-name>PetstoreLogicLocal</local-jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    3. weblogic-ejb-jar.xml (code snip) for entity.jar
    <weblogic-enterprise-bean>
    <ejb-name>Account</ejb-name>
    <entity-descriptor>
    <persistence>
    <persistence-type>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>6.0</type-version>
    <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
    </persistence-type>
    <persistence-use>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>6.0</type-version>
    </persistence-use>
    </persistence>
    </entity-descriptor>
    <reference-descriptor>
    </reference-descriptor>
    <local-jndi-name>net.sourceforge.cpetstore/AccountLocalHome</local-jndi-name>
    </weblogic-enterprise-bean>
    4. if I do
    accountLocalHome = (AccountLocalHome) ic.lookup("net/sourceforge/cpetstore/AccountLocalHome");
    get error like:
    javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException:
    While trying to look up /app/ejb/net.sourceforge.cpetstore-entity.jar#Account/local-home
    in /app/ejb/cpetstore-ejb.jar#PetstoreLogic.; remaining name '/app/ejb/net/sourceforge/cpetstore-entity/jar#Account/local-home'
         at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:869)
         at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:150)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:338)

Maybe you are looking for

  • Problems setting up username & password for SQL

    Due to the outstanding advice I recieved from this excellent forum, I have managed to overcome my first problem with declaring a new Class. This leads me to request help with my next biggest problem: Setting up a user GUI that takes a "username" & "p

  • J2ME: can you clear the key pressed buffer on a cell?

    I am having trouble with keypressed. I am writing a cell phone game in MIDP 2.0. Basically its the standard GameCanvas setup, where you have a main game loop and it calls your input function. The input function then does: int keyStates = getKeyStates

  • Changing Pay Terms on Order Line Item

    Hello - When an invoice is cancelled,  SAP permits payterms to be changed on the line item of the corresponding sales order,  however, upon saving the order,  the payterms revert back to the original ones.   I am trying to re-invoice using new/change

  • Unexpected quits, missing themes, missing fonts and broken file paths

    I created a project in iDVD 5 on the Powerbook at home, and then took the drive containing the project and all related files to my dad's office to burn it on his iMac G5 (the drive in the powerbook won't burn anything - separate problem). I put all t

  • Problems with my new Video iPod

    Hi, I just got a brand new black 30GB video iPod, so far it has been great. However, I've noticed a problem with the HD. Whenever the HD is spinning up and the iPod is moved you can hear the HD clunk. It also tends to make a odd whirring noise when I