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.

Similar Messages

  • 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.

  • 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

  • Simple query with like return wrong result

    Hi,
    I run simple query with like.
    If I use parameter I get wrong results.
    If I use query without parameter results are ok.
    My script:
    ALTER SESSION SET NLS_SORT=BINARY_CI;
    ALTER SESSION SET NLS_COMP=LINGUISTIC;
    -- drop table abcd;
    create table abcd (col1 varchar2(10));
    INSERT INTO ABCD VALUES ('122222');
    insert into abcd values ('111222');
    SELECT * FROM ABCD WHERE COL1 LIKE :1; -- wrong result with value 12%
    COL1
    122222
    *111222*
    select * from abcd where col1 like '12%'; -- result ok
    COL1
    122222
    I use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    and query run in Oracle SQL Developer 3.1.07.

    Hi,
    welcome to the forum.
    When you put some code please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    You should specify exactly how you run your code.
    If I run this statement in SQL Plus:SQL> ALTER SESSION SET NLS_SORT=BINARY_CI;
    Session altered.
    SQL> ALTER SESSION SET NLS_COMP=LINGUISTIC;
    Session altered.
    SQL>
    SQL> -- drop table abcd;
    SQL> create table abcd (col1 varchar2(10));
    Table created.
    SQL>
    SQL> INSERT INTO ABCD VALUES ('122222');
    1 row created.
    SQL> insert into abcd values ('111222');
    1 row created.
    SQL>
    SQL> SELECT * FROM ABCD WHERE COL1 LIKE :1;
    SP2-0552: Bind variable "1" not declared.
    SQL>
    I got this error. So I wonder how you set value 12%
    Please specify exactly how you run your test as we cannot reproduce your problem.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Can I Use Singletone  Pattren for DAO in Stateless EJB?

    Hi friends,
    I have a design in which i am creating an Business Layer using EJB (Stateless). In my case i have only read only to DataBase and at one case where i will be updating the database. But my application will be accessed by many concurrent users.
    My problem is if i create a DAO with singleton pattren then it will be returning the same instance to all the person who access the DB. So if one person is reading the database and at the same moment one more person request for update since the DAO is singleton object will there be any conflict?
    Reply soon

    Hi Martin.S
    Thanks for your suggestion.
    U Asked
    You need to think about why have you have made your DAO a Singleton. You need to ask yourself, SHOULD it be a Singleton? It may be valid decision but I find that doubtful. Singleton DAO's suit only limited set of circumstances. Why i decided to use singleton pattren was :
    Since i am using session bean and if i won't use Singleton pattren and
    If my app was used by say 1000 users
    Then 1000 Dao instaces whould be created!
    The App Server will have 1000 refrences which may be a performance issue and may slow down the server due to more usage of server resource. So i need to know weather is it a good idea to use the Singleton pattren for DAO when using SessionBeans?
    And one more doubt I have Martin
    If i use One Dao Class Per One Table Then How about the factories if i use singleton? Need to create so many factories as DAO's? *reply
    Also i think if i use Single DAO per Table and if i have say 1 user accessing the DAO and he is in the Middle of his execution and user 2 requests for the same DAO once again the situation is worse! Am i right?
    So I think Singleton pattren comes into handy only when one person is accessing the DAO at a time. After he completes then only we can give access to some one else.
    And also while Using EJB's Using syncronized DAO is not preffered since EJB's are for multiple access
    So do you have any solution for the same? Currently I am using ordinary DAO and creating multiple instances in the Session Bean.
    Is there any way to Use SingleTon Pattren inside SessionBean?
    Reply
    A Singleton DAO would be valid choice when you are doing performance/throughput optimisation for read only access to dataset which you have cached for speed, but need to ensure only one copy exists for memory efficiency.One more query martin,
    How can we use it for read only access to a data set?
    For example i have a DAO which queries and returns some result sets based on some input value given by the user
    Now take a senario1: User1 supplys some input value and executes method1() and he is in the middle.
    User2 comes in and acess the same method1() with different input value
    Since it is a SingleTon Pattren The User2 will get same refrence
    So user1 will get the result set that is having the input parameters of user2. Right?????????
    So my inference is we cannot use singelton pattren for concurrent acess of the DAO.What do you say
    Please Reply Martin

  • Stateless EJB blocks

    Hi.
    I've an stateless ejb that calls another stateless ejb. The two EJB's use Entity Beans though the database schema is different.
    Here's the snippet of code:
        public Libro insertarLibro( String codigo,
                                    Long ejemplar,
                                    Calendar dataPublicacion,
                                    String isdn,
                                    String titulo,
                                    String cifEditorial,
                                    String nifAutor) throws SGLException,
                                                           StockException,
                                                           Exception {
            ServiceFacade01EJBClient externalSystemProxy = new ServiceFacade01EJBClient();                                                      
            StockFacadeEJB stockFacade = SglServiceLocator.getInstance().getStockFacadeEjb();
            stockFacade.addBook(getLibroDto(libro));
            em.persist(libro);
            em.getTransaction().commit();
            return libro;
        }The problem is that the blocking is random. Sometimes it blocks in this line:
    stockFacade.addBook(getLibroDto(libro));
    Other times it returns normally but then blocks (I use JDeveloper).
    The odd thing is that sometimes the data is written in the database. Other times not.
    On the called ejb the data is always written. But on the caller the data is not written.
    I'm using same database instance but different users/schemas for the two stateless EJB's.

    Or is it becoz the two methods that it objected to were returning user-defined objects and not String, void, Integer ... that a web service can recognize !
    But still ... why cannot it just ignore the methods that are not exposed ?
    Can someone throw some light on this.
    Thanks,
    Krishna

  • Transaction problems in Stateless EJB

    I have problems as follows. my client is a servlet which call method B in stateless ejb, In side of method B, there is a loop from which antoher method C in this same ejb is called repeatedly. I want each call of method C being a separate transaction. I can not make this work. the final result will always be one transaction from for loop. I set the transaction attribute as Requires for method B, and Requires New for method C. Please offer some help.
    Thanks.
    void ejbMethodB(){
    where(mycondition)
    ejbMethodC()
    I like to make each call of ejbMethodC be a standalone transaction instaed of the running results from the whole loop being a transaction

    First of all, thank you so much for your time.
    I also doubt the problem is Resin. But "Required" attribut works fine. The following is the coding:
    EJB implementation:
    //mehtodB
    public RequestResult getDailyCreateUpdateInfo(Request request)
    throws RemoteException, ProcessException
    boolean testFlag = false;
    List resultList = null;
    ClaimsDAO dao = null;
    Map mapRequestData = getRequestData(request);
    int num = 0;
    InterfacePushProcess push_process = (InterfacePushProcessRemote)(mySessionCtx.getEJBLocalObject());
    try {
    //Call DAO and get Student, ExchangeVisitor and their dependent information
    dao = (ClaimsDAO) getEntityObject(ClaimsDAO.class.getName());
    dataPushBO = new ClaimsDataImpl(mapRequestData);
    //get the list of categories for DOS or US-VISIT
    interdataList = dataPushBO.createCategoryList();
    Iterator iterator = interdataList.iterator();
    System.out.println("before invokeTransacprocess. ");
    //testing
    this.invokeTransacProcess();
    //process all the categories for DOS or US-VISIT
    while(iterator.hasNext())
    interconfigData = (InterfaceDataConfig) iterator.next();
    processOneCategory(mapRequestData, interconfigData, dao);
    } catch (Exception e) {
    mySessionCtx.setRollbackOnly();
    log.logp(Level.SEVERE, classname, "getDailyCreateUpdateInfo", e.getMessage());
    Object[] args = createExceptionArgs();
    args[0] = request.getName();
    throw new ProcessException(IMessage.ENTITY_POPULATION_FAILED, args, e);
    return new RequestResult(request, resultList);
    //mehtodC
    public void processOneCategory(Map reqmap, InterfaceDataConfig interconfigData, ClaimsDAO dao)
    throws ProcessException
    List pageList = null;
    String fileType = interconfigData.getGroupName(); //student, dep etc
    String countKey = interconfigData.getCountKey();
    String logKey = interconfigData.getIDKey();
    UserTransaction trans = null;
    int count = 0;
    boolean process = false;
    String groupname = interconfigData.getGroupName();
    log.logp(Level.INFO, classname, "processOneCategory() ", "group name = " + groupname);
    try
    Context ct = new InitialContext();
    trans = (UserTransaction) ct.lookup("java:comp/UserTransaction");
    trans.begin();
    String startTime = convert.getTimestamp();
    log.logp( Level.INFO, classname, "processOneCategory() ", "processing start time: "+startTime);
    pageList = processOnePage(interconfigData, dao);
    if (pageList.isEmpty())
    log.info("There are no records which need be processed.");
    else
    do
    try
    this.displayResult(pageList);
    process = pageOutputProcessor(reqmap, interconfigData, pageList);
    pageList.clear();
    pageList = this.processOnePage(interconfigData, dao);
    } catch (Exception ex) {
    mySessionCtx.setRollbackOnly();
    String msg = "Error while processing one page : " + ex.getMessage();
    log.logp(Level.SEVERE, classname, "processOneCategory() ", msg);
    throw new ProcessException(msg);
    } while (!pageList.isEmpty());
    //testing separate transaction
    if(groupname.equalsIgnoreCase("STUDENT"))
    trans.commit();
    else
    trans.rollback();
    } catch (Exception t) {
    mySessionCtx.setRollbackOnly();
    String m = "Error when processing results from ClaimsDAO's : " + t.getMessage();
    log.logp(Level.SEVERE, classname, "processOneCategory() ", m);
    throw new ProcessException(m);
    } finally {
    I put both methods: getDailyCreateUpdateInfo and processOneCategory in remote interface so I can use your suggested method to reference the EJB instance.
    Servlet Client call "getDailyCreateUpdateInfo" method (the transaction attribute is Required) in which call processOneCategory(,,) method (transaction attribute is RequiresNew).
    I put some testing code to see if I can achieve the separate transaction in each call of mehtod processOneCategory(,,) , it does not work. If I use Bean Managed Transaction, it works right away. My app. server is Resin 2.1.4.
    Again, Thank you.
    Mark

  • Stateless EJB 3.0 to webservice

    Hello,
    I'm using EJB 3.0 deployed on weblogic server 10. I can deploy Stateless EJB without any problem.
    If I add a @WebService tag above my stateless bean, my deployment fails with the following error:
    Exception activating module: EJBModule(EfanetTA_EJB.jar) Unable to deploy EJB: ProfilesFacade from EfanetTA_EJB.jar: Unable to deploy EJB: EfanetTA_EJB.jar from EfanetTA_EJB.jar: [HTTP:101216]Servlet: "WSEE_SERVLET" failed to preload on startup in Web application: "/BusinessManager". class: lu.efa.ejb.jaxws.FindProfilesById could not be found at com.sun.xml.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:272) at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:566) at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:513) at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:358) at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:245) at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:229) at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:161) at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:291) at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:315) at weblogic.wsee.jaxws.JAXWSServlet.registerEndpoint(JAXWSServlet.java:125) at weblogic.wsee.jaxws.JAXWSServlet.init(JAXWSServlet.java:64) at javax.servlet.GenericServlet.init(GenericServlet.java:241) at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:282) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:63) at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58) at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:504) at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1830) at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1807) at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1727) at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2890) at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:948) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:353) at weblogic.wsee.deploy.WseeWebappModule.activate(WseeWebappModule.java:139) at weblogic.wsee.deploy.WSEEEjbModule.activate(WSEEEjbModule.java:371) at weblogic.wsee.deploy.WsEJBDeployListener.activate(WsEJBDeployListener.java:52) at weblogic.ejb.container.deployer.EJBDeployer.activate(EJBDeployer.java:1414) at weblogic.ejb.container.deployer.EJBModule.activate(EJBModule.java:423) at weblogic.application.internal.flow.ModuleListenerInvoker.activate(ModuleListenerInvoker.java:107) at weblogic.application.internal.flow.DeploymentCallbackFlow$2.next(DeploymentCallbackFlow.java:381) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26) at weblogic.application.internal.flow.DeploymentCallbackFlow.activate(DeploymentCallbackFlow.java:71) at weblogic.application.internal.flow.DeploymentCallbackFlow.activate(DeploymentCallbackFlow.java:63) at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26) at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212) at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154) at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:566) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:136) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:104) at weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:139) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:320) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:816) at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1223) at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:434) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:161) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:67) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200) at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
    Thank's for your help.
    Thomas

    I am facing a new problem, i tried to create the folowing build script:
    <project default="build_artefacts">
         <taskdef name="apt" classname="com.sun.tools.ws.ant.Apt">
              <classpath refid="jaxws.classpath" />
         </taskdef>
         <target name="compile-server">
              <echo message="Compiling server classes" />
              <javac destdir="target/classes" includes="**/com/**">
                   <src path="com/b2winc/controlpanel/business/facade/customer" />
                   <classpath refid="project.classpath" />
              </javac>
         </target>
         <target name="apt" depends="compile-server">
              <apt destdir="${build}" sourcedestdir="${generated}" sourcepath="${src}">
                   <classpath refid="jaxws.classpath" />
                   <source dir="${src}">
                        <include name="**com/b2winc/controlpanel/business/*.java" />
                   </source>
              </apt>
         </target>
         <target name="build_artefacts" depends="apt">
              <echo message="${src}"></echo>
              <taskdef name="antwsgen" classname="com.sun.tools.ws.ant.WsGen"
                   classpath="${src}jaxws/lib/jaxws-tools.jar" />
              <antwsgen
                   sei="CustomerFacade" verbose="true"
                   destdir="target/classes" sourcedestdir="target/temp" >
                   <classpath path="jaxws.classpath"/>
              </antwsgen>
         </target>
         <path id="jaxws.classpath">
              <pathelement path="jaxws-ri-121/lib/jaxws-tools.jar" />
              <pathelement path="jaxws-ri-121/lib/jaxb-api.jar" />
              <pathelement path="jaxws-ri-121/lib/jaxb-impl.jar" />
              <pathelement path="jaxws-ri-121/lib/jaxws-api.jar" />
         </path>
    </project>     I used this guideline: http://today.java.net/pub/a/today/2006/06/13/web-services-with-jax-ws-2.0.html
    And i get the following error:
          [apt] An exception has occurred in apt (1.5.0_11). Please file a bug at th
    e Java Developer Connection (http://java.sun.com/webapps/bugreport)  after check
    ing the Bug Parade for duplicates. Include your program and the following diagno
    stic in your report.  Thank you.
          [apt] java.lang.NoClassDefFoundError: com/sun/mirror/apt/AnnotationProcessorFactoryThe strange thing, that this class belongs to the tools.jar inside my JDK 5.
    Thanks
    Carlos

  • HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean

    HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean
    by Steve Muench
    Overview
    BC4J provides automatic facilities for deploying any application module as a stateful EJB session bean. If you want to leverage the features of your BC4J application module from a stateless EJB session bean, it's not automatic but it is straightforward to implement. This howto article explains the details.
    For our example, we will create a stateless EJB session bean that uses a container-managed transaction. To keep things simple, let's assume the session bean has a single public method on its remote interface named createDepartment() with the following signature:
    public void createDepartment(int id, String name, String loc) throws AppException
    AppException is an example of an application-specific exception that our method will throw if any problems arise during its execution.The goal of this article is to illustrate how to use the BC4J application module named com.example.hr.HRApp as part of the implementation of this createDepartment method on our stateless enterprise bean. Let's assume that the HRApp application module has a view object member named Departments, based on the com.example.hr.DeptView view object, based on the familiar DEPT table and related to the com.example.hr.Dept entity object so our view can be updateable.
    Creating the Stateless Session Bean
    We can start by using the JDeveloper Enterprise Bean wizard to create a new stateless session bean called StatelessSampleEJB implemented by:[list][*]com.example.StatelessSampleEJBBean (Bean class)[*]com.example.StatelessSampleEJBHome (Home interface)[*]com.example.StatelessSampleEJB (Remote interface)[list]
    We then use the EJB Class Editor to add the createDepartment method to the remote interface of StatelessSampleEJB with the signature above. We edit the remote interface to make sure that it also reflects that the createDepartment method thows the AppException like this:
    package com.example;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface StatelessSampleEJB extends EJBObject {
      void createDepartment(int id, String name, String loc)
      throws RemoteException,AppException;
    }Before we start adding BC4J into the picture for our implementation, our StatelessSampleEJBBean class looks like this:
    package com.example;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class StatelessSampleEJBBean implements SessionBean {
      public void ejbCreate(){}
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){
      public void createDepartment(int id, String name, String loc) 
      throws AppException {
        // TODO: Implement method here
    }We can double-click on the ejb-jar.xml file in our project to see the XML deployment descriptor for the bean we just created:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
    </ejb-jar>We need to add the extra <assembly-descriptor> section in this file to indicate that the createDepartment method will require a transaction. After this edit, the ejb-jar.xml file looks like this:
    <ejb-jar>
       <enterprise-beans>
          <session>
             <description>Session Bean ( Stateless )</description>
             <display-name>StatelessSampleEJB</display-name>
             <ejb-name>StatelessSampleEJB</ejb-name>
             <home>com.example.StatelessSampleEJBHome</home>
             <remote>com.example.StatelessSampleEJB</remote>
             <ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
          </session>
       </enterprise-beans>
       <assembly-descriptor>
          <container-transaction>
             <method>
                <ejb-name>StatelessSampleEJB</ejb-name>
                <method-name>createDepartment</method-name>
                <method-params>
                   <method-param>int</method-param>
                   <method-param>java.lang.String</method-param>
                   <method-param>java.lang.String</method-param>
                </method-params>
             </method>
             <trans-attribute>Required</trans-attribute>
          </container-transaction>
       </assembly-descriptor>
    </ejb-jar>
    Aggregating a BC4J Application Module
    With the EJB aspects of our bean setup, we can proceed to implementing the BC4J application module aggregation.
    The first thing we do is add private variables to hold the EJB SessionContext and the instance of the aggregated BC4J ApplicationModule, like this:
    // Place to hold onto the aggregated appmodule instance
    transient private ApplicationModule _am  = null;
    // Remember the SessionContext that the EJB container provides us
    private           SessionContext    _ctx = null;and we modify the default, empty implementation of the setSessionContext() method to remember the session context like this:
    public void setSessionContext(SessionContext ctx){ _ctx = ctx; }We add additional constants that hold the names of the J2EE datasource that we want BC4J to use, as well as the fully-qualified name of the BC4J application module that we'll be aggregating:
    // JNDI resource name for the J2EE datasource to use
    private static final String DATASOURCE = "jdbc/OracleCoreDS";
    // Fully-qualified BC4J application module name to aggregate
    private static final String APPMODNAME = "com.example.hr.HRApp";We expand the now-empty ejbCreate() and ejbRemove() methods to create and destory the aggregated instance of the BC4J application module that we'll use for the lifetime of the stateless session bean. When we're done, ejbCreate() it looks like this:
    public void ejbCreate() throws CreateException {
      try {
        // Setup a hashtable of environment parameters for JNDI initial context
        Hashtable env = new Hashtable();
        env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
        // NOTE: we want to use the BC4J app module in local mode as a simple Java class!
        env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
        env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
        // Create an initial context, using this hashtable of environment params
        InitialContext ic = new InitialContext(env);
        // Lookup a home interface for the application module
        ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
        // Using the home, create the instance of the appmodule we'll use
        _am = home.create();
        // Register the BC4J factory to handle EJB container-managed transactions
        registerContainerManagedTransactionHandlerFactory();
      catch(Exception ex) {
         ex.printStackTrace();
        throw new CreateException(ex.getMessage());
    }and ejbRemove() looks like this:
    public void ejbRemove() {
      try {
        // Cleanup any appmodule resources before getting shutdown
        _am.remove();
      catch(JboException ex) { /* Ignore */ }
    }The helper method named reigsterContainerManagedTransactionHandlerFactory() looks like this:
    private void registerContainerManagedTransactionHandlerFactory() {
      SessionImpl session = (SessionImpl)_am.getSession();
      session.setTransactionHandlerFactory(
        new TransactionHandlerFactory() {
          public TransactionHandler  createTransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
          public JTATransactionHandler createJTATransactionHandler() {
            return new ContainerManagedTxnHandlerImpl();
    }The last detail is to use the BC4J appmodule to implement the createDepartment() method. It ends up looking like this:
    public void createDepartment(int id, String name, String loc)
    throws AppException {
      try {
        // Connect the AM to the datasource we want to use for the duration
        // of this single method call.
        _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
        // Use the "Departments" view object member of this AM
        ViewObject departments = _am.findViewObject("Departments");
        // Create a new row in this view object.
        Row newDept = departments.createRow();
        // Populate the attributes from the parameter arguments.
        newDept.setAttribute("Deptno", new Number(id));
        newDept.setAttribute("Dname", name);
        newDept.setAttribute("Loc", loc);
        // Add the new row to the view object's default rowset
        departments.insertRow(newDept);
        // Post all changes in the AM, but we don't commit them. The EJB
        // container managed transaction handles the commit.
        _am.getTransaction().postChanges();
      catch(JboException ex) {
        // To be good EJB Container-Managed Transaction "citizens" we have
        // to mark the transaction as needing a rollback if there are problems
        _ctx.setRollbackOnly();
        throw new AppException("Error creating dept "+ id +"\n"+ex.getMessage());
      finally {
        try {
          // Disconnect the AM from the datasource we're using
          _am.getTransaction().disconnect();
        catch(Exception ex) { /* Ignore */ }
    Building a Test Client
    With the EJB-Tier work done, we can build a sample client program to test this new stateless EJB Session Bean by selecting the bean in the Oracle9i JDeveloper IDE and choosing "Create Sample Java Client" from the right-mouse menu.
    When the "Sample EJB Client Details" dialog appears, we take the defaults of connecting to embedded OC4J container. Clicking the (OK) button generates the following test class:
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import com.example.StatelessSampleEJB;
    import com.example.StatelessSampleEJBHome;
    public class SampleStatelessSampleEJBClient {
      public static void main(String [] args) {
        SampleStatelessSampleEJBClient sampleStatelessSampleEJBClient =
           new SampleStatelessSampleEJBClient();
        try {
          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, "welcome");
          env.put(Context.PROVIDER_URL,
                  "ormi://localhost:23891/current-workspace-app");
          Context ctx = new InitialContext(env);
          StatelessSampleEJBHome statelessSampleEJBHome =
               (StatelessSampleEJBHome)ctx.lookup("StatelessSampleEJB");
          StatelessSampleEJB statelessSampleEJB;
          // Use one of the create() methods below to create a new instance
          // statelessSampleEJB = statelessSampleEJBHome.create();
          // Call any of the Remote methods below to access the EJB
          // statelessSampleEJB.createDepartment( int id, java.lang.String name, java.lang.String loc );
        catch(Throwable ex) {
          ex.printStackTrace();
    }We uncomment the call to the create() method and add a few calls to the createDepartment() method so that the body of the test program now looks like this:
    // Use one of the create() methods below to create a new instance
    statelessSampleEJB = statelessSampleEJBHome.create();
    // Call any of the Remote methods below to access the EJB
    statelessSampleEJB.createDepartment( 13, "Test1","Loc1");
    System.out.println("Created department 13");
    statelessSampleEJB.createDepartment( 14, "Test2","Loc2");
    System.out.println("Created department 14");
    try {
      // Try setting a department id that is too large!
      statelessSampleEJB.createDepartment( 23456, "Test3","Loc3");
    catch (AppException ax) {
      System.err.println("AppException: "+ax.getMessage());
    }Before we can successfully run our SampleStatelessSampleEJBClient we need to first run the EJB bean that the client will try to connect to. Since Oracle9i JDeveloper supports local running and debugging of the EJB-Tier without doing through a full J2EE deployment step, to accomplish this prerequisite step we just need to right-mouse on the StatelessSampleEJB node in the System Navigator and select "Run". This starts up the embedded OC4J instance and runs the EJB right out of the current out path.Finally, we can run the SampleStatelessSampleEJBClient, and see the output of the test program in the JDeveloper log window:
    Created department 13
    Created department 14
    AppException: Error creating dept 23456
    JBO-27010: Attribute set with value 23456 for Deptno in Dept has invalid precision/scale
    Troubleshooting
    One error that might arise while running the example is that the database connection information in your data-sources.xml for the jdbc/OracleCoreDS datasource does not correspond to the database you are trying to test against. If this happens, then double-check the file .\jdev\system\oc4j-config\data-sources.xml under the JDeveloper installation home directory to make sure that the url value provided is what you expect. For example, to work against a local Oracle database running on your current machine, listening on port 1521, with SID of ORCL, you would edit this file to have an entry like this for jdbc/OracleCoreDS :
    <data-source
        class="com.evermind.sql.DriverManagerDataSource"
        name="OracleDS"
        location="jdbc/OracleCoreDS"
        xa-location="jdbc/xa/OracleXADS"
        ejb-location="jdbc/OracleDS"
        connection-driver="oracle.jdbc.driver.OracleDriver"
        username="scott"
        password="tiger"
        url="jdbc:oracle:thin:@localhost:1521:ORCL"
        inactivity-timeout="30"
    />This is the data-sources.xml file that gets used by the embedded OC4J instance running in JDeveloper.
    Conclusion
    Hopefully this article has illustrated that it is straightforward to utilize the full power of BC4J in local mode as part of your EJB Stateless Session Beans using container-managed transaction. This example illustrated a single createDepartment method in the enterprise bean, but by replicating the application module interaction code that we've illustrated in createDepartment, any number of methods in your stateless session bean can use the aggregated application module instance created in the ejbCreate() method.
    Code Listing
    The full code listing for the SampleStatelessEJB bean implementation class looks like this:
    * StatelessSampleEJB
    * Illustrates how to use an aggregated BC4J application module
    * in local mode as part of the implementation of a stateless
    * EJB session bean using container-managed transaction.
    * HISTORY
    * smuench/dmutreja 14-FEB-2002 Created
    package com.example;
    import oracle.jbo.*;
    import oracle.jbo.server.*;
    import javax.ejb.*;
    import oracle.jbo.domain.Number;
    import oracle.jbo.common.PropertyConstants;
    import java.util.Hashtable;
    import javax.naming.InitialContext;
    import oracle.jbo.server.ejb.ContainerManagedTxnHandlerImpl;
    public class StatelessSampleEJBBean implements SessionBean {
      // JNDI resource name for the J2EE datasource to use
      private static final String DATASOURCE = "jdbc/OracleCoreDS";
      // Fully-qualified BC4J application module name to aggregate
      private static final String APPMODNAME = "com.example.hr.HRApp";
      // Place to hold onto the aggregated appmodule instance
      transient private ApplicationModule _am  = null;
      // Remember the SessionContext that the EJB container provides us
      private           SessionContext    _ctx = null;
      public void ejbCreate() throws CreateException {
        try {
          // Setup a hashtable of environment parameters for JNDI initial context
          Hashtable env = new Hashtable();
          env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
          env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
          env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
          // Create an initial context, using this hashtable of environment params
          InitialContext ic = new InitialContext(env);
          // Lookup a home interface for the application module
          ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
          // Using the home, create the instance of the appmodule we'll use
          _am = home.create();
          // Register the BC4J factory to handle EJB container-managed transactions
          registerContainerManagedTransactionHandlerFactory();
        catch(Exception ex) {
           ex.printStackTrace();
          throw new CreateException(ex.getMessage());
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}
      public void setSessionContext(SessionContext ctx){ _ctx = ctx; }
      public void createDepartment(int id, String name, String loc)
      throws AppException {
        try {
          // Connect the AM to the datasource we want to use for the duration
          // of this single method call.
          _am.getTransaction().connectToDataSource(null,DATASOURCE,false);
          // Use the "Departments" view object member of this AM
          ViewObject departments = _am.findViewObject("Departments");
          // Create a new row in this view object.
          Row newDept = departments.createRow();
          // Populate the attributes from the parameter arguments.
          newDept.setAttribute("Deptno", new Number(id));
          newDept.setAttribute("Dname", name);
          newDept.setAttribute("Loc", loc);
          // Add the new row to the view object's default rowset
          departments.insertRow(newDept);
          // Post all changes in the AM, but we don't commit them. The EJB
          // container managed transaction handles the commit.
          _am.getTransaction().postChanges();
        catch(JboException ex) {
          // To be good EJB Container-Managed Transaction "citizens" we have
          // to mark the transaction as needing a rollback if there are problems
          _ctx.setRollbackOnly();
          throw new AppException("Error creating dept "+ id +\n"+ex.getMessage());
        finally {
          try {
            // Disconnect the AM from the datasource we're using
            _am.getTransaction().disconnect();
          catch(Exception ex) { /* Ignore */ }
      private void registerContainerManagedTransactionHandlerFactory() {
        SessionImpl session = (SessionImpl)_am.getSession();
        session.setTransactionHandlerFactory(
          new TransactionHandlerFactory() {
            public TransactionHandler createTransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();
            public JTATransactionHandler createJTATransactionHandler() {
              return new ContainerManagedTxnHandlerImpl();

    Hi Steve, It4s me again;
    About the question I made, I tried with a single assembly-descriptor tag and a single container-transaction tag in the deployment descriptor of the session bean and these were the results.
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Then I tried with multiple assembly-descriptor tags each with a single container-transaction tag and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    Finally I tried with a single assembly-descriptor and multiple container tags and the results were:
    java.lang.NullPointerException
         void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
         java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
         void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
    How can I make my Stateless Session bean work out?

  • Javax ejb CreateException: Could not create stateless EJB

    Hi,
    I have a JavaEE (EJB3.0) project deployed on glassfish2.1 as -.ear (exported from eclipse3.4 to the autodeploy-folder) with -.ejb.jar, -.webui.war, general-lib-base.jar (some other...)
    The session bean is invoked by a jsf-managed bean. Have a pure annotation +@ejb+ in managed bean (identifiing the ejb-interface (+@Remote+) ...the ejb is annotated with +@stateless+
    get the following error message:
    *...nested exception is: javax.ejb.CreateException: Could not create stateless EJB*
    as beginner in the JavaEE-field I'm looking for some help concerning the possible causes.
    thank's for any comment...
    (also posted in the Enterprise JavaBeans-forum possibly better there)

    problem fixed: in the deployment-descriptor ejb-jar.xml a spezification of the session-bean hung around ...very annoying!

  • Stateless EJB is null using TimerService

    Hi,
    I created a stateless ejb using TimerService to run it in weblogic 10.3. After deploying it, I could not get the ejb instantiated properly. The code is as below.
    Could anyone explain what is missing?
    Thanks in advance.
    //=================================================
    public interface ReconTimer {
    public void createTimer();
    //================================================
    import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import javax.annotation.Resource;
    import javax.ejb.EJB;
    import javax.ejb.Stateless;
    import javax.ejb.Timeout;
    import javax.ejb.Timer;
    import javax.ejb.TimerService;
    import javax.ejb.Local;
    import javax.ejb.TransactionAttribute;
    import javax.ejb.TransactionManagement;
    import javax.ejb.TransactionManagementType;
    @Stateless (name="ReconTimerBean")
    @Local (ReconTimer.class)
    @TransactionManagement(value=TransactionManagementType.BEAN )
    @TransactionAttribute(value=NOT_SUPPORTED)
    public class ReconTimerBean implements ReconTimer {
         private static final Log log = LogFactory.getLog(ReconTimerBean.class);
    @Resource
    TimerService timerService;
    public void createTimer() {
         log.info("Crating timer");
         log.info("timerService [" + timerService + "]");
    Timer timer = timerService.createTimer(20000,
    "Created new timer");
    @Timeout
    public void timeout(Timer timer) {
    log.info("Timeout occurred !!!");
    ========================================
    client code:
    @EJB(beanName="ReconTimerBean")
    ReconTimer timerBean
    if (timerBean != null)
    timerBean.createTimer();
    else log.error ("Timer Bean is null !!!");
    Error is always logged when the bean is deployed.
    ======================================
    weblogic-ejb-jar.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar"
         xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd">
    <weblogic-enterprise-bean>
    <ejb-name>ReconTimerBean</ejb-name>
         <stateless-session-descriptor>
              <pool>          
                   <max-beans-in-free-pool>1</max-beans-in-free-pool>          
                   <initial-beans-in-free-pool>1</initial-beans-in-free-pool>     
              </pool>
         </stateless-session-descriptor>
    <jndi-name>app-recon-bean</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>

    Hi Ashley,
    The Dependency injection has some limitations as well…Please referto the following link: (Web Component Classes That Support Annotations)
    http://download.oracle.com/docs/cd/E13222_01/wls/docs100/webapp/annotateservlet.html
    …Which says that DI is not possible from every web component.
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com/ejbs_weblogic/#comment-165  (Dependency Injection Issues)

  • Error with stateless EJB

    Hi,
    I am new to WebLogic and I trying to learn it. I was doing an exercise with a stateless EJB I got from a book and get this error:
    javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory. Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
         at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    That class is already in my class path and still does not work. I am using WLS 8.1 on a Linux Suse 9.0 OS, and my IDE is Eclipse. The code seems to be fine seems it is deployed flawlessly by the server. No errors, no warnings. I can post if some one needs to see it. Any ideas?
    Thanks!

    If anyone is interested, and since it seems to be a common anoying problem, the solution is to put the weblogic.jar files in the classpath, and all of the client ones as well.

  • Use select & update(query) at the same time

    I'm sorry to trouble you.
    I am racking my brains to find a solution to the problem.
    I don't search a problem in my source.
    I maked every effort.
    I am tired to death.
    I wanna use (select & update(query)) at the same time.
    The Source compiled but have not access to DB
    plz help me.
    Can you give me a hand?
    sorry my bad English..
    link my source
    http://www.netian.com/~111nice/bangnew.java

    can you clearly explain whats problem and what error your are getting

  • Stateless EJB (exposed only one fn) as a web service - Error illegal public

    I have a stateless EJB which has 3 methods.
    I expose one of them only as a web service.
    But when I test my web service I receive an error...
    500 Internal Server Error
    Servlet error: The class blah.blah.I_EmpRemote contains illegal public methods.
    These methods do not conform to the
    restrictions imposed by the web service implementation
    Offending methods:
    public abstract blah.blah.Employee blah.blah.I_EmpRemote.GetEmployee(java.lang.String) throws java.rmi.RemoteException
    public abstract blah.blah.Operator blah.blah.I_EmpRemote.GetOperator(java.lang.String,int) throws java.rmi.RemoteException
    So does this mean .. I should make sure all or none of my methods of an EJB are exposed in the Web Service ?
    Or I can resolve this in any other way ?
    Thanks,
    Krishna

    Or is it becoz the two methods that it objected to were returning user-defined objects and not String, void, Integer ... that a web service can recognize !
    But still ... why cannot it just ignore the methods that are not exposed ?
    Can someone throw some light on this.
    Thanks,
    Krishna

  • Stateless EJB Global Variable Timeout question

    Hi,
    In this Stateless EJB:
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class HelloBean implements SessionBean
    int testnum = 0;
    public void ejbCreate()
    public void ejbActivate()
    public void ejbPassivate()
    public void ejbRemove()
    public void setSessionContext(SessionContext ctx)
    public String sayHello(String param)
    testnum++;
    System.out.println("Someone call me!" + testnum);
    return "Hello " + param + "! This is an EJB. The current time is " + new java.util.Date() + " The Number is:" + testnum;
    Why "testnum" will keep the value for about 1.5 minutes? If I call this EJB within the 1.5 mins the "testnum" will add the previous value. I don't understand. Because its a stateless session EJB, everytime when I call it the value should be reset.
    How can I fix this problem?
    Please help
    Thanks
    Kenny

    This is why instance variables in a Stateless session bean are not a good idea. The variables do not get reset. It only "appears" to be reset because you probably got a different instance of a session bean.
    Further, since you can be bound to any bean in the pool, you can have different values every time you get a bean.
    Paul

Maybe you are looking for