Beans & EJB - difference?

What is the difference (if any) between Java Beans and EJB, is the latter a mere extension of the former? I've heard that EJBs dont have much in common with Java Beans. is it so?
Thanks in advance

Hi,
You're right. There does not appear to be a lot of similarities. A straight javabean is really a class that has get and set methods. eg. getName() and setName().
Whereas an EJB has lots of different types.
Firstly, you have a choice of session beans and entity beans - the former could be identified as a client bean e,g, a [person] in the simplistic view; whereas an entity bean could be a database record/s relating to a query. This latter type can have persistence(session control) that is handled by a bean or handled by the server itself.
This is a simplistic approach, and you need to read a few tutorials and books to avoid all the wrong information that I am probably giving to you.
The other important difference is that an EJB cannot be directly implemented by a client interface. this means that there has to always be a specific correlation between a home and remote call through an instance of an enterprise java bean.
If you study a few simple examples of EJB, this will become apparently clear. There appears to be a standard way of writing simple EJBs which endorse this approach.
Good reading material is the tutorials that go with the J2EE documentation and also Java Server Pages - J2EE edition by Wrox Press. Also, www.theserverside.com holds an important source of info as do many of the SUN tutorials.
They all explain it a lot better than I do.
best kev

Similar Messages

  • JavaBeans and EJB Difference

    Hi Experts:
    Can anyone tell me DIFFERENCE between JAVABEANS and ENTERPRISE JAVABEANS? I am a newbie to JavaBean world. How do we know which one to use when?
    Also, any startup BASIC TUTORIAL Link would be appreciated.
    Thanks!

    A javabean is simply a class that, through established conventions, exposes certain elements as standard properties. See http://developer.java.sun.com/developer/onlineTraining/Beans/beans01/ and http://developer.java.sun.com/developer/onlineTraining/Beans/beans02/ for a tutorial. Javabeans are a common part of most java programming.
    An enterprise java bean (EJB) is a heavyweight, transactional, remotable component running in a managed "container." EJB has little or nothing to do with regular javabeans. Use EJBs to build web applications and web services with steep scalability, failover and transactional requirements. See http://www2.theserverside.com/books/masteringEJB/index.jsp for a lengthy and comprehensive tutorial.

  • Call stateless session bean EJB 2.0 from Webdynpro Java UI

    Hello,
    Can someone please tell me asto how to call a stateless session bean EJB 2.0 from Webdynpro Java UI?
    The NWDS version is 7.0.
    Thanks and Regards,
    Arya

    Hi Aryadipta
    Please check this pdfs
    https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b00917dc-ead4-2910-3ebb-b0a63e49ef10&overridelayout=true
    Steps for calling stateless session bean in Webdynpro java
    Go to NWDS -> open perspective ->j2ee
    select EJB Module Project ->create a project with name
    Open the Project -->RC on ejb-jar.xml -> Select new --> EJB
    Give name to EJB Bean (First letter should be in capital letters)
    select the type of bean as Stateless session bean and give the package name to store that EJB bean.
    After that Expand ejb-jar.xml and then select the <projectEJB> 
    Double click on this on method  tab double click you will get business method where we will create the methods for business logic
    Double click on projectEJB and then RC on bean tab and write required business logic in bean window as follows(based on requirement we will design a business logic).
    After writing the business logic go to project -> rebuild
    Till now we have created one EJB jar file
    then go to File-->Enterprise Application Project -->create a project (projectEAR)
    After creating a project click on next-> here we will have ear projects and then we select specific project required for our application.(here select projectEJB)
    After that Calculate EAR project will be available on j2ee explorer.
    Right click on <Bean> here
    select New->Web Service->give a name to webservice and select Default configuration type as simple SOAP
    -->click next -> Finish.
    That webservice and related are created in ejb-jar.xml .
    Expand the ejb-jar.xml.and double click on < webservice>
    RC ProjectEJB -> Build EJB Archive RC on CalculateEAR ->Build applicationarchive.
    Expand the projectEAR->RC on CalculateEAR.ear->Deploy to J2EE Engine
    Double click on calculateEAR.ear ->Webservice navigator tab ->we eill servers expand the node
    select the specific WebService  
    Here we test the webservice by click on Test and test it.
    After that go to Web dynpro perspective ->create one webdynpro Project and one component
    RC on model> Select import Web Service model(last)>give model name and package
    and select radio button as local file system or URL
    Go to WSnavigator->copy the WSDL path and paste it in model WSDL path and click on finish.
    from here onwards steps are same as that adaptive RFC model
    Hope it helps
    Thanks
    Tulasi Palnati
    Edited by: Tulasi Palnati on Aug 26, 2009 12:15 PM
    Edited by: Tulasi Palnati on Aug 26, 2009 12:43 PM

  • Insert data into table from JSP page using Entity Beans(EJB 3.0)

    I want to insert data into a database table from JSP page using Entity Beans(EJB 3.0).
    1. I have a table 'FRIENDS', (in Oracle 10g database).
    2. It has two columns, 'NAME' and 'CITY'. Both have datatype strings(varchar2).
    3. Now from a JSP page, having two textfields, 'NAME' and 'CITY', I want to insert data into table 'FRIENDS'.
    4. In between JSP and database is a Entity Bean(EJB 3.0) and a stateless session bean.
    5. I am using JDev as editor.
    Please provide me code ASAP or link with similar example.
    Thank you.
    Anurag

    Hi,
    I am also trying that scenario. So u can
    Post the jsp form data to a Servlet which will act as a Controller.
    In the servlet invoke the business method.
    Similar kind of app is in www.roseindia.net
    Hope this would help u.
    Meanwhile if u get any optimal solution, pls post it.
    Thanks,
    Happy Java Coding.

  • Entity Bean EJB 2.0 Deployment error

    Hi !!!
    I am new in EJB .
    I have developed an Entity Bean (EJB 2.0) and using IDE MyEclipse and JBoss Server.
    while I deploying the Application I getting the following Exceptions :
    --- MBeans waiting for other MBeans ---
    ObjectName: jboss.j2ee:service=EjbModule,module=EntityExample.jar
    State: FAILED
    Reason: org.jboss.deployment.DeploymentException: No abstract accessors for field named 'id' found in entity class account.AccountEJB
    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: jboss.j2ee:service=EjbModule,module=EntityExample.jar
    State: FAILED
    Reason: org.jboss.deployment.DeploymentException: No abstract accessors for field named 'id' found in entity class account.AccountEJB
    can any one give suggetion on it what i am doing incorrect.
    thanks in Advance

    There should be some error in looking up the Jndi..
    In weblogic server I have been using the following code:
         try
              Context ctx = getContext.getInitialContext();
              HelloHome home = (HelloHome)ctx.lookup("MyHello");
              Hello hello = home.create();
              System.out.println(hello.display());
         catch(Exception e)
              System.out.println("Error :");
              e.printStackTrace();
         static String user = null;
         static String password = null;
         static String url = "t3://localhost:7001";
         * Gets an initial context.
         * @return Context
         * @exception java.lang.Exception if there is
         * an error in getting a Context
         static public Context getInitialContext() throws Exception
              Properties p = new Properties();
              p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
              p.put(Context.PROVIDER_URL, url);
              if (user != null)
         System.out.println ("user: " + user);
         p.put(Context.SECURITY_PRINCIPAL, user);
                   if (password == null)
                        password = "";
         p.put(Context.SECURITY_CREDENTIALS, password);
    return new InitialContext(p);
    this works fine in weblogic..
    also check if ur classpath is ok..

  • Webllogic8to10migration-SAXValidationExc Couldnot locate bean ejb-jar.xml

    Please help me out here..
    Failed to parse descriptor at 'META-INF/weblogic-ejb-jar.xml' for module 'PAMaintenanceBean.jar': javax.xml.stream.XMLStreamException: weblogic.xml.process.SAXValidationException: Could not locate bean with ejb-name "PAMaintenance" in ejb-jar.xml
    ejb-jar.xml
    ==========
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
    <ejb-jar>
    <enterprise-beans>
    <session>
         <ejb-name>PAMaintenance</ejb-name>
         <home>com.bear.coreapps.pa.ejb.maintenance.PAMaintenanceHome</home>
         <remote>com.bear.coreapps.pa.ejb.maintenance.PAMaintenance</remote>
         <ejb-class>com.bear.coreapps.pa.ejb.maintenance.PAMaintenanceBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
         <method>
         <ejb-name>PAMaintenance</ejb-name>
         <method-intf>Remote</method-intf>
         <method-name>*</method-name>
         </method>
         <trans-attribute>Supports</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
    <ejb-jar>
    <enterprise-beans>
    <session>
         <ejb-name>PAFeatures</ejb-name>
         <home>com.bear.coreapps.pa.ejb.features.PAFeaturesHome</home>
         <remote>com.bear.coreapps.pa.ejb.features.PAFeatures</remote>
         <ejb-class>com.bear.coreapps.pa.ejb.features.PAFeaturesBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
         <env-entry>
         <env-entry-name>myString</env-entry-name>
         <env-entry-type>java.lang.String</env-entry-type>
         <env-entry-value>anything at all</env-entry-value>
         </env-entry>
    </session>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
         <method>
         <ejb-name>PAFeatures</ejb-name>
         <method-intf>Remote</method-intf>
         <method-name>*</method-name>
         </method>
         <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    weblogic-ejb-jar.xml
    ===============
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>PAMaintenance</ejb-name>
    <caching-descriptor>
         <max-beans-in-free-pool>100</max-beans-in-free-pool>
    </caching-descriptor>
    <enable-call-by-reference>false</enable-call-by-reference>
    <jndi-name>com.bear.coreapps.pa.ejb.maintenance.PAMaintenance</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>PAFeatures</ejb-name>
    <caching-descriptor>
         <max-beans-in-free-pool>100</max-beans-in-free-pool>
    </caching-descriptor>
    <jndi-name>statelessSession.PAFeaturesHome</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    my web.xml
    ========
    <ejb-ref>
    <ejb-ref-name>PAFeatures</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.bear.coreapps.pa.ejb.features.PAFeaturesHome</home>
    <remote>com.bear.coreapps.pa.ejb.features.PAFeatures</remote>
    <ejb-link>../PAFeaturesBean.jar#PAFeatures</ejb-link>
    </ejb-ref>
    <ejb-ref>
    <ejb-ref-name>PAMaintenance</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.bear.coreapps.pa.ejb.maintenance.PAMaintenanceHome</home>
    <remote>com.bear.coreapps.pa.ejb.maintenance.PAMaintenance</remote>
    <ejb-link>../PAMaintenanceBean.jar#PAMaintenance</ejb-link>
    </ejb-ref>
    Application.xml
    ===========
    <module>
    <ejb>PAFeaturesBean.jar</ejb>
    </module>
    <module>
    <ejb>PAMaintenanceBean.jar</ejb>
    </module>
    config.xml
    ===========
    <app-deployment>
    <name>emsApp</name>
    <target>mngCTK_dbctkapp01</target>
    <module-type>ear</module-type>
    <source-path>applications/emsApp</source-path>
    <sub-deployment>
    <name>/</name>
    <target>mngCTK_dbctkapp01</target>
    </sub-deployment>
    <sub-deployment>
    <name>PAMaintenanceBean.jar</name>
    <target>mngCTK_dbctkapp01</target>
    </sub-deployment>
    <sub-deployment>
    <name>PAFeaturesBean.jar</name>
    <target>mngCTK_dbctkapp01</target>
    </sub-deployment>
    <security-dd-model>DDOnly</security-dd-model>
    <staging-mode>nostage</staging-mode>
    </app-deployment>

    Hi,
    Nothing stands out as being configured incorrectly. I copy and pasted the descriptors below, put them in a jar file and ran weblogic.appc on it. The descriptors loaded properly and appc only complained that the EJB classes couldn't be found (as expected). Are you sure the weblogic-ejb-jar.xml containing the 'PAMaintenance' reference is in the same ejb-jar file as the ejb-jar.xml containing the 'PAMaintenance' definition? That's the only thing I can think of.
    - Matt

  • Error while calling a method on Bean (EJB 3.0)

    I am getting an error while calling a method on EJB. I am using EJB3.0 and my bean is getting properly deployed(i am sure b'cos i can see the successfullly deployed message). Can any body help me
    Error is -->
    Error while destroying resource :An I/O error has occured while flushing the output - Exception: java.io.IOException: An established connection was aborted by the software in your host machine
    Stack Trace:
    java.io.IOException: An established connection was aborted by the software in your host machine
    at sun.nio.ch.SocketDispatcher.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:33)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:104)
    at sun.nio.ch.IOUtil.write(IOUtil.java:75)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:302)
    at com.sun.enterprise.server.ss.provider.ASOutputStream.write(ASOutputStream.java:138)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
    at org.postgresql.PG_Stream.flush(PG_Stream.java:352)
    at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:159)
    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:70)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:482)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:461)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.rollback(AbstractJdbc1Connection.java:1031)
    at org.postgresql.jdbc2.optional.PooledConnectionImpl$ConnectionHandler.invoke(PooledConnectionImpl.java:223)
    at $Proxy34.close(Unknown Source)
    at com.sun.gjc.spi.ManagedConnection.destroy(ManagedConnection.java:274)
    at com.sun.enterprise.resource.LocalTxConnectorAllocator.destroyResource(LocalTxConnectorAllocator.java:103)
    at com.sun.enterprise.resource.AbstractResourcePool.destroyResource(AbstractResourcePool.java:603)
    at com.sun.enterprise.resource.AbstractResourcePool.resourceErrorOccurred(AbstractResourcePool.java:713)
    at com.sun.enterprise.resource.PoolManagerImpl.putbackResourceToPool(PoolManagerImpl.java:424)
    at com.sun.enterprise.resource.PoolManagerImpl.resourceClosed(PoolManagerImpl.java:393)
    at com.sun.enterprise.resource.LocalTxConnectionEventListener.connectionClosed(LocalTxConnectionEventListener.java:69)
    at com.sun.gjc.spi.ManagedConnection.connectionClosed(ManagedConnection.java:618)
    at com.sun.gjc.spi.ConnectionHolder.close(ConnectionHolder.java:163)
    at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.closeDatasourceConnection(DatabaseAccessor.java:379)
    at oracle.toplink.essentials.internal.databaseaccess.DatasourceAccessor.closeConnection(DatasourceAccessor.java:367)
    at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.closeConnection(DatabaseAccessor.java:402)
    at oracle.toplink.essentials.internal.databaseaccess.DatasourceAccessor.afterJTSTransaction(DatasourceAccessor.java:100)
    at oracle.toplink.essentials.threetier.ClientSession.afterTransaction(ClientSession.java:104)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.afterTransaction(UnitOfWorkImpl.java:1816)
    at oracle.toplink.essentials.transaction.AbstractSynchronizationListener.afterCompletion(AbstractSynchronizationListener.java:161)
    at oracle.toplink.essentials.transaction.JTASynchronizationListener.afterCompletion(JTASynchronizationListener.java:87)
    at com.sun.ejb.containers.ContainerSynchronization.afterCompletion(ContainerSynchronization.java:174)
    at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:467)
    at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:357)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3653)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1247)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:197)
    at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:110)
    at $Proxy84.addDepartment(Unknown Source)
    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:585)
    at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
    at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
    at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
    at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
    at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
    at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
    at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
    End of Stack Trace
    |#]
    RAR5035:Unexpected exception while destroying resource. To get exception stack, please change log level to FINE.
    EJB5018: An exception was thrown during an ejb invocation on [DepartmentSessionBean]
    javax.ejb.EJBException: Unable to complete container-managed transaction.; nested exception is: javax.transaction.SystemException
    javax.transaction.SystemException
    at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:452)
    at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:357)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3653)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1247)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:197)
    at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:110)
    at $Proxy84.addDepartment(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    Means theres an error in XML/ABAP conversion probably due a syntax error...
    Regards
    Juan

  • Problem calling a session bean (EJB 3.0)

    Hello,
    I'm new to netbeans and J2EE. I'm using NetBeans 5.5 Beta 2 and sun application server 9 pe.
    I created a new enterprise application and i'm trying to access a Session Bean (Remote and Stateless)
    from the app-client (outside the main class).
    This is the loockup method that was generated by the IDE (Enterprise Resources > Call enterprise bean):
    private ejb.SessionBeanDoenteRemote lookupSessionBeanDoenteBean() {
    try {
    javax.naming.Context c = new javax.naming.InitialContext();
    return (ejb.SessionBeanDoenteRemote) c.lookup("java:comp/env/ejb/SessionBeanDoenteBean");
    catch(javax.naming.NamingException ne) {
    java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne);
    throw new RuntimeException(ne);
    When I run the application and try to invoke the lookup method my application gets the following exception:
    SEVERE: exception caught
    javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/Se
    ssionBeanDoenteBean
    at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.
    java:751)
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j
    ava:156)
    at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:307
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at intensivecare.entrada.JDialogEntrada.lookupSessionBeanDoenteBean(JDia
    logEntrada.java:219)
    at intensivecare.entrada.JDialogEntrada.buttonMenuGravarActionPerformed(
    JDialogEntrada.java:79)
    at intensivecare.JDialogWizzard$2.jButtonGravarActionPerformed(JDialogWi
    zzard.java:178)
    at componentes.JTaskPanelMenu$3.actionPerformed(JTaskPanelMenu.java:54)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
    49)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2169)
    Please... can someone help me?

    The portable way to acquire the dependency is through java:comp/env or @EJB. Accessing the
    global namespace directly is not recommended. If you use an ejb-ref, you need to define it
    in the component environment within which you'll be looking up the dependency. So if you're
    looking it up from an Application Client, you'll need to define the ejb-ref in application-client.xml.
    Also, the ejb-ref-name is the portion of the string after java:comp/env. There is no automatic
    "ejb" appended to it. If you do ic.lookup("java:comp/env/foo"), your ejb-ref-name would be "foo".
    You can use @EJB but it can only be defined in certain managed classes such as the
    Application Client main class.
    You can find additional info in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Error while using sybase trigger with the CMP entity bean,ejb version 2.1

    Hi All,
    I am using ejb version 2.1 and using entity bean (Transaction required) ,i am trying to update data in sybase(ver 12.3) database table
    I am using session bean(Transaction required) to update the multiple entity beans in a while loop.It is working fine .But when i am trying to run it with the trigger which updates multiple tables in different sybase databases on update of each entity.Then it throws NoSuchEntityException and it rollback the whole transaction.
    My trigger has only few simple update statements and the trigger runs fine without my CMP entity bean.is the CMP does not support the update triggers in sybase or is it the problem with the transaction.
    Please help
    Thanks
    Anshu

    If you can have a look at a cmp example in the samples that ship with the server. My guess is that the weblogic-ejb-jar.xml file is missing the <persistence-use> element which for 810 would look like:
    <persistence>
    <persistence-use>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>7.0</type-version>
    <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
    </persistence-use>
    </persistence>
    I seem to recall that the elements might be slightly different in structure for the wls700 version of the DTD, so please check that (I cannot, I'm at home and don't have everything here).
    Give that a try and see if it doesn't solve your compilation failure.
    Also, the compilation should not be throwing a null pointer exception in a case like that, I consider that to be a bug.
    -thorick

  • Null Pointer Exception in Stateless Session Beans(EJB 3.0)

    I am executing a simple HelloUser example i code session bean interface and implementing session bean class in the EJB project.
    package ejb3inaction.ejb;
    import javax.ejb.Remote;
    @Remote
    public interface HelloUser {                                       
    public void sayHello(String name);
    package ejb3inaction.ejb;
    import javax.ejb.Stateless;
    @Stateless
    public class HelloUserBean implements HelloUser {                  
    public void sayHello(String name) {
    System.out.println("Hello " + name + " welcome to EJB 3 In Action!");
    And in the client project i code this class and add JAR file of the EJB project.
    package ejb3inaction.example;
    import javax.ejb.EJB;
    import ejb3inaction.ejb.*;
    public class HelloUserClient {
    @EJB
    private static HelloUser helloUser;
         public static void main(String[] args) {
    helloUser.sayHello("Curious George");
    System.out.println("Invoked EJB successfully .. see server console for output");
    I am using netbeans 6.0(10 M) and Sun Application server 9.
    it gives NullPointer Exception at the following line...
    helloUser.sayHello("Curious George");
    how i can resolve this error.
    regards,
    deemy

    Well, helloUser is just a null reference, you haven't created an instance of HelloUser to use, hence the NPE

  • Example of client/servelt calling an Entity Bean(EJB 2.0)

    Hi !!
    Can somebody give any code of servlet or client calling an entity bean...please give any sample code... I am getting error while calling an entity bean in Servlet....
    It says that the Jndi name not found
    SERVLET CODE----------
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import sfms.mtk.*;
    import sfms.sec.*;
    import java.util.*;
    public class TestServletExample extends HttpServlet
         SecDbSecUserHome home;
         public void init(ServletConfig config)throws ServletException{
         //Look up home interface
              try
                   Properties props = new Properties();
                   System.out.println("Looking for Jndi ----->>");
                   InitialContext ctx = new javax.naming.InitialContext();
                   home = (SecDbSecUserHome)javax.rmi.PortableRemoteObject.narrow(ctx.lookup("SecUserJndi"), SecDbSecUserHome.class);
                   System.out.println("Lookup is over ----->>");
              catch (Exception NamingException)
                   NamingException.printStackTrace();
         public void doGet (HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException
              MTKDataObject objDataObject = null;
              PrintWriter out;
              response.setContentType("text/html");
              String title = "EJB Example";
              out = response.getWriter();
              out.println("<HTML><HEAD><TITLE>");
              out.println(title);
              out.println("</TITLE></HEAD><BODY>");
              try
                   System.out.println("*************STARTING NOW*************");
                   Collection coll = home.findAllUsers();
                   Iterator i =coll.iterator();
                   while(i.hasNext())
                        SecDbSecUserRemote remote = (SecDbSecUserRemote)i.next();
                        System.out.println("User ID "+remote.getUserId());
                        System.out.println("FirstName "+remote.getFirstName());
              catch(Exception CreateException)
                        CreateException.printStackTrace();
              out.close();
         public void destroy()
              System.out.println("Destroy");
    javax.naming.NameNotFoundException: SecUserJndi not found
    <<no stack trace available>>
    *************STARTING NOW*************
    java.lang.NullPointerException
    at TestServletExample.doGet(TestServletExample.java:49)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.access$0(ApplicationFilterChain.java:197)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:368)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
    at java.lang.Thread.run(Thread.java:484)
    PLEASE DO REPLY ME BACK (ASAP)
    Bhumika

    There should be some error in looking up the Jndi..
    In weblogic server I have been using the following code:
         try
              Context ctx = getContext.getInitialContext();
              HelloHome home = (HelloHome)ctx.lookup("MyHello");
              Hello hello = home.create();
              System.out.println(hello.display());
         catch(Exception e)
              System.out.println("Error :");
              e.printStackTrace();
         static String user = null;
         static String password = null;
         static String url = "t3://localhost:7001";
         * Gets an initial context.
         * @return Context
         * @exception java.lang.Exception if there is
         * an error in getting a Context
         static public Context getInitialContext() throws Exception
              Properties p = new Properties();
              p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
              p.put(Context.PROVIDER_URL, url);
              if (user != null)
         System.out.println ("user: " + user);
         p.put(Context.SECURITY_PRINCIPAL, user);
                   if (password == null)
                        password = "";
         p.put(Context.SECURITY_CREDENTIALS, password);
    return new InitialContext(p);
    this works fine in weblogic..
    also check if ur classpath is ok..

  • Stateless Session Bean + EJB Question + Jboss

    Hello,
    If I have a stateless session bean on a linux machine and it works locally what do i need to do to access a method in the session bean from a remote windows machine.
    I would like to be able to execute my client jar file on a windows machine and have it access the jboss server on the linux machine. what do i need to do?
    i have the session bean working locally on both windows and linux machine. do i need to to have a JSP/Servlet to access the session bean? can the session bean not be accessed directly? what should my classpath look like? do I need to include extra jar files in my client jar file.?
    Thanks,
    Joyce

    Thanks guys for the help but I am still a little lost.
    My Client windows machine has the client jar file and all the other jar files. This is my client class
    package helloworld.client;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import java.util.Hashtable;
    import java.util.Properties;
    import helloworld.interfaces.HelloWorldHome;
    import helloworld.interfaces.HelloWorld;
    public class HelloClient
         public static void main(String[] args)
              Hashtable prop = new Hashtable();
              prop.put ("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
              prop.put ("java.naming.provider.url","jnp://172.16.220.160:1099");
              prop.put ("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
              try
                   Context ctx = new InitialContext(prop);
                   Object obj = ctx.lookup("ejb/helloworld/HelloWorld");
                   System.out.println(obj);
                   HelloWorldHome home = (HelloWorldHome)javax.rmi.PortableRemoteObject.narrow(obj, HelloWorldHome.class);
                   HelloWorld helloWorld = home.create();
                   String str = helloWorld.sayHelloEJB("JOYCE is COOL");
                   System.out.println(str);
                   helloWorld.remove();
              catch(Exception e)
                   e.printStackTrace();
    I get a NullPointer ie the home object is null. The IP address is the IP of the Linux machine that has Jboss running on.
    Questions are:
    1. Do I need to have Tomcat running on my client machine if I am to connect via HTTP? Does this alter my client code.?
    2. My JNDI lookup is what is causing the problem. Does my jboss.xml and my ejb-jar.jar look okay to you.
    jboss.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
    <jboss>
    <enterprise-beans>
    <session>
    <ejb-name>helloworld/HelloWorld</ejb-name>
    <jndi-name>ejb/helloworld/HelloWorld</jndi-name>
    </session>
    </enterprise-beans>
    <resource-managers>
    </resource-managers>
    </jboss>
    ejb-jar.jar
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar >
    <description>No Description.</description>
    <display-name>Generated by XDoclet</display-name>
    <enterprise-beans>
    <!-- Session Beans -->
    <session >
    <description><![CDATA[No Description.]]></description>
    <ejb-name>helloworld/HelloWorld</ejb-name>
    <home>helloworld.interfaces.HelloWorldHome</home>
    <remote>helloworld.interfaces.HelloWorld</remote>
    <ejb-class>helloworld.session.HelloWorldBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
    </session>
    <!--
    To add session beans that you have deployment descriptor info for, add
    a file to your merge directory called session-beans.xml that contains
    the <session></session> markup for those beans.
    -->
    <!-- Entity Beans -->
    <!--
    To add entity beans that you have deployment descriptor info for, add
    a file to your merge directory called entity-beans.xml that contains
    the <entity></entity> markup for those beans.
    -->
    <!-- Message Driven Beans -->
    <!--
    To add message driven beans that you have deployment descriptor info for, add
    a file to your merge directory called message-driven-beans.xml that contains
    the <message-driven></message-driven> markup for those beans.
    -->
    </enterprise-beans>
    <!-- Relationships -->
    <!-- Assembly Descriptor -->
    <assembly-descriptor >
    <!-- finder permissions -->
    <!-- transactions -->
    <!-- finder transactions -->
    </assembly-descriptor>
    </ejb-jar>
    Do I need RMI ? Do I need to concern myself with CORBA? All Im looking for is a step by step to understanding what I need to configure? Is their some way I can debug?
    Thanks alot,
    Joyce

  • Bean Managed Entity Beans(EJB) using Tangosol.

    I am trying to use Bean Managed Entity Beans using Tangosol Coherence.
    The entity bean is currently configured in the weblogic-ejb-jar.xml with:
    <max-beans-in-cache>200</max-beans-in-cache>
    In the public void ejbLoad() method, I am calling the Tangosol Cache to load the entity bean.
    If we have have more that 200 request coming at the same time, we get an OutOfMemoryError exception.
    Is there anyway to overcome this limitation by somehow having the ejb cache to use the tangosol cache?
    Thanks for any help in advance.
    Krishan

    So far, it's not immediately obvious to us what the exact problem is that you are seeing. It sounds like the VM would be using at least 200MB just for the application server's own internal cache, for example, and that you are also using Coherence within the application server to provide additional caching.
    If possible, we should set up a phone call with you and your team, and we could get an engineer from our end to walk through your specific use case with you, so that we could understand what the exact technical challenge(s) is(are) in this particular application.
    Peace.
    p.s. You can email [email protected] directly to schedule a call.

  • Extend session beans - EJB 2.0

    Hi there,
    I am new to EJB world, but I've to reuse some functionality of an existing stateful session EJB. I am thinking about extending the existing EJB to create my own stateless session bean (note: stateless as I don't have anything to do with a conversational state. It is just one operation that I am going to expose to client code). The EJB I am planning to create will reside in the same JVM as that of the existing EJB.
    Is this a good approach? How to go about it? Are they any patterns around reusing EJB methods in other EJBs without lookups as those methods I am interested in reusing are not part of the home interface of the existing bean.
    I wish I could refactor the existing EJB to take out the methods that I need, but it is not an option for me.
    Thanks a lot and I appreciate any inputs around this.

    user1364272 wrote:
    Is this a good approach? How to go about it? Are they any patterns around reusing EJB methods in other EJBs without lookups as those methods I am interested in reusing are not part of the home interface of the existing bean.Sounds to me like those methods should be in a separate POJO class you can reuse wherever you want.

  • How to use jta in toplink and stateless session bean EJB 3.0?

    I have an application with techologies jsf,stateless session bean, adf, toplink
    generated by toplink workbench.
    In web side ı want to use two methods in stateless session bean which are updated
    different tables. I call these methods in my page backing bean.
    I also want to JTA in web side. My first methods is done correctly, but second method has an error. I wanto to rollback all transaction.
    How can ı do that? with using JTA in Toplink...

    Yuichi
    Did you manage to solve this?  I'm doing something similar and seeing the same problem, although they're up to 7.3 SP7.
    Any help greatly appreciated.
    Lewis

Maybe you are looking for

  • Pushbutton not holding sy-ucomm

    I have 2 pushbuttons on my screen using screen painter. But when I debug they dont hold sy-ucomm or ok_code. DEL and CLR are pushbuttons but the  code is not working because they dont hold sy-ucomm value. However the other buttons are working as they

  • Movie syncs but no audio

    I can synce movies but have no sound. Does anyone know how to fix this?

  • Can i connect an external 3tb hdd to my mac mini 2011

    I think the title discribes my problem prety well, please be sure that your awnsers are tested .

  • Mixing level based measures issue

    Hi experts I have a geography dimension with the following hierarchy WW/Country/store. I created 2 level based measures using as source a measure called 'sales': level based measure 1: store sales share of WW (it shows for every store his contributio

  • Delete the table  entries on db2

    Hi,    when iam applying pathces iam getting dump,i want to delete the entires on pat01 table,whats the command to see the tables and delete the entry on pat01,02,03 tables. Thanku