Entity bean (ejb 3.0) refactoring problem

I didn't find a better method than regenerating an entity bean after modifying the table definition and renaming the class after deleting the old one.
I'm not sure i can delete the old class representing the entity bean before regenerating it without any effects into the others entity beans.
It work fine but still a little problem. The refactoring process didn't change the name of the entity bean into the select clauses into queynamed injection.

I am facing a similar problem. Does JDeveloper 10g (10.1.3.3.0) provide an automatic process to update an Entity Bean definition when the underlying database table definition changes?
I also noticed that for JDeveloper to create all the relationships (i.e. @OneToMany, @ManyToOne) between multiple Entity beans, I need to create all the Entity beans together in one pass using the wizard. If two entities depend on each other, and not created together, JDeveloper will not create the relationships between them. Is there a way around that?
Thank you

Similar Messages

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

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

  • 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

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

  • Entity beans not loaded due to problem loading WebLogic_RDBMS.jar dynamically

    Hi,
    I'm new to WebLogic so bear with me! When I start WebLogic (using
    Microsofts SDK for Java 4.0), all me session beans load up fine, but none of
    my entity beans load. The error I get for each is:
    [EJB]: Server cannot load: d:\weblogic\lib\persistence\WebLogic_RDBMS.jar
    dynamically. Attempting to load from classpath
    ... and then it goes on to say that it could not deploy the entity bean jar
    file giving a list of possible reasons. I'm guessing that the problem stems
    from the fact that the persistence jar file could not be loaded (correct me
    if I'm wrong!).
    Has anyone come across this before? I have included the WebLogic_RDBMS.jar
    file in my classpath when I start WebLogic to see if this would help but to
    no avail.
    Any help would be really appreciated.
    Thanks,
    Ciaran

    Please see my response in the ejb newsgroup.
    -- Rob
    Ciaran Diver wrote:
    >
    Hi,
    I'm new to WebLogic so bear with me! When I start WebLogic (using
    Microsofts SDK for Java 4.0), all me session beans load up fine, but none of
    my entity beans load. The error I get for each is:
    [EJB]: Server cannot load: d:\weblogic\lib\persistence\WebLogic_RDBMS.jar
    dynamically. Attempting to load from classpath
    ... and then it goes on to say that it could not deploy the entity bean jar
    file giving a list of possible reasons. I'm guessing that the problem stems
    from the fact that the persistence jar file could not be loaded (correct me
    if I'm wrong!).
    Has anyone come across this before? I have included the WebLogic_RDBMS.jar
    file in my classpath when I start WebLogic to see if this would help but to
    no avail.
    Any help would be really appreciated.
    Thanks,
    Ciaran--
    Coming Soon: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnweblogic.com

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

  • Entity beans(EJB 3.0) replication in IAS 10.1.3

    Hi,
    I have a application with webservices, having a few stateless session beans and a few entity beans. The application has to be deployed in a grid environment, on 2 machines.
    My problem is that a change in an entity needs to be replicated on both machines. Right now, with the application deployed on 2 machines, in a load balanced non-cluster environment, I have stale data. I have reviewed the option of cache coordination, but the toplink essentials don't have this feature.
    As a temp solution, one of the machines was stopped. Another option is to disable the entity beans cache completely, but that's not what I'm looking for.
    I have done some digging in the documentation, and it's clear that stateful beans can be replicated in a clustered environment. In this configuration, are the entity beans replicated too?

    Thanks for your reply. I'm actually interested in the entities, not the web session. I need to make sure that the entities cache stays synchronized between the nodes.
    Example:
    I have entity "customer" for example.. I do an update from one of the nodes, changing the customer name, and do commit. This happens in node 1. I want to make sure that the node 2 knows this happened.

  • CMP Entity Bean with ejb-ql finder methods and INFORMIX database

    Hi,
    I have some CMP Entity Beans with finder methods defined in ejb-ql. In my ejb-jar, within <entity> definitions I have something like:
        <entity>
          <abstract-schema-name>BeanName</abstract-schema-name>
          <cmp-field><field-name>fieldOne</field-name></cmp-field>
          <cmp-field><field-name>fieldTwo</field-name></cmp-field>
          <query>
            <query-method>
              <method-name>findAll</method-name>
              <method-params></method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM BeanName o</ejb-ql>
          </query>
        <entity>
    And in persistent.xml:
    <db-properties>
         <data-source-name>datasource_name</data-source-name>
    </db-properties>
    <entity-bean>
         <ejb-name>BeanName</ejb-name>
         <table-name>table_name</table-name>
         <field-map key-type="NoKey">
         <field-name>fieldOne</field-name>
         <column><column-name>column_one</column-name></column>
          </field-map>
         <field-map key-type="NoKey">
         <field-name>fieldTwo</field-name>
         <column><column-name>column_two</column-name></column>
          </field-map>
          <finder-descriptor>
              <method-name>findAll</method-name>
              <method-params/>
         </finder-descriptor>
    Once deployed, on server side, I can found a java source file (with corresponding compiled class file) in path:
    j2ee/cluster/server0/apps/companyName/MyEARApp/EJBContainer/temp/temp38837373733/route/to/package/
    with names:
    BeanName0_0pm.java
    BeanName0_0PM.class
    and the generated java file contains this code:
      public java.util.Enumeration ejbFindAll() throws javax.ejb.FinderException, javax.ejb.EJBException  {
        TransactionContext tc = pm.getTransactionContext();
        Connection conn = null;
        PreparedStatement pSt = null;
        ResultSet ejb_rs = null;
        int status = javax.transaction.xa.XAResource.TMSUCCESS;
        try {
          conn = pm.getConnectionForFindMethod();
          pSt = conn.prepareStatement("SELECT \"O\".\"COLUMN_ONE\",\"O\".\"COLUMN_TWO\", FROM \"TABLE_NAME\" \"O\"");
          ejb_rs = pSt.executeQuery();
    I'm trying to call this method but it throws a SQLException when preparing the statement.
    It seems that Informix does not like this SQL syntax because of upper case names, doble quotes on table alias, or something else.
    When editing persistent.xml in netweaver, I can define the element <datasource-vendor> as ORACLE, SAPDB, MS_SQL_SERVER, DB2_UDB_AS400 or DB2_UDB_OS390 but INFORMIX is not an accepted value.
    Is there any way to define how this SQL query is build?
    Thanks in advance.

    The return type of the finder method defined in the remote home interface is either the entity bean's remote interface or a collection of objects implementing the entity bean's remote interface. The return type of the finder method defined in the local home interface is either the entity bean's local interface or a collection of objects implementing the entity bean's local interface

  • Problem in creating CMP Entity Bean - Pls Help

    I am trying to build one simple project having jsps to get connected to CMP Entity Bean.
    But while deploying I am getting the following error...
    Nov 15, 2004 10:59:09... Info: End of log messages of the target system.
    Nov 15, 2004 10:59:09... Info: ***** End of SAP J2EE Engine Deployment (J2EE Application) *****
    Nov 15, 2004 10:59:09... Error: Execution of deployment action for "EntityCMPAppln" aborted:
    Caught exception during application deployment from SAP J2EE Engine's deploy service:
    java.rmi.RemoteException: Error occurred while starting application bcone.com/EntityCMPAppln and wait.
    Reason: Complex error : server ID 6155350:Application bcone.com/EntityCMPAppln cannot be started, because it has hard reference to resource CONFIG_DB with type javax.sql.DataSource, but it is not active on the server.
    (message ID: com.sap.sdm.serverext.servertype.inqmy.extern.EngineApplOnlineDeployerImpl.performAction(DeploymentActionTypes).REMEXC)
    Nov 15, 2004 10:59:09... Error: Deployment NOT successful for EntityCMPAppln
    Nov 15, 2004 10:59:09... Info: SDM configuration: Do not automatically start/stop J2EE Engine. Do not restore state of J2EE Engine now.
    Nov 15, 2004 10:59:09... Error: -
    At least one of the Deployments failed -
    Nov 15, 2004 11:05:16... Info: Request for Logon as admin accepted
    ===========================================
    Nov 15, 2004 11:05:08... Info: =   Starting to execute command 'remotegui'   =
    Nov 15, 2004 11:05:08... Info: ===============================================
    Nov 15, 2004 11:05:10... Info: SDM started successfully.
    Please tell me how to activate the CONFIG_DB reference in database. Or what Extra I have to do to run this example.
    Regards,
    Vivek Ojha

    Dear Benny,
    The code of the required files is pasted below....
    Application.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
                                 "http://java.sun.com/dtd/application_1_3.dtd">
    <application>
        <display-name>EntityCMPAppln</display-name>
        <description>EAR description</description>
        <module>
            <ejb>EntityCMPEjb.jar</ejb>
        </module>
        <module>
            <web>
                <web-uri>EntityCMPWeb.war</web-uri>
                <context-root>/student</context-root>
            </web>
        </module>
    </application>
    Application-j2ee-engine.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application-j2ee-engine SYSTEM "application-j2ee-engine.dtd">
    <application-j2ee-engine>
         <provider-name>bcone.com</provider-name>
         <fail-over-enable
              mode="disable"/>
    </application-j2ee-engine>
    data-source-aliases.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE data-source-aliases SYSTEM "data-source-aliases.dtd">
    <data-source-aliases>
         <aliases>
              <data-source-name>${com.sap.datasource.default}</data-source-name>
              <alias>STUDENTDB</alias>
         </aliases>
    </data-source-aliases>
    ejb-j2ee-engine.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-j2ee-engine SYSTEM "ejb-j2ee-engine.dtd">
    <ejb-j2ee-engine>
         <enterprise-beans>
              <enterprise-bean>
                   <ejb-name>StudentBean</ejb-name>
                   <resource-ref>
                        <res-ref-name>jdbc/STUDENTDB</res-ref-name>
                        <res-link>STUDENTDB</res-link>
                   </resource-ref>
                   <entity-props/>
              </enterprise-bean>
         </enterprise-beans>
    </ejb-j2ee-engine>
    ejb-jar.xml
    <?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>EJB JAR description</description>
         <display-name>EJB JAR</display-name>
         <enterprise-beans>
              <entity>
                   <ejb-name>StudentBean</ejb-name>
                   <home>com.bcone.ejb.StudentHome</home>
                   <remote>com.bcone.ejb.Student</remote>
                   <ejb-class>com.bcone.ejb.StudentBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.String</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>StudentBean</abstract-schema-name>
                   <cmp-field>
                        <field-name>studentId</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>lname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>standard</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>fyear</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>fname</field-name>
                   </cmp-field>
                   <primkey-field>studentId</primkey-field>
                   <resource-ref>
                        <res-ref-name>jdbc/STUDENTDB</res-ref-name>
                        <res-type>javax.sql.DataSource</res-type>
                        <res-auth>Container</res-auth>
                   </resource-ref>
              </entity>
         </enterprise-beans>
    </ejb-jar>
    persistent.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE persistent-ejb-map SYSTEM "persistent.dtd">
    <persistent-ejb-map>
         <locking
              type="Table"/>
         <db-properties>
              <data-source-name>CONFIG_DB</data-source-name>
              <database-vendor
                   name="SAPDB"/>
         </db-properties>
         <entity-beans>
              <entity-bean>
                   <ejb-name>StudentBean</ejb-name>
                   <table-name>TMP_STUDENTNEW</table-name>
                   <field-map
                        key-type="PrimaryKey">
                        <field-name>studentId</field-name>
                        <column>
                             <column-name>STUDENTID</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>lname</field-name>
                        <column>
                             <column-name>LNAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>standard</field-name>
                        <column>
                             <column-name>STANDARD</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>fyear</field-name>
                        <column>
                             <column-name>FYEAR</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>fname</field-name>
                        <column>
                             <column-name>FNAME</column-name>
                        </column>
                   </field-map>
              </entity-bean>
         </entity-beans>
         <relationships/>
    </persistent-ejb-map>
    StudentBean.java
    package com.bcone.ejb;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    import javax.ejb.RemoveException;
    import javax.ejb.CreateException;
    @abstractSchemaName StudentBean
    @cmpVersion 2.x
    @ejbHome <{com.bcone.ejb.StudentHome}>
    @ejbPrimaryKey <{java.lang.String}>
    @ejbRemote <{com.bcone.ejb.Student}>
    @hasSimplePK true
    public abstract class StudentBean implements EntityBean {
         public void ejbLoad() {
         public void ejbStore() {
         public void ejbRemove() throws RemoveException {
         public void ejbActivate() {
         public void ejbPassivate() {
         public void setEntityContext(EntityContext context) {
              myContext = context;
         public void unsetEntityContext() {
              myContext = null;
         private EntityContext myContext;
    @primKeyField
         public abstract String getStudentId();
         public abstract void setStudentId(String studentId);
         public abstract String getLname();
         public abstract void setLname(String lname);
         public abstract String getFname();
         public abstract void setFname(String fname);
         public abstract String getStandard();
         public abstract void setStandard(String standard);
         public abstract String getFyear();
         public abstract void setFyear(String fyear);
    Create Method.
         public String ejbCreate(
              String studentId,
              String fname,
              String lname,
              String standard,
              String fyear)
              throws CreateException {
              setStudentId(studentId);
              setFname(fname);
              setLname(lname);
              setStandard(standard);
              setFyear(fyear);
              return null;
    Post Create Method.
         public void ejbPostCreate(
              String studentId,
              String fname,
              String lname,
              String standard,
              String fyear) {
              // TODO : Implement
    StudentData.java
    Created on Nov 14, 2004
    To change the template for this generated file go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    package com.bcone.data;
    @author Administrator
    To change the template for this generated type comment go to
    Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    public class StudentData {
         private String studentId;
         private String fname;
         private String lname;
         private String standard;
         private String fyear;
    @return
         public String getFname() {
              return fname;
    @return
         public String getFyear() {
              return fyear;
    @return
         public String getLname() {
              return lname;
    @return
         public String getStandard() {
              return standard;
    @return
         public String getStudentId() {
              return studentId;
    @param string
         public void setFname(String string) {
              fname = string;
    @param string
         public void setFyear(String string) {
              fyear = string;
    @param string
         public void setLname(String string) {
              lname = string;
    @param string
         public void setStandard(String string) {
              standard = string;
    @param string
         public void setStudentId(String string) {
              studentId = string;
    student.jsp
    <%@ page language="java" %>
    <html>
         <head>
              <title>
                   Title
              </title>
         </head>
         <body>
              <form method="POST" action="WEBBOT-SELF" name="Student" onSubmit="">
      <!--webbot bot="SaveResults" startspan U-File="_private/form_results.txt"
      S-Format="TEXT/CSV" S-Label-Fields="TRUE" ><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!webbot
      bot="SaveResults" endspan -->
      <br>
      <a href="/student/manageStudent.jsp?action=add" method="post"> Create </a>   
      <a href="/student/manageStudent.jsp?action=modify" method="post"> Modify </a>   
      <a href="/student/manageStudent.jsp?action=delete" method="post"> Delete </a>
      <br><br>
      <table border="1" width="32%">
        <tr>
          <td width="39%">Student ID </td>
          <td width="61%"><input type="text" name="studentId" size="20"></td>
        </tr>
        <tr>
          <td width="39%">First Name</td>
          <td width="61%"><input type="text" name="fname" size="20"></td>
        </tr>
        <tr>
          <td width="39%">Last Name</td>
          <td width="61%"><input type="text" name="lname" size="20"></td>
        </tr>
        <tr>
          <td width="39%">Standard</td>
          <td width="61%"><input type="text" name="standard" size="20"></td>
        </tr>
        <tr>
          <td width="39%">Fiscal Year</td>
          <td width="61%"><input type="text" name="fyear" size="20"></td>
        </tr>
        <tr>
          <td width="39%" align="center"><input type="submit" value="Submit" name="submit"></td>
          <td width="61%" align="center"><input type="reset" value="Reset" name="reset"></td>
        </tr>
      </table>
    </form>
         </body>
    </html>
    mamageStudent.jsp
    <%@ page language="java"
    import="javax.naming.,java.sql.,javax.sql,com.bcone.ejb."
    %>
    <html>
         <head>
              <title>
                   Manage Student
              </title>
         </head>
         <body>
              <h1>
              </h1>
    <jsp:useBean id="stu" class="com.bcone.data.StudentData" ></jsp:useBean>
    <jsp:setProperty name="stu" property="*" />
    <%
    try {
         InitialContext ctx = new InitialContext();
         StudentHome home = (StudentHome) ctx.lookup("java:comp/env/StudentBean");
         String str = request.getParameter("action");
         if("action".equals(str)) {
              Student rem = home.create(remote.setFname(stu.getStudentId(),stu.getFname(),stu.getLname(),stu.getStandard(),stu.getFyear());
              out.println(stu.getStudentId() + "Student Created");
         } else if ("modify".equals(str)) {
              Student remote  = home.findByPrimaryKey(stu.getStudentId());
              remote.setFname(stu.getFname());
              remote.setFname(stu.getLname());
              remote.setFname(stu.getStandard());
              remote.setFname(stu.getFyear());
              out.println(stu.getStudentId() + "Student modified");
         } else if ("delete".equals(str)) {
              Student stu1  = home.findByPrimaryKey(stu.getStudentId());
              stu1.remove();
              out.println(stu.getStudentId() + "Student deleted");
    } catch (Exception e) {
         out.println("Exception e"+e.toString());
    %>
         </body>
    </html>
    Regards,
    Vivek Ojha

  • Container Managed Entity Beans and Client Identifier in Oracle

    Is it possible to use Container Managed Entity Beans (EJB with CMP)
    in a way that the Oracle database sessions still know the
    individual Client Identifiers of the actual users
    (not just the Identifier of the proxy user defined in the
    Connection Pool)?
    If Yes: How?
    If No: The consequence would be that the
    technologies EJB with CMP cannot be user together with
    Oracle Virtual Private Databases (VPN) because VPN requires
    some kind of Client Identifier.
    I am grateful for any hint.
    Regards,
    Martin Siepmann
    +49 (0)163 / 7765328

    Not quite an auto-incrementing PK, but it is managed by the container. the following is from the turorial
    Generating Primary Key Values
    For some entity beans, the value of a primary key has a meaning for the business entity. For example, in an entity bean that represents a phone call to a support center, the primary key might include a time stamp that indicates when the call was received. But for other beans, the key's value is arbitrary--provided that it's unique. With container-managed persistence, these key values can be generated automatically by the EJB container. To take advantage of this feature, an entity bean must meet these requirements:
    * In the deployment descriptor, the primary key class is defined as a java.lang.Object. The primary key field is not specified.
    * In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object.
    * In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object.
    In these entity beans, the primary key values are in an internal field that only the EJB container can access. You cannot associate the primary key with a persistent field or any other instance variable. However, you can fetch the bean's primary key by invoking the getPrimaryKey method, and you can locate the bean by invoking its findByPrimaryKey method.
    Maybe that is good enough
    christina

  • Problem creating EJB 3.0 Entity bean in JDeveloper

    Hello all,
    I trying to create my first entity bean in JDeveloper.
    JDevelper create the entity bean with the code below:
    package model;
    import java.io.Serializable;
    import javax.persistence.Entity;
    @Entity
    public class BatchSettlementT implements Serializable {
    public BatchSettlementT() {
    The problem is that JDeveloper don't find the import command import javax.persistence.Entity;
    What am I doing wrong?
    I'm using JDeveloper Studio Edition Version 10.1.3.1.0.3914.
    My libraries are:
    - TopLink
    - Oracle XML Parser 2
    - EJB 3.0
    - Toplink Essentials JPA
    - J2EE
    Thanks in advance.

    It's very strange, when I type import.javax. in my class there is no persistence package available, do you have any idea what's wrong.
    I did set the technology scope to EJB either.
    Thanks!

  • Problem with ejb 3.0 entity beans with manyToMany relationship

    Hello everyone!
    I am using struts 1.2.9 and java ee 5 sdk update 2 for my enterprise application. Besides others i have these entity beans Targetgroup.java and City.java, (i would upload file but i do not know how:)
    with manytomany relationship with join table.
    when user updates Targetgroup, by clicking on web page with checkboxes and textfields, struts dispatch action calls following method stateless bean:
    public void update(String firmId, String targetgroupId, String newGender, String newMinYearsOld, String newMaxYearsOld, String[] newCities) {
    TargetgroupPK pkForUpdate = new TargetgroupPK(targetgroupId, firmId);
    Targetgroup targetgroupForUpdate = find(pkForUpdate);
    targetgroupForUpdate.setGender(newGender);
    targetgroupForUpdate.setMinyearold(Integer.parseIn t(newMinYearsOld));
    targetgroupForUpdate.setMaxyearold(Integer.parseIn t(newMaxYearsOld));
    //pronalazenje gradva za koje je vezana ciljna grupa
    Collection<City> newCitiesCollection = new ArrayList<City>();
    for(int i = 0; i < newCities.length; i++){
    String tmp_city_name = newCities;
    City city_obj = cityFacade.find(tmp_city_name);
    newCitiesCollection.add(city_obj);
    targetgroupForUpdate.setCityidCollection(newCities Collection);
    parameter newCities represents names of cities which user checked on his update page. When the page is showen to him some cities are allready check because they were connected with Targetgruoup when it was created (targetgroup).
    this code throws following exception:
    [#|2007-07-26T12:13:36.993+0200|SEVERE|sun-appserver-pe9.0|javax.enterprise.system.container.web|_Threa dID=16;_ThreadName=httpWorkerThread-8080-0;_RequestID=f79d9c50-86b0-4b6c-96ab-97956dfb39c1;|StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
    javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
    javax.transaction.RollbackException: Transaction marked for rollback.
    at
    .com.sun.enterprise.web.connector.grizzly.WorkerTh read.run(WorkerThread.java:75)
    javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
    at com.sun.ejb.containers.BaseContainer.completeNewTx (BaseContainer.java:3659)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx( BaseContainer.java:3431)
    at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:1247)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:1 92)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dlerDelegate.invoke(EJBLocalObjectInvocationHandle rDelegate.java:71)
    at $Proxy149.update(Unknown Source)
    at audiotel.sms.actions.backoffice.TargetgroupDispatc hAction.updateOrDelete(TargetgroupDispatchAction.j ava:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java:270)
    at org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:187)
    at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:431)
    at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:236)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
    com.sun.enterprise.web.connector.grizzly.WorkerThr ead.run(WorkerThread.java:75)
    |#]
    exceprion is throwen ONLY when in parameter newCities are city names allready connected to Targetgroup. when NewCities contains names of
    City objects which are not connected to Targetgroup it works fine, but it's of no use for me, because user must be able to add or remove certian cities from relaionship with Targetgroup. I think it's because there are rows in join table that contain primary keys of city and targetgroup which are connected so perisistence manager cann't write them again.
    i thought it was going to figure it out by itself, and only update those rows.
    Does anyone know what is the problem and solution?
    Thanks! (forgive my spelling errors :)

    solved the problem!
    I moved code from sesion bean to struts action as follows:
    CityFacadeLocal cityFacade = lookupCityFacade();
    //prikupljanje novih podataka o ciljnoj grupi
    String newGender = ctf.getGender();
    String newMaxYears = ctf.getMaxyears();
    String newMinYears = ctf.getMinyears();
    String[] newSelectedCities = ctf.getSelectedCities();
    //niz imena gradova se prevodi u kolekcju objekata City
    Collection<City> newCitiesObjCollection = new Vector<City>();
    for(int i = 0; i < newSelectedCities.length; i++){
    String tmpCityName = newSelectedCities;
    City tmpCityObj = cityFacade.find(tmpCityName);
    newCitiesObjCollection.add(tmpCityObj);
    //setovanje novih podataka
    targetgroupForUD.setGender(newGender);
    targetgroupForUD.setMinyearold(Integer.parseInt(newMinYears));
    targetgroupForUD.setMaxyearold(Integer.parseInt(newMaxYears));
    targetgroupForUD.setCityidCollection(newCitiesObjCollection);
    //pozivanje update metdoe u session beany
    targetgroupFacade.edit(targetgroupForUD);
    //korisnik se vraca na stranu sa svim postojecim ciljnim grupama
    forward = mapping.findForward("backend.targetgroups");
    and now it works fine. I guess probelm was same transaction scope for Targetgroup and City entities. Now when they are separated it works.
    Thanks!

  • Problems accessing tables in oracle database with ejb entity bean

    I have created a simple server application that uses an entity bean (version 2.0) for an existing table in oracle database, and a session bean that is used as an outside interface for performing operations on that table.
    after deploying the server and client application the client attempts to perform an operation with the session bean remote interface it obtained.
    The session bean uses a locale interface to communicate with the entity bean, but when it tries to use its methods (create, findByXXX) it always get the following Exception: java.sql.SQLException: ORA-00942: table or view does not exist.
    the table of course exists, and the username password I'm using has all the permissions needed for this table.
    note - I'm using the Forte enterprise edition 4.0 as developer tool.
    I'll be glad to get some help.
    Here is the full stack trace of the exception:
    javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-00942: table or view does not exist
    javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-00942: table or view does not exist
    java.sql.SQLException: ORA-00942: table or view does not exist
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1674)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:314)
    at com.sun.ejb.persistence.SQLEngine.ejb20Finder(SQLEngine.java:226)
    at com.sun.ejb.persistence.PartitionImpl.ejbFinder(PartitionImpl.java:736)
    at com.cti2.telco.core.ejb.entity.userInfo.UserInfoEJB_PM.ejbFindByEmail(UserInfoEJB_PM.java:393)
    at com.cti2.telco.core.ejb.entity.userInfo.UserInfoEJB_PM_LocalHomeImpl.findByEmail(UserInfoEJB_PM_LocalHomeImpl.java:64)
    at com.cti2.telco.core.ejb.UserManagerEJB.authenticate(UserManagerEJB.java:77)
    at com.cti2.telco.core.ejb.UserManagerEJB.authenticate(UserManagerEJB.java:68)
    at com.cti2.telco.core.ejb.UserManagerEJB_EJBLocalObjectImpl.authenticate(UserManagerEJB_EJB
    LocalObjectImpl.java:63)
    at com.cti2.telco.core.ejb.dispatch.TelcoFacadeEJB.userLogin(TelcoFacadeEJB.java:80)
    at com.cti2.telco.core.ejb.dispatch.TelcoFacadeEJB_EJBObjectImpl.userLogin(TelcoFacadeEJB_EJBObjectImpl.java:24)
    at com.cti2.telco.core.ejb.dispatch._TelcoFacadeEJB_EJBObjectImpl_Tie._invoke(Unknown Source)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:519)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:204)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:112)
    at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:273)
    at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
    at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)
    ...

    Well it seems like the problems has a simple explanation. The Forte assigns a default table name (<entityName>EJBTable) when creating an entity bean from an existsing table in DB (which is not the same as the one it was created from !!!). Also, for reason unknown, when you deploy these entity beans, it doesn't even create the new table under its new name (even if instructed to).
    So using the Forte we managed to use successfuly only entity beans that were created "from scretch" (when deployed their tables are created).
    Does anyone know how to change the default name the Forte uses, and make it work properly with entity beans created from an existsing table (without going over the xml's) ?

  • Problems accessing ejb 3.0 entity bean from project

    I have written some code using ejb 3.0 and was previously accessing the entity bean without problem when both ejbs and the accessing code were in the same project. However I have moved the accessing code into a different project within the same application and now when the code tries to accessing the entity bean I get the following error:
    com.colwilson.web.ingestion.IdentifiedException: java.lang.ClassCastException: __Proxy3
         at com.colwilson.web.ingestion.IngestionHandler.recordArrived(IngestionHandler.java:140)
         at com.colwilson.web.ingestion.IngestionHandler.main(IngestionHandler.java:52)
    Caused by: java.lang.ClassCastException: __Proxy3
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.getFreshObject(StatelessSessionRemoteInvocationHandler.java:21)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.getReplacementObject(RecoverableRemoteInvocationHandler.java:64)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.handleRecovery(RecoverableRemoteInvocationHandler.java:41)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:30)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.mergeEntity(Unknown Source)
         at com.colwilson.web.ingestion.IngestionHandler.recordArrived(IngestionHandler.java:137)
         ... 1 more
    Now, of course I could move the code back into the same project, but as I understand it that is just the point of ejbs. I'm looking up the entity bean thus:
    final Context context = InitialContext();
    ingestionSessionEJB =
    (IngestionSessionEJB)context.lookup("IngestionSessionEJB");
    It may be true that I don't understand the way lookup works, but to be honest I can't find the docs that explain what I've got wrong.
    Please help.

    hi
    Double Click on the project which is goin to use the project which contains bean from the Application Navigator window. The project properties window will open. Choose the "Dependencies" item from left panel. click on the radio "User Project Settings" and select another project which contain ejb which you're goin to access...
    Best Of Luck
    Ravi A. Trivedi

Maybe you are looking for