JCOM EJB method parameter

Hi,
I want to call into an EJB using JCOM and I had a look at BEA's JCOM examples.
Are there any restrictions on the parameter and result types the EJBs methods
have, or can you use any serializable java type? Because interface Account uses
only double parameters and return values. I want to return classes generated by
corba IDLJ.
Thanks,
Juergen

Juergen Weber wrote:
Hi,
I want to call into an EJB using JCOM and I had a look at BEA's JCOM examples.
Are there any restrictions on the parameter and result types the EJBs methods
have, or can you use any serializable java type? Because interface Account uses
only double parameters and return values. I want to return classes generated by
corba IDLJ.jCOM is quite restrictive for pass by value IMHO (restricted by COM
struct limitations). You can read about those restrictions here:
http://j-integra.intrinsyc.com/j-integra/doc/
If you don't want to compromise your design I would recommend using
CORBA. You can use Tuxedo C++ (or any other C++ ORB, but with Tuxedo you
get a free licence for the client I believe when you purchase WLS) and
then ATL to expose that over COM. Note that does require a reasonable
degree of skill to implement (e.g. knowledge of CORBA, ATL/Visual C++ etc.)
An alternative CORBA client that is excellent for COM interop is Borland
Janeva which I have been using quite a lot recently. Version 6 includes
a number of COM interop enhancements. It does require the .NET runtime
on the client however which might not be acceptable for your environment
of course. It is extremely easy to use however, and requires very little
knowledge beyond that which a competent J2EE developer will have.
Robert

Similar Messages

  • Using InputStream on EJB method

    Hi everyone,
    i was looking for a way to use InputStream or anything else related to the java.io package on my EJB method. This is the first time that i need to do something like that, so i made a research and i figure out that is impossible use any kind of the io package when i using EJB. Is that true?...
    if this is true, could anyone help me how i can save something on my server using EJB?
    Thanks in Advance

    hi,
    i looked in some forums, and talk with some people who use EJB for so long, and all answers took me to the conclusion that is totally not recommended using streams on ejb methods...i haven't looked on ejb specification to really see if its true...
    Besides, i tried in other way..... first i created my EJB method with a byte[] parameter, and a "service" class which convert this array to an InputStream..and record the file on server...i did a client to test and apparently works without errors, i don't receive any exceptions, so i suppose that at least this part is correct, but i having another problem....
    by the way, anyone know how can i save a certificate on a Keystore??...i'm trying that:
    keyStore = manager.getKeystore("DEFAULT");
         keyStore.load(is, password.toCharArray());     attempting that "is" is the InputStream (same of the problem above) and the second parameter is the password....this code belongs to a method on the "service class" that i mentioned before....
    but nothing happens when i run my app. anyone could help me??
    Thanks in Advance

  • EJB method parameters are sent but nulls are received

    My client calls my EJB method passing two serializable objects as parameters.
    Using print statements and a network snoop I have confirmed that:
    - the client is calling the method with valid objects
    - from examining the data it appears that the objects are being serialized and sent across the network
    - the EJB seems to receive null values.
    I have deployed the EJB to both 9iAS and a standalone instance of OC4J with exactly the same results.
    Any ideas?

    Hi Dale and Kamesh,
    No error messages? Nothing in the log files? Have you tried running OC4J in debug mode? In case you haven't already seen it, this "Technical Note" has more details.
    Pardon me if I am stating the obvious, but it seems like there is a deserialization problem. Are the client JVM and server JVM both the same version? Have you implemented custom [de]serialization for the parameter classes? Is the same version of the parameter class files located both at the client and at the server?
    Good Luck,
    Avi.

  • Bind ADF table to EJB method that takes a argument (operation)

    Hi Oracles
    I can bind a ADF table to a EJB method that takes no arguments, and then JDeveloper calls the method a accessor. I would like to bind another ADF table to another EJB method that takes a argument, but there I have some problems. First of all JDeveloper will not allow this, can I work around that? Then obviously I have to pass the argument to this EJB method some how..?
    Do you guys have any way of fixing this? Is the only way to not bind the ADF table, and do it in code in the background, and how do I do this?
    Best regards
    Søren

    Thank you!
    I found it, and if I drag it to my JSP, it gives me these options:
    - Create Methods
    - ADF Link
    - ADF Button
    - ADF Menu Item
    - ADF Toolbar Button
    - ADF Image Link
    - Create Parameters
    - ADF Parameter Form
    I have one ADF table that is bound to a data control, and based on the selection on this table, I would like to show data in another table based on a EJB method that takes a id from the selected object from the first table. Either on the same JSP or on another JSP, whatever is easiests.
    Can you help me do this? Then I hope I learn something in the process :)
    Best regards
    Søren

  • Java.rmi.RemoteException: EJB Exception: while calling an EJB method,

    Hi
    I am getting below error while calling a stateless EJB method. There is some validation checks while performing ejb's modify() method and a RuntimeException is thrown in case of validation failure.The modify() method internally calls other stateless ejb as well.
    The problem I'm facing is, instead of getting the expected RuntimeException in the Servlet, i am getting RemoteException. I am using WLS 9 MP1, all participating ejbs are stateless and i am using default transaction attributes(Supports) for these ejbs.
    The interesting part is, at the ejb layer RuntimeException is thrown as expected, but this exception changed to RemoteException at the servlet's end where i am catching the ejb call exceptions.
    I am new to WLS, please suggest/help me out of this exception.
    Any help is truly appreciated.
    java.rmi.RemoteException: EJB Exception: ; nested exception is: java.lang.RuntimeException:
         at weblogic.ejb.container.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:95)
         at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:713)
         at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:681)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvoke1(BaseEJBObject.java:447)
         at weblogic.ejb.container.internal.StatelessEJBObject.postInvoke1(StatelessEJBObject.java:72)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvokeTxRetry(BaseEJBObject.java:374)
         at com.mycomp.base.BaseController_8x2e52_EOImpl.modify(BaseController_8x2e52_EOImpl.java:149)
         at com.mycomp.webgui.servlet.FrontComponent.service(FrontComponent.java:207)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:223)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3245)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2003)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1909)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Thanks!
    Edited by: user10721298 on Feb 23, 2009 4:16 AM

    Hi,
    If i don't misunderstand, you are using the RuntimeException as an application exception, right?
    Have you annotated it or denoted it in deployment descriptor?
    Thanks,
    Amy

  • Invoking a web service - cannot resolve method parameter

    I am getting a failure trying to invoking a method called sl_Access on a web service.
    (Same code worked in Workshop 7.1, but fails in Workshop 8.0. The WDSL has not
    changed.) WLW is not able to revolve a method parameter called piCustNo. The service
    call works in WLW 7.1, but not 8.0.
    Any insight on how to fix this problem?
    The service call
    private AnonType_sl_AccessResponse response = null;
    nlastid = response.piLastId;
    the service definition from wsdlControl.jcx ----
    * @jc:protocol form-post="false" form-get="false" http-soap="true"
    public AnonType_sl_AccessResponse sl_Access (int piCustno);
    console error output -----
    Submitted at Wednesday, October 8, 2003 2:15:22 PM EDT
    Exception in sl_Access
    com.bea.control.ServiceControlException:
    SOAP-ENV:Client
    An error was detected in the Web Service request. (10894)
    Cannot resolve method sl_Access parameter ns:piCustno (10933)e91a6247e9b693c3:-1b6d127:f811fed2db:-8000#17
    at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:846)
    at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:359)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:420)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:393)
    at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:387)
    at $Proxy11.sl_Access(Unknown Source)
    at com.ovid.service.AccessService.getRepl(AccessService.java:93)
    at com.ovid.service.AccessService.processBatch(AccessService.java:71)
    at Controller.runAccess(Controller.jws:399)

    see:
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.developer.interest.workshop&item=1730
    Joe Smith wrote:
    >
    I am getting a failure trying to invoking a method called sl_Access on a web service.
    (Same code worked in Workshop 7.1, but fails in Workshop 8.0. The WDSL has not
    changed.) WLW is not able to revolve a method parameter called piCustNo. The service
    call works in WLW 7.1, but not 8.0.
    Any insight on how to fix this problem?
    The service call
    private AnonType_sl_AccessResponse response = null;
    nlastid = response.piLastId;
    the service definition from wsdlControl.jcx ----
    * @jc:protocol form-post="false" form-get="false" http-soap="true"
    public AnonType_sl_AccessResponse sl_Access (int piCustno);
    console error output -----
    Submitted at Wednesday, October 8, 2003 2:15:22 PM EDT
    Exception in sl_Access
    com.bea.control.ServiceControlException:
    SOAP-ENV:Client
    An error was detected in the Web Service request. (10894)
    Cannot resolve method sl_Access parameter ns:piCustno (10933)e91a6247e9b693c3:-1b6d127:f811fed2db:-8000#17
    at com.bea.wlw.runtime.core.control.ServiceControlImpl.invoke(ServiceControlImpl.jcs:846)
    at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:359)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:420)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:393)
    at com.bea.wlw.runtime.jcs.container.JcsProxy.invoke(JcsProxy.java:387)
    at $Proxy11.sl_Access(Unknown Source)
    at com.ovid.service.AccessService.getRepl(AccessService.java:93)
    at com.ovid.service.AccessService.processBatch(AccessService.java:71)
    at Controller.runAccess(Controller.jws:399)

  • Can't fill ByteArray in EJB-Method with generated Model-Class from WD-Model

    Hello everybody,
    i try to call an ejb-method with data from an FileUpload-UI-Element in WD. The EJB-Method is receiving the byte-data to create a document in KM via a Web-Service.
    The ebj-methid has the following signature:
    public FObject putFileDataSimple (byte [] btContent, String fullFileName, String username, String password)
    After importing the Model and creating a context node i have the following structure:
    Request_X_putFileDataSimple
    +---btContent (Node)
          +-- item
    + fullFileName
    + username
    + password
    btContent is of the generated Type Byte_Item, which is itself a generated Model-Class of modelClassType ARRAY
    item is of Type byte
    But i simply have problems to fill the context node (or the binded model-object). i tried different ways and looked at thread [https://www.sdn.sap.com/irj/scn/thread?messageID=1954223] but i cant get it work.
    So my Method in WD looks like this to fill the structure and start the ejb-method:
    public boolean putKMDataSimple( com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource fin )  {
    try
      wdContext.currentRequest_X_putFileDataSimpleElement().setFullFileName("abc");
      wdContext.currentRequest_X_putFileDataSimpleElement().setUsername("def");
      wdContext.currentRequest_X_putFileDataSimpleElement().setPassword("xxx");
      byte[] buffer = new byte[1];
      InputStream in = fin.read(false);
      int i = 1;
      int j = 0;
      while (i!=-1)
         i = in.read(buffer);
         if (i!=-1)
           Byte_Item bi = new Byte_Item(mAlf);     // mAlf ist global defined Model-Class-Instance
           bi.setItem(buffer[0]);
            wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().addBtContent(bi);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    Doing this results in Error-Messages like:
    Model-Object is not a complex type for every byte added this way.
    And finally an IllegalArgumentException at java.lang.reflect.Array.set(Native Method)
    The second way i tried is:
    public boolean putKMDataSimple( com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource fin )  {
    try
      wdContext.currentRequest_X_putFileDataSimpleElement().setFullFileName("abc");
      wdContext.currentRequest_X_putFileDataSimpleElement().setUsername("def");
      wdContext.currentRequest_X_putFileDataSimpleElement().setPassword("xxx");
      byte[] buffer = new byte[1];
      ArrayList<Byte> btlist = new ArrayList<Byte>();
      InputStream in = fin.read(false);
      int i = 1;
      int j = 0;
      while (i!=-1)
         i = in.read(buffer);
         if (i!=-1)
              btList.add(buffer[0]);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().setBtContent(btList);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    Trying so results in:
    java.lang.ClassCastException: class java.lang.Byte:null incompatible with interface com.sap.tc.cmi.model.ICMIModelClass:library:com.sap.tc.cmi(at-sign)[email protected]@alive
    whenn calling the setBtContent Method
    I don't what to do now to fill the context/model-object the right way.
    Any helpfull hints are very welcome
    Edited by: Matthias Hayk on Dec 1, 2008 5:51 PM
    Edited by: Matthias Hayk on Dec 2, 2008 10:56 AM

    Ok Vesselin and thanx for your idea,
    so i adapted the source in the way you told like the following:
                     ArrayList<Byte_Item> btlist = new ArrayList<Byte_Item>();
                     byte[] buffer = new byte[1];
                     InputStream in = fin.read(false);
                     int i = 1;
                     int j = 0;
                     while (i!=-1)
                          i = in.read(buffer);
                          if (i!=-1)
                               // Byte gelesen
                               Byte_Item bi = new Byte_Item(mAlf);
                               bi.setItem(buffer[0]);
                               btlist.add(bi);
                               j++;
                     wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().setBtContent(btlist);     
                     wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    This results also in the following Exception when exceuting the WS-proxy:
    execute
    [EXCEPTION]
    java.lang.IllegalArgumentException
    at java.lang.reflect.Array.set(Native Method)
    at com.sap.tc.webdynpro.model.ejb.model.EJBGenericModelClassExecutable.getInputParameters(EJBGenericModelClassExecutable.java:215)
    at com.sap.tc.webdynpro.model.ejb.model.EJBGenericModelClassExecutable.execute(EJBGenericModelClassExecutable.java:112)

  • Returning more than one value/object from an EJB method

    Hi,
    I have the follong method in the remote interface of my EJB:
    void createSomeObject( MyObject obj1, List returnList1, Map returnMap1);
    Since i want to return a List (returnList1) and a Map(returnMap1) from my EJB method "createSomeObjects", i am passing these as parameters thinking they will be passed by reference and the client(servlet) gets the changes the EJB made to these objects.
    But it doesn't seem to be working, the EJB is filling the List and Map objects and the servlet doesn't get it (pass by value problem).
    My understading is that, all parameters to an EJBs are passed by value(because they are remote calls, the RMI thing), let me know if this right.
    Is there any workaround apart from the following alternative?
    Alternatives:
    1. Wrap "List list1" and "Map map1" in another model and return this instead of passing them as parameters.
    Thanks
    Vasu

    My understading is that, all parameters to an EJBs
    are passed by value(because they are remote calls,
    the RMI thing), let me know if this right.Yes, that is correct - which you should know from your introduction to J2EE reading.
    Is there any workaround apart from the following
    alternative?
    Alternatives:
    1. Wrap "List list1" and "Map map1" in another model
    and return this instead of passing them as
    parameters.No.

  • Field-Symbols as Method Parameter

    Hi all,
    is there a way to create a field symbol within a method and export this field-symbol directly as a method parameter?
    The problem is that we can't pass a field symbol as method parameter unless it's assigned, but we would like to assign the field symbol within a method and give the result back to the calling program.
    We have managed to create a field symbol within the method and give back the result as a reference (we used the type ANY).
    We would like to pass the result field-symbol directly as a Method parameter.
    Any ideas?
    Best regards Dominik

    Hi all,
    thanks for you help. I managed to do the method calls with reference parameters but I'd like to do it with fieldsymbols instead.
    Your suggentions for field-symbold worked, but I could use them only with primitive datatypes.
    In my requirements the table must be created within the method, so the caller doesn't know the tablestructure.
    If a dummy table is assigned to the field-symbol before the call, the error "Two internal tables are neither compatible nor convertible" is produced.
    Is there a solution?
    Thanks in advance
    Dominik
    class ZZX0_CL_TEST definition
      public
      final
      create public .
    public section.
      class-methods FIELD_SYMBOLS_TAB_TEST
        changing
          !FS type ANY .
    METHOD FIELD_SYMBOLS_TAB_TEST .
      DATA: it_t000 TYPE TABLE OF t000.
      FIELD-SYMBOLS <field_symbol> TYPE ANY TABLE.
      ASSIGN it_t000 TO <field_symbol>.
      fs = <field_symbol>.
      EXIT.
    ENDMETHOD.
    REPORT zzx0_mini.
    DATA: it_mara  TYPE TABLE OF mara.
    START-OF-SELECTION.
    * Tabellen test
      FIELD-SYMBOLS: <fs> TYPE STANDARD TABLE.
      ASSIGN it_mara TO <fs>.
    *  ASSIGN it_t000 TO <fs>.
      CALL METHOD zzx0_cl_test=>field_symbols_tab_test
        CHANGING
          fs = <fs>.
      EXIT.

  • Transaction Isolation Level for EJB methods

    L.S.
    I just found out the in OC4J one can not set the transaction isolation level on ejb methods. Moreover one needs to revert to bean managed transaction (manual coding of the ALL transaction logic) to set the isolation level.
    On entity beans one can only set the isolation level for the whole bean (not on individual methods), and in session beans there is no way at all to set the isolation level.
    This is on shear contract to all other application servers I used before (there one can declaratively set the isolation level for a ejb method, both in session and in entitybean deployment descriptors)
    Is it foreseen in a future release to include such a valuable feature will be provided by oc4j?
    Note that I was VERY surprised that OC4J could not handle this (I checked the j2ee spec, but admittedly the spec is a little vague about this support and makes it vendor dependent. the j2ee spec does not mandate this, except for CMP entity beans, but includes some suggestions on this ability. But most other application servers implemented the ability)
    Regadrs,
    Erik

    Hello Erik --
    I think we met in Perth recently?
    Anyway, your information is correct.
    We can set the transaction isolation level for each entity bean, at the bean level. We don't have for the specification of method level isolation settings -- I'd be interested to hear how you would like/do use this. What behaviour do you expect to see when a transaction is started that spans multiple methods on a bean with different declared isolation levels.
    For session beans, we do not currently have the ability to declaratively specify the isolation level to use for the bean. I know this is not in the forthcoming 904 release, and will to check what is beyond that.
    As you point out, this can be done programatically using the Connection.setIsolationLevel() method on any connections you are using from within the session bean.
    I'd would like to log an enhancement request for you for this functionality. Can you send me an email at [email protected] and we'll take it offline.
    -steve-

  • Logging Denied EJB Method Invocation

    In Weblogic Application Server, v 6.1, I'm experimenting around with
    the AuditProvider. Several of my EJB's have method-permission
    declarations that limit who is able to execute those methods. When
    WLS correctly denies an attempt to invoke a method for which its
    method-permission does not allow the user permission, the
    AuditProvider method (checkPermission) does not seem to get called.
    Should checkPermission() be called if a permission check against an
    EJB method-permission fails? If not, is there somewhere else I can
    capture and audit disallowed attempts to execute these methods?
    Thanks.
    -- Edgar

    Thanks, Tom.
    We are on SP3. I'll double-check my findings, put together a test
    case I can send with it, and open a support case.
    Thanks again.
    -- Edgar
    "Tom Hegadorn" <[email protected]> wrote in message news:<[email protected]>...
    Hi,
    I'm not sure but it sounds like it may be a bug. Please make
    sure you are on the latest service pack (SP3 at time of this
    writing). If so, and you still see the behavior I would recommend
    opening a case with BEA Support. Please provide a detailed
    test case so that a support engineer can replicate the behavior.
    Thanks.
    Regards,
    Tom Hegadorn
    Developer Relations Engineer
    BEA Support
    [email protected] (Edgar) wrote:
    In Weblogic Application Server, v 6.1, I'm experimenting around with
    the AuditProvider. Several of my EJB's have method-permission
    declarations that limit who is able to execute those methods. When
    WLS correctly denies an attempt to invoke a method for which its
    method-permission does not allow the user permission, the
    AuditProvider method (checkPermission) does not seem to get called.
    Should checkPermission() be called if a permission check against an
    EJB method-permission fails? If not, is there somewhere else I can
    capture and audit disallowed attempts to execute these methods?
    Thanks.
    -- Edgar

  • Member variable verses method parameter to pass information

    Hi all,
    Is the a performance penalty in using method parameter, such as a String, to pass information into multiple methods( method1(String X), method2(String X), etc ) in a class verses using a class member variable to pass the information to the methods?
    Thanks.

    Never, ever, ever make a decision as to what should be parameter and what should be field based on this kind issue. If the value is reasoably part of the state of the object it should stored (or referenced by) a field. Otherwise it should not and so your left with it being a parameter or an atribute of some other object.
    There is little if any performance cost in passing a parameter (on the order of 10's to 100's of nanoseconds on modern computers and JVM's. Optimizing in this area will only noticeably impact performance of such calls if it needs to get performed 100's of thousands or millions of times per second. That generally excludes everything any of us is likely to write.
    Chuck

  • Urgent - calling EJB methods from thread

    Dear all
    I am aware of EJB spec that does not permit developer managed threads within EJB components. However, I need to call EJB methods from my own thread. Hence, it there any way to to call EJB methods from developer managed thread ?? If yes, please advice me, thanks in advance and your help will be appriciated.
    Hava a nice day

    You can call EJB's from your threads. Your thread will act as the client and the call will to EJB will be same as any other client invoking EJB's. Hope I understand your question !.

  • Can an EJB method return processing results to its calling program?

    Hi there,
    I have an EJB method which does JDBC connection to a UDB. I want the ResultSet to be returned to JSP so I can format them in the page itself. I got an ClassCastException at the return statement. Could anybody point out what I might be missing?
    Thanks a lot.
    Andy

    Here is the code related:
              try
                   Context jndi = AuditPublicService.getContext();
                   Object obj = jndi.lookup(AuditInterface.ALIAS);
                   AuditHome auditHome =
                        (AuditHome) PortableRemoteObject.narrow(obj, AuditHome.class);
                   Audit audit = auditHome.create();
                        this.rs = (ResultSet) audit.read();
              catch (Throwable t)
                   System.out.println("Test.read():failed." + t.toString());
                   t.printStackTrace();
    and this is what I got:
    Test.read():failed.java.lang.ClassCastException
    java.lang.ClassCastException
    P.S. When I track down to the return statement(return rs) in the audit.read(), I can see that the rs is exactly what I want, but failed when the EJB stub tries to cast it to Serializable. I tried to implements java.io.Serializable in both the calling class and the EJB. it didn't work.

  • Stateless EJB 3: update / query on same ejb-method get wrong results

    I have a JavaEE application using EJB3 Stateless and DAOs with JDBC statements, simple transfer objects for data.
    The EJB business method update some questionnaire structure, after that query on database for new questionnaire (need for get autogenerated ID's on subelements: questions, sections, ...), the ejb-method code look like:
    public Questionnaire modifyQuestionnaire(Questionnaire questionnaire) {
       QuestionnaireDAO dao = getQuestionnaireDAO();        
        // Update questionnaire info
       dao.modifyQuestionnaire(questionnaire);
       // Get new info
       Questionnaire newQuestionnaire = dao.getQuestionnaireById(questionnaire.getId());
       return newQuestionnaire;
    }The problem is: when invoke "getQuestionnaireById" method on DAO at this time, I get old information ... seems as if UPDATE operations executes on DAO not has been flushed.
    After EJB method finish, the information is up to date on physical database, and after that I query the questionnaire using the same DAO "getQuestionnaireById" method, and all is up to date ! ...
    When I'm wrong?, I'm using default transaction (required) on ejb, I get the JDBC connection from a DataSource using JNDI lookup to a Container managed connection pool, I close all connection and JDBC resources ... mmm I'm using "executeBatch" for updates/inserts.
    My system:
    AppServer: SJSAS PE 9
    Database: Postgresql 8.1
    JDBC Driver: 8.2dev Build 503
    O.S.: Linux Ubuntu Dapper Drake
    Thanks any help ! .. please.
    null

    There seem a Postgresql JDBC driver problem, I change datasourceclassname from
    org.postgresql.ds.PGSimpleDataSource to org.postgresql.xa.PGXADataSource (of course, resource type: javax.sql.XADataSource) and work fine.

Maybe you are looking for