Direct DB access from Session Bean w/o using Serialized Objects

I am developing a system where I am receiving some messages (data ) inside session bean and I want to log that data into data base �.i.e inserting that data in to various tables. I am not showing that data to client ( that is taken care by another application).
So I am directly calling insert methods on various tables instead of going for serialized classes for each of that tables and calling setter methods. Is this approach correct? Or this will create nightmares when millions of messages are to be logged? Do I have to make serialized objects? Please post the suggestions ..Thank you in advance.
If session bean is making direct inserts in the DB using Helper classes as shown below �is there any problem of concurrency?? Means multiple session bean instances inserting data in the same table using the helper class will create any problems?? I am using MySql db presently. Or all will work fine coz I am using the data source and pool available in welogic app server?
Is this a good approach if my application is doing inserts 90% of times? or I have to use entity beans or serialized objects encapsulating each class?
public class Logger implements SessionBean
DAO dao = getDAO();
dao.insertXyzLog(�x�, �y�,�.);
private DAO getDAO(){
if(Dao == null) {
oao = DAOFactory.getDAO();
return Dao;
//other std methods
public interface DAO {
// methods to directly insert data in to the tables
//some methods to look for required value in another tables
public abstract void insertXyzLog (String x, Stringy, ���.);
public class DAOImpl implements DAO {
// look up for JNDI data sourse
//method to return connection
public void insertXyzLog (String x, Stirng y�){
//SQLs for inserting into Xyz table using connection obtained above.

Hi,
Nothing wrong in using Helper class to insert into table. It won't create problem as long as your database server able to handle that many request from client.
If you use weblogic server and datasource, the server will take care of all connection pool management depending upon your configuration parameters.
Moreover, insert won't lock the table. So you need not worry about those things.
Best Luck,
Senthil Babu
Developer Technical Support
SUN Microsystems
http://www.sun.com/developers/support/

Similar Messages

  • Database access from session bean

    Hello,
    I have a stateless session bean which performs some complex
    calculations, and also does some database access.
    For the database access the bean class has a datasource as
    follows:
    public class TestBean implements SessionBean {
    private DataSource ds_;
    public void ejbCreate() {
         getDataSources();
    private void getDataSources() {
         try {
         Context ictx = new InitialContext();
         ds_ = (DataSource)ictx.lookup("java:comp/env/jdbc/TestDB");
         } catch (Exception e) {
         e.printStackTrace();
         throw new EJBException(e);
    Now this class has a method (which is also in the remote interface)
    calculateSomething(). This method constructs a number of other
    objects that do the actual calculation, and one of these objects
    does the actual database access. How would another object be able to
    use the datasource that was constructed in the bean class?
    I could pass the datasource reference to that object, but that would
    break my encapsulation. This is because that object does not get
    created directly by the bean object, but rather the way the objects
    interact is something like A -> B -> C, where A is the TestBean, and
    C is the object that does the DB access. If I passed the datasource,
    I would need to make B aware of the datasource, which doesn't
    seem good design, because B doesn't do any database access.
    Alternatively I could do the lookup in class C, but that would
    degrade the performance, as an object C gets created and destroyed
    every time the calculateSomething() method is called.
    A third option I have thought of, is to add a public method to the
    bean that returns a connection. Whenever another object gets
    created, a reference to the bean object will be passed along. Then,
    if another object needs to do database access, it will call back
    the bean to get a connection. This seems just as bad (if not worse)
    than the first option.
    Does anyone have an elegant solution for this situation? What is
    the best practice of handling datasources when a bean class doesn't
    do the database access itself? In all the examples I've seen so far,
    all the functionality was in the session bean class, but again that
    doesn't seem good OO design, and would result in a single huge class.
    regards,
    Kostas

    Thanks again to both for the replies. Here are my responses:
    Yi Lin: Yes, I know that an entity bean would solve this problem, however it has been decided not to use entity beans so this is not my call (I think the reason entity beans are not allowed in this project is that they are considered risky: there are other applications that access the same database, so if the container caches entity bean data as you describe, then the users might get inconsistent results).
    Gerard: Actually object B is the one that has the business logic and C is a peer object that only does database access and no calculaitons. For example B can be Customer, and C CustomerDB. This is why object B does not have any knowledge of datasources or connections. So my design does not appear to be that bad!
    As far as the factory you propose is concerned, I cannot understand how this would solve my problem. In order to solve this situation the factory would need to be persistent, i.e. get created by the ejbCreate() method, and destroyed whenever the container decides to destroy the bean. There would be no point in object C creating the factory, as I would have the overhead of doing the JNDI lookup every time I create a C.
    So the question remains the same: how would I pass a reference to the factory from A to C without making B aware of it?

  • How to send message to MessageDrivenBean from Session bean in JDeveloper

    HI I am trying to write a sample program using JDeveloper.
    I am trying to do these steps
    1) client class which gets Session bean and calls its method.
    2) write Stateless Session bean with a method which gets MDB and sends message.
    3) write Message Driven Bean ( which prints message recieved from Session bean )
    Set up
    =======
    jms.xml
    {JDevHome}\jdev\system9.0.5.2.1618\oc4j-config\jms.xml : changed jms.xml file and included
         <topic name="Demo Topic" location="jms/theTopic">
              <description>A dummy topic</description>
         </topic>
         <topic-connection-factory name="Demo Topic Connection Factory" location="jms/theTopicConnectionFactory">
              <description>A dummy topic connection factory</description>
         </topic-connection-factory>
    orion-ejb-jar.xml:
    edited MDB entry to
    <message-driven-deployment name="MessageLogger"
    destination-location="jms/theTopic" connection-factory-location="jms/theTopicConnectionFactory">
    </message-driven-deployment>
    Implementation
    ===============
    In client class:
    I am getting session bean like
    Properties props = System.getProperties();
    props.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY , "com.evermind.server.rmi.RMIInitialContextFactory");
    props.put( javax.naming.Context.SECURITY_PRINCIPAL , "admin" );
    props.put( javax.naming.Context.SECURITY_CREDENTIALS,"welcome");
    props.put( javax.naming.Context.PROVIDER_URL ,"ormi://localhost:23891/current-workspace-app");
    Context ctx = new InitialContext(props);
    MySessionHome home = (MySessionHome)
              javax.rmi.PortableRemoteObject.narrow(obj, MySessionHome.class);
    This part works fine, and I am calling method on session bean created out of home.
    In Session bean:
    I want to get TopicConnectionFactory and tried these two ways:
    a)
    getting the context by setting new environemnt values like
    Properties props = System.getProperties();
    props.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY , "com.evermind.server.jms.EvermindConnectionFactory");
    props.put( javax.naming.Context.SECURITY_PRINCIPAL , "admin" );
    props.put( javax.naming.Context.SECURITY_CREDENTIALS,"welcome");
    props.put( javax.naming.Context.PROVIDER_URL ,"ormi://localhost:9227/current-workspace-app");
    Context ctx = new InitialContext( props);
    When I try this,it is complaining that it cannot instantiate EvermindConnectionFactory.
    I am not sure which factory class we have to use here.i tried all the Factory class in that package.but didn't worked.
    next I used,
    b)
    tried to use default context in session bean to get MDB factory
    String TOPIC_NAME="jms/theTopic";
    String TOPIC_CONNECTION_FACTORY="jms/theTopicConnectionFactory";
    TopicConnectionFactory connectionFactory = (TopicConnectionFactory)new InitialContext().lookup("java:comp/env/" + TOPIC_CONNECTION_FACTORY);
    this gives
    04/06/13 23:46:09 javax.naming.NameNotFoundException: jms/theTopicConnectionFactory not found in MySession
    04/06/13 23:46:09      at com.oracle.naming.J2EEContext.getSubContext(J2EEContext.java:93)
    this may be because JMS server runs on different port than other EJBs and have different namespaces.
    Can any body give info,how we can make use of Message Driven bean from a Session Bean or from a JSP page or from a simple class inside JDeveloper.
    Thanks in advance.
    gopal

    Hi,
    There are some hints in this forum for how to do this.
    I put together and make it working.
    This example creates an MD Bean and have a simple message and a client class send messages to that bean.
    Steps
    =====
    1)
    a)in {JDev Home}\jdev\system9.0.5.2.1618\oc4j-config\jms.xml
         <topic name="Demo Topic" location="jms/demoTopic">
              <description>A dummy topic</description>
         </topic>
         <topic-connection-factory name="Demo Topic Connection Factory" location="jms/theTopicConnectionFactory">
              <description>A dummy topic connection factory</description>
         </topic-connection-factory>
    b) in current project in orion-ejb-jar.xml
    go to orion-ejb-jar properties and add these values there to MDB node
    destination-location=jms/demoTopic
    connection-factory-location=jms/theTopicConnectionFactory
    2) create a dummy session bean and a dummy client for that session bean
    This sets default configuration for the client application we write
    doing so we do not need to set properties to get Initial context.It makes use of
    {JDev Home}\jdev\system9.0.5.2.1618\oc4j-config\.client\jndi.properties
    We can directly get Contexxt ctx = new InitialContext();
    3) Create MDB and put this sample code in method
    onMessage()
    TextMessage tm = (TextMessage) msg;
    try {
    String text = tm.getText();
    System.err.println("Received new message : " + text);
    catch(JMSException e) {
    e.printStackTrace();
    4) go to properties for the MDB and set Destination to Topic
    5) write Client code
    Context ctx =new InitialContext();
    // 1: Lookup ConnectionFactory via JNDI
    TopicConnectionFactory factory =     
    (TopicConnectionFactory) ctx.lookup("jms/theTopicConnectionFactory");
    // 2: Use ConnectionFactory to create JMS connection
    TopicConnection connection = factory.createTopicConnection();
    // 3: Use Connection to create session
    TopicSession session = connection.createTopicSession( false, Session.AUTO_ACKNOWLEDGE);
    // 4: Lookup Desintation (topic) via JNDI
    Topic topic = (Topic) ctx.lookup("jms/demoTopic");
    // 5: Create a Message Producer
    TopicPublisher publisher = session.createPublisher(topic);
    // 6: Create a text message, and publish it
    TextMessage msg = session.createTextMessage();
    msg.setText("This is a test message from My Test Client!!! .");
    publisher.publish(msg);
    6) Run the server and run the client

  • NoSuchObjectException from Session bean wrapper

    Hi,
    I am getting the following exception when accessing a session bean.
    The exception is thorwn from a method of a statful session bean. The lines before and after the particular line are exceuted properly
    public void cloneBasket(eprcBasketSF pDestinationBkt) throws RemoteException{
    pDestinationBkt.setIsJobValid(this.m_IsBktJobValid);
    pDestinationBkt.setIsAppValid(this.m_IsBktAppValid);
    pDestinationBkt.setIsSubValid(this.m_IsBktSubValid);
    pDestinationBkt.setIsPOValid(this.m_IsBktPOValid);
    pDestinationBkt.setIsEdaValid(this.m_IsBktEdaValid);
    pDestinationBkt.setIsIdaValid(this.m_IsBktIdaValid);
    //** Exception is thrown at this line only
    pDestinationBkt.setBasketLines(this.m_bktLines);
    pDestinationBkt.setDeletedBasketLines(cloneDeletedBasketLines());
    java.rmi.NoSuchObjectException: Session has timed out
    at com.evermind.server.ejb.StatefulSessionEJBObject.throwPassivisationEx
    ception(.:215)
    at eprcBasketSF_StatefulSessionBeanWrapper3.cloneBasket(eprcBasketSF_Sta
    tefulSessionBeanWrapper3.java:469)
    at com.comp.eProcurement.eprcCore.eprcBasketJBean.cloneBasket(eprcBaske
    tJBean.java:58)
    at com.comp.eProcurement.eprcCore.eprcBasketTemplateManager.retrieveBas
    ketByKey(eprcBasketTemplateManager.java:1471)
    at com.comp.eProcurement.eprcCore.eprcBasketTemplateManager.getCurrentB
    asket(eprcBasketTemplateManager.java:598)
    at com.comp.eProcurement.eprcCore.eprcEprocSession.passivate(eprcEprocS
    ession.java:953)
    We are using orion server 1.5.3. Can any body tell me what could be causing this problem.
    Thanks in advance
    karthi

    Hi,
    I got an exact same error. I'm using Oracle 9i App Server, but it's based on Orion server, which you're using.
    When I try to use stateful session bean, I also got "Session has timed out" error at the exact same point (com.evermind.server.ejb.
    StatefulSessionEJBObject.throwPassivisationException).
    I have no clue, either. My session bean worked fine bofore, but after I updated records in the database, then something went wrong. First, I thought database connection problem or something, but it's definitely not.
    If you find out the problem, please post it here or send me email below.
    [email protected]
    If I figure it out, I'll post it here, too.
    thanks.
    -tom

  • How to call a EJB method from Session bean method

    Hi all,
    I'm new to J2EE programming. I have a simple doubt .
    I have already created a lookup method for EJB bean in Session bean .
    My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
    Please provide me an example code .
    Thanks in advance.

    InitialContext ctx = new InitialContext();
         GeneralEditor editor = (GeneralEditor) ctx
                        .lookup("GeneralEditorBean/remote");
              GeneralService service = (GeneralService) ctx
                        .lookup("GeneralServiceBean/remote");
              LanMu lm = new LanMu();
              lm.setName("shdfkhsad");
              editor.add(lm);

  • Accessing Managed Session Bean in Servlet Filter

    I wrote a Servlet Filter to handle user authentication. Now I'm trying to access my Managed Session Bean in the filter in order to save the current user. Unfortunately the Session Bean is created after the Filter executes for the first time.
    I'm trying to access the Session Bean in this way:
    (SessionBean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("sessionBean");
    In this case getExternalContext() is equals null.
    Is there any way to create the Session bean before the filter executes or any other ideas how to handle this?
    I already searched around the internet but couldnt figure out something.
    Thanks guys,
    Paul

    Ok, fixed it like this. Works perfect. JSF finds and uses the handmade Session Bean as well.
    if(request.getSession().getAttribute(BeanNames.SESSION_SCOPE_BEAN) == null) {
         SessionBean sessionBean = new SessionBean();
         request.getSession().setAttribute(BeanNames.SESSION_SCOPE_BEAN, sessionBean);
    }Thanks,
    Paul

  • URGENT ! JDEV 10.1.2 Problem with data control generated from session bean

    I got a problem with data control generated from session bean which return a collection of data transfer object.
    The dto's seem to be correct. The session bean load correctly the data into and the object's are plenty of data. Using the console to display the dto content is ok.
    When generating a data control from this session bean and associate the dto included in the collection only the first object level and one-to-one dto object are correctly setted in the data control. Object that represent collection into the dto (one-to-many foreign key) are setted as collection with an iterator but the structure of the object is not setted. I don't know how to associate this second level of collection with the dto bean class to obtain the attributes definition.
    I created a case with hr schema like the hrApp demo application in the tutorial with departments and employees table. I got the same problem.
    Is it a bug ?
    It exists a workaround to force the data control to understand the collection data structure ?
    Help is welcome ! this is urgent !!!

    we found the problem by assigning the child dto bean class to the node representing the iterator in the xml file corresponding to the master dto.

  • Could not access Local Session Bean using JNDI lookup

    Hi EJB Guru,
    I am quite new to EJB 3.0 but have had a good deal of success including using JNDI to lookup Remote Stateless Session Bean in EJB 3.0. However, looking up local Stateless Session Bean prove more challenging with I had anticipated.
    Here is my code
    as follows:
    public interface Calculator {
        public int add(int x, int y);
        public int subtract(int x, int y);
    import javax.ejb.Remote;
    @Remote
    public interface CalculatorRemote extends Calculator {
    import javax.ejb.Local;
    @Local
    public interface CalculatorLocal extends Calculator {
    import javax.ejb.Local;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    import bean.CalculatorLocal;
    import bean.CalculatorRemote;
    @Stateless
    public class CalculatorBean implements CalculatorRemote, CalculatorLocal {
        public int add(int x, int y) {
            return x + y;
        public int subtract(int x, int y) {
            return x - y;
    import bean.*;
    import bean.Calculator;
    import bean.CalculatorLocal;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public class ClientAccessLocalCalculator {
        public static void main(String[] args) throws NamingException {
            InitialContext ctx = new InitialContext();
            CalculatorLocal calculator = (CalculatorLocal) ctx.lookup("CalculatorBean/local");
            System.out.println("1 + 1 = " + calculator.add(1, 1));
            System.out.println("1 - 1 = " + calculator.subtract(1, 1));    }
    import bean.Calculator;
    import bean.CalculatorRemote;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public class ClientAccessRemoteCalculator {
        public static void main(String[] args) throws NamingException {
            InitialContext ctx = new InitialContext();
            CalculatorRemote calculator = (CalculatorRemote) ctx.lookup("CalculatorBean/remote");
            System.out.println("1 + 1 = " + calculator.add(1, 1));
            System.out.println("1 - 1 = " + calculator.subtract(1, 1));    }
    }Output when running ClientAccessRemoteCalculator gives
    1 + 1 = 2
    1 - 1 = 0
    Output when running ClientAccessLocalCalculator on JBoss AS 4.0.5 gives:
    Exception in thread "main" javax.ejb.EJBException: Invalid invocation of local interface (null container)
    at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:75)
    at $Proxy0.add(Unknown Source) at ClientAccessLocalCalculator.main(ClientAccessLocalCalculator.java:14)
    JNDIView in JMX-Console in JBoss:
    +- CalculatorBean (class: org.jnp.interfaces.NamingContext)
    | +- local (proxy: $Proxy84 implements interface bean.CalculatorLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
    | +- remote (proxy: $Proxy83 implements interface bean.CalculatorRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
    Output when running ClientAccessLocalCalculator on SJSAS 9.0 gives:
    Exception in thread "main" javax.naming.NameNotFoundException: bean.CalculatorLocal not found
    C:\>asadmin
    Use "exit" to exit and "help" for online help.
    asadmin> list-jndi-entries
    Jndi Entries for server within root context:
    bean.CalculatorRemote: javax.naming.Reference
    jbi: com.sun.enterprise.naming.TransientContext
    jdbc: com.sun.enterprise.naming.TransientContext
    UserTransaction: com.sun.enterprise.distributedtx.UserTransactionImpl
    bean.CalculatorRemote__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
    bean.CalculatorRemote#bean.CalculatorRemote: javax.naming.Reference
    ejb: com.sun.enterprise.naming.TransientContext
    Command list-jndi-entries executed successfully.
    asadmin>I am using Application Client to lookup these Session Beans on Netbeans 5.5, JBoss AS 4.0.5 (EJB3 installer)/SJSAS
    9.0, SDK 1.5.0_11 on Windows XP platform.
    Any assistance would be much appreciated.
    Many thanks,
    Henry

    Hi Henry,
    Any direct global JNDI lookup is not portable. It works in some cases but not in others, which
    is why we recommend using the portable Java EE approach of declaring an ejb dependency
    and looking up that dependency via the bean's component environment (java:comp/env).
    This is true whether you're dealing with Remote or Local ejb dependencies.
    Local ejbs are not supported in the Application Client tier at all. In the server tier, there is no
    guarantee that a Local EJB even is assigned a global JNDI name since there's no requirement
    that it be available outside of the application in which the ejb is defined.
    You can find more information on these ejb access topics in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

  • Obtaining PersistenceManager from Session Bean in JBoss 3.0.4

    Hi,
    I'm attempting to use the JCA for JBoss with Kodo 2.4.0. The kodo.rar seems to deploy ok:
    2002-12-18 11:19:43,640 INFO [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] Bound connection factory for resource adapter 'KodoJDO' to JNDI name 'java:/kodo'
    2002-12-18 11:19:43,640 INFO [org.jboss.resource.connectionmanager.LocalTxConnectionManager] Started
    2002-12-18 11:19:43,640 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/kodo.rar
    In my session bean, I access the PersistenceManager using the following code:
    InitialContext context _ new InitialContext();
    JDOConnectionFactory factory _ (JDOConnectionFactory)context.lookup("java:/kodo");
    PersistenceManager pm _ (PersistenceManager)factory.getConnection();
    The code generates a JDOFatalDataStoreException when I try to execute it:
    Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac; - nested throwable: (javax.resource.ResourceException: Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac)
    And when I execute it a second time around, it seems to retrieve the PersistenceManager ok, but when I try to invoke methods on it, I get an SQLException:
    Connection is broken: Software caused connection abort: socket write error
    at com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.newDataStoreId(JDBCStoreManager.java:464)
         at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistentFilter(PersistenceManagerImpl.java:1107)
         at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:1059)
         at org.aims.his.ejb.PatientBean.createPatient(PatientBean.java:117)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
         at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
         at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
         at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
         at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
         at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
         at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
         at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
         ... 47 more
    So...what did I miss? Could it be the configuration of my connection to the database in kodo-service.xml (see attached)? In the server log files I didn't see any of my connection properties.
    Any help is appreciated.
    Thanks,
    Jeff

    Ok, looks like it was the kodo-service.xml file. I removed the ConnectionFactoryName entry and most of the options were commented out which I didn't catch...
    Thanks,
    Jeff
    "Jeff Carnegie" <[email protected]> wrote in message news:[email protected]...
    Hi,
    I'm attempting to use the JCA for JBoss with Kodo 2.4.0. The kodo.rar seems to deploy ok:
    2002-12-18 11:19:43,640 INFO [com.solarmetric.kodo.impl.jdbc.ee.ManagedConnectionFactoryImpl.kodo] Bound connection factory for resource adapter 'KodoJDO' to JNDI name 'java:/kodo'
    2002-12-18 11:19:43,640 INFO [org.jboss.resource.connectionmanager.LocalTxConnectionManager] Started
    2002-12-18 11:19:43,640 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/kodo.rar
    In my session bean, I access the PersistenceManager using the following code:
    InitialContext context _ new InitialContext();
    JDOConnectionFactory factory _ (JDOConnectionFactory)context.lookup("java:/kodo");
    PersistenceManager pm _ (PersistenceManager)factory.getConnection();
    The code generates a JDOFatalDataStoreException when I try to execute it:
    Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac; - nested throwable: (javax.resource.ResourceException: Error in use of ManagedConnectionPool: matchManagedConnection failed with subject: null and ConnectionRequestInfo: [email protected]3be7ac)
    And when I execute it a second time around, it seems to retrieve the PersistenceManager ok, but when I try to invoke methods on it, I get an SQLException:
    Connection is broken: Software caused connection abort: socket write error
    at com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.newDataStoreId(JDBCStoreManager.java:464)
    at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistentFilter(PersistenceManagerImpl.java:1107)
    at com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:1059)
    at org.aims.his.ejb.PatientBean.createPatient(PatientBean.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
    at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
    at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
    at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
    at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
    at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
    at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
    at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
    ... 47 more
    So...what did I miss? Could it be the configuration of my connection to the database in kodo-service.xml (see attached)? In the server log files I didn't see any of my connection properties.
    Any help is appreciated.
    Thanks,
    Jeff

  • Problem invoking gogle web service from session bean

    Hello
    I have developed a Web-Client which consumes the google-WebService with Apache Axis. I have generated the corresponding classes with WSDL2Java and the client works without problems. A little code fragment from my client:
    GoogleSearchService service = new GoogleSearchServiceLocator();
              // Now use the service to get a stub to the Service Definition Interface (SDI)
              GoogleSearchPort google = service.getGoogleSearchPort();
             GoogleSearchResult googleSearchResult =  google.doGoogleSearch(GOOGLE_KEY, // java.lang.String key
                           q.toString(), //java.lang.String q
                           0, // int start
                           10, // int maxResults
                           false, //boolean filter
                           "", // java.lang.String restrict      
                           false, //boolean safeSearch              
                           "lang_ja|lang_en", // java.lang.String lr
                           "UTF-8", // java.lang.String ie
                           "UTF-8"); // java.lang.String oeNow I have to put the Web-Client in a SessionBean. Therfore I defined the code of the web-client in a method and put it into a stateless session bean and wrote a client for the session bean. But when the session bean invokes the corresponding method for consuming the google web service, there always occurs the following error:
    [java] Exception in thread "main" java.rmi.ServerError: Unexpected Error; nested exception is:
    [java] java.lang.NoClassDefFoundError: GoogleSearch/GoogleSearchService
    But I have definitely all necessary classes in my classpath, like GoogleSearchService, etc. So all necessary classes are available. And the code to conume the web service als works because as said I tested it with a web-client.
    Has anybody an idea what went wrong here? Is there anything important when I a web service is invoked by a session bean??:(
    regards
    pat

    Has nobdy an idea?? :(( I tried for such a long time but I was not able to fix this problem....:(
    Please help...

  • Generating web service from session bean

    Hi
    I have a session bean in one project which has a service-endpoint defined.
    My web services are in another project entirely, within the same workspace if that helps any.
    When I generate the web service from the EJB JDev turns the business tier project into a web project,
    I don't see any options to include the web service in the web project.
    I've reversed all of the changes, but wonder if I shouldn't redo it and copy the mapping file and configuration
    across to the web project and reverse the changes in the business tier.
    This is a workaround that I'm hoping to avoid, as I'm doing the "howto" for this in our project.
    How is this normally done?

    I tried generating the web servioce from WSDL, in the web project.
    I tested and the web service works fine.
    Then I changed the config file to point to the ejb, but the server won't start up....
    *08/09/17 10:58:40 WARNING: Application.setConfig Application: current-workspace-app is in failed state as initialization failed.*
    This is the webservices.xml bit I updated...
         <ejb-link>SomeOrOtherEjbName</ejb-link> The bit I found in webservices.xml when the service is in the business tier.
    <!-- <servlet-link>SomeOrOtherWebServiceSoapHttpPort</servlet-link> --> The service that works in the web tier.

  • Problem with JMS from session bean

     

    My guess is that in your effort to work around the
    clustering/ejb/jndi problems, you have a producer
    sending on one topic, and a consumer listening on
    another topic. You can check to see if they are the
    same destination using the (uncompiled) code snippets
    below at both the producer and consumer ends.
    import weblogic.jms.common.DestinationImpl;
    Topic topic;
    DestinationImpl destination = (DestinationImpl) topic;
    System.out.println("name = " + destination.getServerName() + "/" +
    destination.getName());
    System.out.println("back-end id = " + destination.getBackEndId());
    System.out.println("destination id = " + destination.getDestinationId());
    _sjz.
    "Malcolm Robbins" <[email protected]> wrote in message
    news:[email protected]...
    >
    This was also posted to the EJB newsgroup and was asked to post the secondissue
    here. Please focus on the second issue, but the first providesbackground.
    >
    >
    I have discovered two significant problems in WLS6.0 with JNDi and JMSthat do
    not occur in the Sun Reference implementation (1.3 Beta).
    Attached is some code you can try to see the problem.
    I have developed a JmsClient that simply looks up a session bean andpasses it
    a string to publish. The session bean is meant to publish to a JMS topic.
    However I have discovered two problems:
    1) In teh ejbCreate() method I look up the topic connection factory andtopic
    in JNDI. These are referenced as "java:comp/env/jms/JmsConnectionFactory"and
    "java:comp/env/jms/JmsTopic" respectively. Here's a fragment of theejb-jar
    descriptor
    <resource-ref>
    <description>The (probably durable) Topic Connection Factory to connectto</description>
    <res-ref-name>jms/JmsConnectionFactory</res-ref-name>
    <res-type>javax.jms.TopicConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <resource-env-ref>
    <description>The Jms Source Topic to publish to</description>
    <resource-env-ref-name>jms/JmsTopic</resource-env-ref-name>
    <resource-env-ref-type>javax.jms.Topic</resource-env-ref-type>
    </resource-env-ref>
    As you can see they are resource references and resoruce environmentreferences
    respectively. The weblogic-ejb-jar maps these to the real JNDI names"TopicConnectionFactory"
    amd "SchemaTopic" respectively as shown below by the fragment:
    <weblogic-ejb-jar>
    ...etc...
    <reference-descriptor>
    <resource-description>
    <res-ref-name>jms/JmsConnectionFactory</res-ref-name>
    <jndi-name>TopicConnectionFactory</jndi-name>
    </resource-description>
    <resource-env-description>
    <res-env-ref-name>jms/JmsTopic</res-env-ref-name>
    <jndi-name>SchemaTopic</jndi-name>
    </resource-env-description>
    </reference-descriptor>
    Now here's the first problem. When this is deployed the resourceenvironment
    "logical" name (JNDI linkref) for the topic is not defined. The code willhappily
    find the connection factory (presuming you've set these administeredobjects at
    the console).
    2) The second problem now arises. In the code I have ahcked it so thatwhen
    the JNDI lookup fails it tries looking up the real topic in JNDI(SchemaTopic)
    directly.
    This works and teh bean now appears to work, albeit with a directlyhardcoded
    JNDI reference in it. However, if you hook up a standard JMS consumer tothat
    topic it will not consuem the message that is published!!! While thestats clock
    up at the console the message appears to go into a black hole. I canprovdie
    a stadnard consumer if you need one.
    I have the code working fine as-is in teh Sun Reference implementation soI presume
    these are bugs with WL6.0.
    Can anyone advise workarounds and/or fix the problem?

  • Calling stored procedure from session bean method

    I have a situation like this :
    I have one method on a stateless session bean (and I mark this method as container managed transaction). For database related stuff, I am not using entity beans, I am using my own layer of OR mapping. This method does a lot of stuff and it involves many trips to the database, as a result of which the performance is very poor. I have identified certain pieces of functionality from this method which I think can be moved to stored procedures, while some of the functionality can still remain in the session bean method. So my scenario is like this :
    session bean method start
    store some data in tables(using my OR layer)
    call the stored procedure
    session bean method end
    My question is :
    Will the data that I am storing in tables from within the session bean method, be available to the code executing inside stored proc.
    secondly, how do I sync the transcation which is being initiated by the container with the transaction under which the stored proc is executing or is it that the stored procedure code will also be executing under the container managed transcation.
    Thanks
    Vimal

    Hi Vimal,
    Will the data that I am storing in tables from within
    the session bean method, be available to the code
    executing inside stored proc.There's only one way to find out (isn't there?)
    secondly, how do I sync the transcation which is
    being initiated by the container with the transaction
    under which the stored proc is executing or is it
    that the stored procedure code will also be executing
    under the container managed transcation.Again, why not just "suck it and see!"
    [Or is there some reason why you can't?]
    As I interpret the EJB specification, if the transaction attribute for your session bean method is such that it starts a transaction, then that transaction will be terminated when the method completes -- and every operation that occurs within the framework of that method will be in the one transaction.
    In other words, your database stored procedure should execute within the same transaction as your O/R mapping layer.
    However, how OC4J behaves may not exactly follow what is written in the (EJB) specification. Hence I repeat, "try it and see for yourself".
    Put it this way: as far as I know, the only way that your stored procedure would NOT see the changes made by your O/R mapping layer is if they both executed in separate transactions and the O/R mapping layer did not commit its changes before the stored procedure began its execution.
    Hope this has helped.
    Good Luck,
    Avi.

  • Calling Data Control from Session bean

    Is it possible to use workshop data control from with in Session bean.

    If the client code is located in the same "deployment unit" (e.g. EAR
    file) as the EJBs, then you can pass the data by reference.
    Serialization is required when crossing between deployment units. This
    is required to support redeployment.
    Hyung-Jin Kim wrote:
    I recently downloaded WL6.0 and I noticed that when a
    session bean returns data to its client, the data is
    always serialized back the client -- EVEN it the client
    is on the same machine. Ideally, I would prefer that a
    reference to the data simply be returned to the client.
    Does the serialization occur because WL6.0 put session
    beans in its own ClassLoader or does the serialization occur
    because of the way WL6.0 compiles the RMI stubs? Thanks
    for your response.
    -hjk

  • Working list from Session Bean

    In a method of a session bean, I need to get the list of tasks of a user from the TaskManager service of BPEL. I can not find any sample in Web, so if anyone can help me, I appreciate it.
    I am using the JDeveloper 10.1.3.1.

    can u list the entire source for the method...

Maybe you are looking for

  • Windows 7 and Macbook Pro

    I have a 13 inch macbook pro that i got last month. I was wondering whether windows 7 will work smoothly on it or will it be slow putting in mind that it has 2 GB of ram and a 2.2 GHz processor Thank you

  • My macbook starts up windows but not osx

    So after doing the software update on my mac side, it all of a sudden stopped booting up. Just stuck in the grey apple logo screen. However, I am able to boot up in my windows partitioned side. Is there any way to fix this? Or has my macbook crashed

  • With Adobe cs6 trial, can I do splining and game modding?

    Just what the question says - is it possible? I am a beginner to both adobe as well as modding, so any help or advice will be greatly appreciated - Thanks.

  • EDI Formats

    Hello B2B Experts, Oracle B2B supports EDI feeds including 850,855,810 Does B2B supports these feeds 860(Change), 856(ASN), 820(PAY ADV), 824(Error Ack) ..? Any pointers available for this ? Thanks

  • Audio Monitoring

    Greetings, I am curious as i set up my new editing studio. I currently have two creative desktop surround sound speakers connected to my mac pro - the sound is pretty good. however as I grow with editing I'm curious about another audio monitoring opt