Creation Code EJB

Dear all,
is it possible to let Developer studio create the code for calling an ejb automatically?
the following code is actually always the same and it's not practical to type that code over and over again every time we want to call a method on an EJB...
InitialContext ctx = new InitialContext();
          TestEJBLocalHome localHome = (TestEJBLocalHome)ctx.lookup("localejbs/TestEJBBean");
          TestEJBLocal bean = localHome.create();
So it would be nice if there was a way to say to developer studio, this is the bean i want to use, please generate the code so i can call my method on it.
Kind regards,
J.

Joren,
Almost exactly what you need:
1. In NW IDE open Window -> Preferences
2. Navigate to Java -> Editor -> Templates
Got the idea?
Valery Silaev
SaM Solutions
http://www.sam-solutions.net

Similar Messages

  • Problem with Creation/Code mode

    Hi!!
    When I open dreamweaver, and any of the pages i am working
    on, it opens them into code mode and i cannot swap to creation or
    creation / code mode......the option is just not available
    anymore...can anyone help please?
    Many thankx

    What version of DW, and what OS are you using? What kind of
    page are you
    working on - is it named with an htm(l) extension?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "valf" <[email protected]> wrote in message
    news:e4eott$dob$[email protected]..
    > Hi!!
    >
    > When I open dreamweaver, and any of the pages i am
    working on, it opens
    > them
    > into code mode and i cannot swap to creation or creation
    / code
    > mode......the
    > option is just not available anymore...can anyone help
    please?
    >
    > Many thankx
    >

  • Code EJB : Lesson - 8

    [ M E S S A G E - D R I V E N B E A N    C O D E ]
    1.     NewsLetterBean
    DistributeNewsLetterMDB.java
    import javax.ejb.*;
    import javax.jms.*;
    public class DistributeNewsLetterMDB implements MessageDrivenBean,MessageListener
    protected MessageDrivenContext ctx;
    String text;
    public void setMessageDrivenContext(MessageDrivenContext ctx)     {          this.ctx=ctx;     }
    public void ejbCreate()     {     //     System.out.println("ejbcreate");     }
    public void onMessage(Message msg)
         TextMessage tm=(TextMessage) msg;
         try
                   text=tm.getText();
                   System.out.println("NEWS # GOING TO DISTRIBUTE :"+msg);
                   insertMessageToDB();//MUST BE REPLACED WITH JAVAMAIL CODE IN FUTURE
         catch(JMSException e)
                   e.printStackTrace();
    public void ejbRemove()      {       //System.err.println("ejbremove");     }
    void insertMessageToDB() //JavaMAIL should be used to send mail
    try
         Class.forName("oracle.jdbc.driver.OracleDriver");
         java.sql.Connection con=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@192.168.29.62:1521:ORCL","pravash","pravash");
         java.sql.PreparedStatement     stat=con.prepareStatement("Insert into TopicInfo values(?,?)");
         stat.setString(1,"WeeklyNews");
         stat.setString(2,text);
         stat.executeUpdate();
         stat.close();
         con.close();
    catch(Exception e)
         e.printStackTrace();
    ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar>
    <ejb-jar>
    <enterprise-beans>
    <message-driven>
    <ejb-name>DistributeNewsLetter</ejb-name>
    <ejb-class>DistributeNewsLetterMDB</ejb-class>
    <message-selector></message-selector>
    <resource-env-ref-name>WeeklyNewsLetterTopic</resource-env-ref-name>
    <resource-env-ref-type>javax.jms.Topic</resource-env-ref-type>
    <resource-ref>
    <res-ref-name>TopicConnectionFactory </res-ref-name>
    <res-type>javax.jms.TopicConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <transaction-type>Container</transaction-type>
    <message-driven-destination>
    <destination-type>javax.jms.Topic</destination-type>
    <subscription-durability>NonDurable</subscription-durability>
    </message-driven-destination>
    </message-driven>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>DistributeNewsLetter</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>NotSupported</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    ejb-jar.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <jboss>
    <enterprise-beans>
    <message-driven>
    <ejb-name>DistributeNewsLetter</ejb-name>
    <configuration-name>Standard Message Driven Bean</configuration-name>
    <destination-jndi-name>WeeklyNewsLetterTopic</destination-jndi-name>
    </message-driven>
    </enterprise-beans>
    </jboss>
    BUILD.BAT
    @echo off
    echo COMPILING THE MDBEAN
    javac DistributeNewsLetterMDB.java
    echo CREATING THE JAR FOR DEPLOYMENT
    jar -cv0f DistributeNewsLetterMDB.jar META-INF DistributeNewsLetterMDB.class
    echo DEPLOYING THE JAR FOR USE
    copy DistributeNewsLetterMDB.jar c:\jbosstomcat\jboss\deploy
    echo DEPLOYMENT PROCESS OVER ....

    wtf ? what the hell is that ?:-) I wonder how he does it without the EJB QL. Not that I want him to post it.

  • Code EJB : Lesson - 2

    [CONTENTS OF ENTITY BEAN]
    {CONTAINER MANAGED PERSISTANCE}
    CMEJBHomeIFace.java
    import javax.ejb.*;
    import java.rmi.*;
    public interface CMEJBHomeIFace extends EJBHome
    public CMEJBRemoteIFace create(int id, String name,String password,int age,String location) throws CreateException,RemoteException;
    /* IN THIS EXAMPLE BOTH THE FOLLOWING METHODS DO THE SAME JOB AS P-KEY AND ID ARE THE SAME FIELD */
    public CMEJBRemoteIFace findById(int id) throws RemoteException,FinderException;
    public CMEJBRemoteIFace findByPrimaryKey(CMEJB_PKeyCode obj) throws RemoteException,FinderException;
    CMEJBRemoteIFace.java
    import javax.ejb.*;
    import java.rmi.*;
    public interface CMEJBRemoteIFace extends EJBObject
    public void setId(int id) throws RemoteException;
    public void setName(String name) throws RemoteException;
    public void setPassword(String password) throws RemoteException;
    public void setAge(int age) throws RemoteException;
    public void setLocation(String location) throws RemoteException;
    public int getId() throws RemoteException;
    public String getName() throws RemoteException;
    public String getPassword() throws RemoteException;
    public int getAge() throws RemoteException;
    public String getLocation() throws RemoteException;
    CMEJB_BeanCode.java
    import javax.ejb.*;
    import java.rmi.*;
    /* ONE ENTITY BEAN INSTANCE ASSOCIATED WITH ONE RECORD OF A TABLE.
    A RECORD IS KNOWN AS AN ENTITY.P-KEY IS REQUIRED TO IDENTIFY THE RECORD.
    P-KEY NEED NOT BE CREATED IN DATABASE, VIRTUAL P-KEY CAN BE MAINTAINED IN THE BEAN ITSELF.
    THIS P-KEY WILL MAINTAIN UNIQUNESS OF RECORD AS LONG AS WE ARE ACCESSING THE TABLE USING ENTITY BEAN.IF WE ACCESS THE TABLE DIRECTLY THROUGH SQL-PLUS AND INSERT DUPLICATE RECORD, ejbLoad() WILL FAIL,NEXT TIME WE TRY TO LOAD*/
    public class CMEJB_BeanCode implements EntityBean
    public int id;
    public String name;
    public String password;
    public int age;
    public String location;
    EntityContext tx;
    public CMEJB_PKeyCode ejbCreate(int id, String name,String password,int age,String location) //same as create() of HomeIFace but return type is different
    System.out.println("#########  Entered ejbCreate of Entity Bean ################");
         this.id = id;
         this.name = name;
         this.password = password;
         this.age = age;
         this.location = location;
         CMEJB_PKeyCode obj = new CMEJB_PKeyCode();
         obj.id = id;
    System.out.println("#########  Exited ejbCreate of Entity Bean ################");
         return obj;
    public void ejbPostCreate(int id, String name,String password,int age,String location) { }
    public void ejbActivate() { }
    public void ejbPassivate(){}
    public void setEntityContext(EntityContext etx)
         tx = etx;
    public void unsetEntityContext() {}
    public void ejbLoad() {} //taken care of by Container... in BMP we have to code it
    public void ejbStore() {}//taken care of by Container... in BMP we have to code it
    public void ejbRemove() {}
    public boolean isModified() // in  ejbStore()it is checked to store latest changes
    {     return true;     }
    public void setId(int id)               {     this.id = id;     }
    public void setName(String name)          {     this.name = name;   }
    public void setPassword(String password)     {     this.password = password;}
    public void setAge(int age)               {     this.age = age;     }
    public void setLocation(String location)     {     this.location = location;}
    public int getId()                    {     return id;          }
    public String getName()               {     return name;     }
    public String getPassword()               {     return password;     }
    public int getAge()                    {     return age;     }
    public String getLocation()               {     return location;     }
    CMEJB_PkeyCode.java
    import javax.ejb.*;
    import java.rmi.*;
    import java.io.*;
    /* used for findByPrimarykey() .used for ejbLoad() and ejbStore().*/
    public class CMEJB_PKeyCode implements Serializable
    public int id; // PKey can be applied to multiple fields
    public int hashCode() // for comparision... when we try to create a record
    {     return id;          }
    public boolean equals(Object o) // for comparision ... when we try to find a record
         CMEJB_PKeyCode pkobj = (CMEJB_PKeyCode) o;
         return (pkobj.id == this.id)?true:false;
    }   }

    wtf ? what the hell is that ?:-) I wonder how he does it without the EJB QL. Not that I want him to post it.

  • Code EJB : Lesson - 1

    USING REMOTE-I-FACE TO CONNECT EJBs
    [CONTENTS OF STATELESS SESSION BEAN]
    HomeIFace.java
    import java.rmi.*;
    import javax.ejb.*;
    public interface HomeIFace extends EJBHome
    public RemoteIFace create()throws RemoteException,CreateException;
    RemoteIFace.java
    import java.rmi.*;
    import javax.ejb.*;
    import java.util.Vector;
    public interface RemoteIFace extends EJBObject
    public String   insertData(int id,String name,String password,int age,String location)  throws RemoteException;
    public Vector   fetchData()   throws RemoteException;
    BusinessLogicCode.java
    import java.rmi.*;
    import javax.rmi.*;
    import javax.ejb.*;
    import javax.naming.*;
    import java.util.*;
    public class BusinessLogicCode implements SessionBean
    public void ejbCreate(){}
    public void ejbRemove(){}
    public void ejbActivate(){}
    public void ejbPassivate(){}
    public void setSessionContext(SessionContext s){}
    public String insertData(int id,String name,String password,int age,String location)
    System.out.println("\nStateless Beans insertData() Entered ....");
         Properties p;
         Context ctx;
         Object obj;
         CMEJBHomeIFace h;
         CMEJBRemoteIFace rem;
         try
         p=new Properties();
         p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
              p.put(Context.PROVIDER_URL,"jnp://localhost:1099");
              ctx=new InitialContext(p);
              obj=ctx.lookup("EntityBeanViaRemoteIFace");
    h=(CMEJBHomeIFace)PortableRemoteObject.narrow(obj,CMEJBHomeIFace.class);
    rem=h.create(id,name,password,age,location);
    System.out.println("\nStateless Beans insertData() Exited ......");
    return "Inserted Successfully To Entity Bean...";
         catch(Exception e)
              return "Exception While Inserting Record" +e;
    public Vector fetchData()
              //Code to call Finder method of entity bean through LocalInterface
              Vector v1=new Vector();
              v1.addElement("Hello Vector");
              return v1;
    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>EjbStatelessDemo</ejb-name>
    <home>HomeIFace</home>
    <remote>RemoteIFace</remote>
    <ejb-class>BusinessLogicCode</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    jboss.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <jboss>
    <secure>false</secure>
    <container-configurations />
    <resource-managers />
    <enterprise-beans>
    <session>
         <ejb-name>EjbStatelessDemo</ejb-name>
         <jndi-name>StatelessRemoteAccessFacility</jndi-name>
         <configuration-name></configuration-name>
    </session>
    </enterprise-beans>
    </jboss>
    BUILD.BAT
    @ECHO OFF
    echo ==== SETTING PATHS CLASSPATHS ===
    set CLASSPATH=%CLASSPATH%;.;
    path=c:\windows;c:\windows\command;c:\jdk1.3\bin
    echo ==== COMPILING ALL SERVERSIDE CODE ===
    javac *.java
    echo ==== GENERATING .JAR FILE FOR DEPLOYMENT ===
    jar -cv0f %1 META-INF *.class
    echo ==== DEPLOYING THE JAR ===
    copy %1 C:\jbosstomcat\jboss\deploy
    copy HomeIFace.class RemoteIFace.class C:\JBossTomcat\tomcat\webapps\MyJsp\WEB-INF\Classes
    echo ==== READY......... START THE SERVER IF NOT STARTED ... AND GO AHEAD ===

    wtf ? what the hell is that ?:-) I wonder how he does it without the EJB QL. Not that I want him to post it.

  • Code EJB(QL) : Lesson - 12

    EJBQLDemoHomeIFace
    import javax.ejb.*;
    import java.rmi.*;
    import java.util.*;
    public interface EJBQLDemoHomeIFace extends EJBHome
    public EJBQLDemoRemoteIFace create(int id, String name,double salary,int deptno) throws CreateException,RemoteException;
    public EJBQLDemoRemoteIFace findById(int id) throws RemoteException,FinderException;
    public EJBQLDemoRemoteIFace findByPrimaryKey(EJBQLDemoPk obj) throws RemoteException,FinderException;
    public Collection findByName(String name) throws RemoteException,FinderException;
    public Collection findByDeptno(int deptno) throws RemoteException,FinderException;
    public Collection findByAll() throws RemoteException,FinderException;
    EJBQLDemoRemoteIFace
    import javax.ejb.*;
    import java.rmi.*;
    public interface EJBQLDemoRemoteIFace extends EJBObject
    public void setId(int id) throws RemoteException;
    public void setName(String name) throws RemoteException;
    public void setSalary(double salary) throws RemoteException;
    public void setDeptno(int deptno) throws RemoteException;
    public int getId() throws RemoteException;
    public String getName() throws RemoteException;
    public double getSalary() throws RemoteException;
    public int getDeptno() throws RemoteException;
    EJBQLDemoPk
    import javax.ejb.*;
    import java.rmi.*;
    import java.io.*;
    public class EJBQLDemoPk implements Serializable
    public int id;
    public int hashCode()
         return id;
    public boolean equals(Object o)
    EJBQLDemoPk pkobj = (EJBQLDemoPk) o;
    return (pkobj.id == this.id)?true:false;
    EJBQLDemoBeanCode
    import javax.ejb.*;
    import java.rmi.*;
    /* BEAN CLASS MUST BE DECLARED AS AN ABSTRACT CLASS */
    abstract public class EJBQLDemoBeanCode implements EntityBean
    /****************** MEMBER FIELDS ARE NOT REQUIERED ****************************
         public int id;
         public String name;
         public double salary;
         public int deptno;
    private EntityContext tx;
    public EJBQLDemoBeanCode(){}
    public EJBQLDemoPk ejbCreate(int id, String name,double salary,int deptno) throws CreateException // throws is a must here
         setId(id);
         setName(name);
         setSalary(salary);
         setDeptno(deptno);
         return null;
    public void ejbPostCreate(int id, String name,double salary,int deptno) { }
    public void ejbActivate() { }
    public void ejbPassivate(){}
    public void setEntityContext(EntityContext etx){ tx = etx; }
    public void unsetEntityContext() {}
    public void ejbLoad() {}
    public void ejbStore() {}
    public void ejbRemove() {}
    public boolean isModified() {          return true;     }
    /****************** MEMBER METHODS ARE DECLARED ABSTRACT ****************************/
    abstract public void setId(int id);               //{this.id=id;}
    abstract public void setName(String name);     //{this.name=name;}
    abstract public void setSalary(double salary);     //{this.salary=salary;}
    abstract public void setDeptno(int deptno);     //{this.deptno=deptno;}
    abstract public int getId();                    //{return id;}
    abstract public String getName();               //{return name;}
    abstract public double getSalary();               //{return salary;}
    abstract public int getDeptno();               //{return deptno;}
    JSPCient
    <%@ page import="javax.ejb.*,javax.naming.*,java.rmi.*,javax.rmi.*,java.util.*" %>
    <%@ page import="EJBQLDemoHomeIFace,EJBQLDemoRemoteIFace" %>
    <%!
    InitialContext c = null;
    Properties p = null;
    EJBQLDemoHomeIFace homref = null;
    EJBQLDemoRemoteIFace remref = null;
    %>
    <%
    p=new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
    p.put(Context.PROVIDER_URL,"jnp://localhost:1099");
    c=new InitialContext(p);
    homref=(EJBQLDemoHomeIFace)c.lookup("EJBQLBean");
    out.println("<h1>Ready....</h1>");
         //CODE TO INSERT A RECORD
         remref=homref.create(104,"DEWANG",5780.0,10);
         out.println("Record Inserted ,...");
         //CODE TO FIND A RECORD
         remref = homref.findById(100);
         out.println("NAME OF THE PERSON : " +remref.getName());
         //CODE TO FIND ALL RECORD
         Iterator i = homref.findByAll().iterator();
         while(i.hasNext())
              remref = (EJBQLDemoRemoteIFace)PortableRemoteObject.narrow(i.next(),EJBQLDemoRemoteIFace.class);
              out.println(remref.getName() + " " + remref.getSalary() );
    %>

    wtf ? what the hell is that ?:-) I wonder how he does it without the EJB QL. Not that I want him to post it.

  • Code EJB : Lesson - 2 (Continue)

    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>
    <entity>
         <ejb-name>CMEntityDemo</ejb-name>
         <home>CMEJBHomeIFace</home>
         <remote>CMEJBRemoteIFace</remote>
         <ejb-class>CMEJB_BeanCode</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>CMEJB_PKeyCode</prim-key-class>
         <reentrant>False</reentrant>
         <cmp-field>     <field-name>id</field-name>          </cmp-field>
         <cmp-field>     <field-name>name</field-name>     </cmp-field>
         <cmp-field>     <field-name>password</field-name>     </cmp-field>
         <cmp-field>     <field-name>age</field-name>     </cmp-field>
         <cmp-field>     <field-name>location</field-name>     </cmp-field>
    </entity>
    </enterprise-beans>
    </ejb-jar>
    jaws.xml
    <jaws>
         <datasource>java:/orclPool</datasource>
         <type-mapping>Oracle8</type-mapping>
         <enterprise-beans>
              <entity>
                   <ejb-name>CMEntityDemo</ejb-name>
                   <table-name>MyLoginTable</table-name>
                   <remove-table>false</remove-table>
                   <create-table>true</create-table>
                   <cmp-field>
                        <field-name>id</field-name>
                        <column-name>ID</column-name>
              </cmp-field>
                   <cmp-field>
                        <field-name>name</field-name>
                        <column-name>NAME</column-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>password</field-name>
                        <column-name>PASSWORD</column-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>age</field-name>
                        <column-name>AGE</column-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>location</field-name>
                        <column-name>LOCATION</column-name>
                   </cmp-field>
              </entity>
         </enterprise-beans>
    </jaws>
    jboss.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <jboss>
    <secure>false</secure>
    <container-configurations />
    <resource-managers />
    <enterprise-beans>
    <entity>
         <ejb-name>CMEntityDemo</ejb-name>
         <jndi-name>EntityBeanViaRemoteIFace</jndi-name>
         <configuration-name></configuration-name>
    </entity>
    </enterprise-beans>
    </jboss>
    BUILD.BAT
    @ECHO OFF
    echo ==== SETTING PATHS CLASSPATHS ===
    set CLASSPATH=%CLASSPATH%;.;
    path=c:\windows;c:\windows\command;c:\jdk1.3\bin
    echo ==== COMPILING ALL SERVERSIDE CODE ===
    javac *.java
    echo ==== GENERATING .JAR FILE FOR DEPLOYMENT ===
    jar -cv0f %1 META-INF *.class
    echo ==== DEPLOYING THE JAR ===
    copy %1 C:\jbosstomcat\jboss\deploy
    echo ==== READY......... START THE SERVER IF NOT STARTED ... AND GO AHEAD ===

    wtf ? what the hell is that ?:-) I wonder how he does it without the EJB QL. Not that I want him to post it.

  • Code EJB : Lesson - 9

    2.     ScienceNewsBean
    DistributeScienceNewsMDB.java
    import javax.ejb.*;
    import javax.jms.*;
    public class DistributeScienceNewsMDB implements MessageDrivenBean,MessageListener
    protected MessageDrivenContext ctx;
    String text;
    public void setMessageDrivenContext(MessageDrivenContext ctx)     {          this.ctx=ctx;     }
    public void ejbCreate()     {     //     System.out.println("ejbcreate");     }
    public void onMessage(Message msg)
              Open Con to DB
              Get Subscriber List
              Send Mail to Them(JavaMail Preferred)
         TextMessage tm=(TextMessage) msg;
         try
                   text=tm.getText();
                   System.out.println("RECEIVED THE NEWS # GOING TO DISTRIBUTE :"+msg);
                   insertMessageToDB(); //JavaMAIL should be used to send mail
         catch(JMSException e)
                   e.printStackTrace();
    public void ejbRemove()      {       //System.err.println("ejbremove");     }
    void insertMessageToDB() //JavaMAIL should be used to send mail
    try
         Class.forName("oracle.jdbc.driver.OracleDriver");
         java.sql.Connection con=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@192.168.29.62:1521:ORCL","pravash","pravash");
         java.sql.PreparedStatement     stat=con.prepareStatement("Insert into TopicInfo values(?,?)");
         stat.setString(1,"ScienceNews");
         stat.setString(2,text);
         stat.executeUpdate();
         stat.close();
         con.close();
    catch(Exception e)
         e.printStackTrace();
    ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar>
    <ejb-jar>
    <enterprise-beans>
    <message-driven>
    <ejb-name>DistributeScienceNews</ejb-name>
    <ejb-class>DistributeScienceNewsMDB</ejb-class>
    <message-selector></message-selector>
    <resource-env-ref-name>ScienceTopic</resource-env-ref-name>
    <resource-env-ref-type>javax.jms.Topic</resource-env-ref-type>
    <resource-ref>
    <res-ref-name>TopicConnectionFactory </res-ref-name>
    <res-type>javax.jms.TopicConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <transaction-type>Container</transaction-type>
    <message-driven-destination>
    <destination-type>javax.jms.Topic</destination-type>
    <subscription-durability>NonDurable</subscription-durability>
    </message-driven-destination>
    </message-driven>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>DistributeScienceNews</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>NotSupported</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    jboss.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <jboss>
    <enterprise-beans>
    <message-driven>
    <ejb-name>DistributeScienceNews</ejb-name>
    <configuration-name>Standard Message Driven Bean</configuration-name>
    <destination-jndi-name>ScienceTopic</destination-jndi-name>
    </message-driven>
    </enterprise-beans>
    </jboss>
    BUILD.BAT
    @echo off
    echo COMPILING THE MDBEAN
    javac DistributeScienceNewsMDB.java
    echo CREATING THE JAR FOR DEPLOYMENT
    jar -cv0f DistributeScienceNewsMDB.jar META-INF DistributeScienceNewsMDB.class
    echo DEPLOYING THE JAR FOR USE
    copy DistributeScienceNewsMDB.jar c:\jbosstomcat\jboss\deploy
    echo DEPLOYMENT PROCESS OVER ....

    wtf ? what the hell is that ?:-) I wonder how he does it without the EJB QL. Not that I want him to post it.

  • Code EJB : Lesson - 10

    3.     SportsNewsBean
    DistributeSportsNewsMDB.java
    import javax.ejb.*;
    import javax.jms.*;
    public class DistributeSportsNewsMDB implements MessageDrivenBean,MessageListener
    protected MessageDrivenContext ctx;
    String text;
    public void setMessageDrivenContext(MessageDrivenContext ctx)     {          this.ctx=ctx;     }
    public void ejbCreate()     {     //     System.out.println("ejbcreate");     }
    public void onMessage(Message msg)
         TextMessage tm=(TextMessage) msg;
         try
                   text=tm.getText();
                   System.out.println("TOPIC: SPORTS # GOING TO DISTRIBUTE :"+msg);
                   insertMessageToDB(); //JavaMAIL should be used to send mail
         catch(JMSException e)
                   e.printStackTrace();
    public void ejbRemove()      {       //System.err.println("ejbremove");     }
    void insertMessageToDB() //JavaMAIL should be used to send mail
    try
         Class.forName("oracle.jdbc.driver.OracleDriver");
         java.sql.Connection con=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@192.168.29.62:1521:ORCL","pravash","pravash");
         java.sql.PreparedStatement     stat=con.prepareStatement("Insert into TopicInfo values(?,?)");
         stat.setString(1,"SportsNews");
         stat.setString(2,text);
         stat.executeUpdate();
         stat.close();
         con.close();
    catch(Exception e)
         e.printStackTrace();
    ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar>
    <ejb-jar>
    <enterprise-beans>
    <message-driven>
    <ejb-name>DistributeSportsNews</ejb-name>
    <ejb-class>DistributeSportsNewsMDB</ejb-class>
    <message-selector></message-selector>
    <resource-env-ref-name>SportsTopic</resource-env-ref-name>
    <resource-env-ref-type>javax.jms.Topic</resource-env-ref-type>
    <resource-ref>
    <res-ref-name>TopicConnectionFactory </res-ref-name>
    <res-type>javax.jms.TopicConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <transaction-type>Container</transaction-type>
    <message-driven-destination>
    <destination-type>javax.jms.Topic</destination-type>
    <subscription-durability>NonDurable</subscription-durability>
    </message-driven-destination>
    </message-driven>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>DistributeSportsNews</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>NotSupported</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    jboss.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <jboss>
    <enterprise-beans>
    <message-driven>
    <ejb-name>DistributeSportsNews</ejb-name>
    <configuration-name>Standard Message Driven Bean</configuration-name>
    <destination-jndi-name>SportsTopic</destination-jndi-name>
    </message-driven>
    </enterprise-beans>
    </jboss>
    BUILD.BAT
    @echo off
    echo COMPILING THE MDBEAN
    javac DistributeSportsNewsMDB.java
    echo CREATING THE JAR FOR DEPLOYMENT
    jar -cv0f DistributeSportsNewsMDB.jar META-INF DistributeSportsNewsMDB.class
    echo DEPLOYING THE JAR FOR USE
    copy DistributeSportsNewsMDB.jar c:\jbosstomcat\jboss\deploy
    echo DEPLOYMENT PROCESS OVER ....

    wtf ? what the hell is that ?:-) I wonder how he does it without the EJB QL. Not that I want him to post it.

  • How to code EJB in Eclipse IDE

    Hello Forum
    I have downloaded eclipse-SDK-3_1.2-win32.zip and installed but I couldnt findout J2EE development in it
    (that how we add session beans, how we configure application server and how we generate entity beans)
    do I need any plugin to work with J2ee in it,
    Please help me - Thank u very much
    - Tahir

    Sorry, this forum is for questions about the javadoc tool for generating documentation, so you might try elsewhere.

  • Error when opening a EJB code

    Hi All,
    When I try to open by ejb code ( ejb.java file) I am getting the following error
    An internal error occurred during: "Resynching JPA model ...".
    IWAE0011E Key already used to access Resource : org.eclipse.wst.common.internal.emfworkbench.EditModelLeastUsedCache@e55d75
    Please help me in this
    Thanks!
    Swarnaprakash

    Hi,
    First check in
    IMG-FA-FA GS - Tax on sales & Purchase
    1. Check the calculation procedure - TAX<Country> E.g. for India - TAXIN
    2. Check whether the country has been assignmed to the calculation procedure
    3. Calculation - Define Tax codes for Sales / Pur - Enter country and enter tax codes (Tax Type: A: Output tax; v-Input Tax) and give Tax percent
    Save
    It should solve ur problem
    <i>Pls. assign points, if useful</i>
    Regards,
    sridevi

  • Error while looking up EJB

    Hello,
    I'm trying to develop EJBs 2.0 for my company.
    creation and EJB deployment works fine, but when I try to look up my EJB, I get a NamingException.
    EAR is deployed on a Websphere Application Server 5.1, and I would like to communicate with my EJB in a portlet. This portlet is deployed on a Websphere portal Server 5.1. WPS ans WAS servers are on the same system.
    this is my JSP code :
    Context ctx = new InitialContext();
    Object obj = ctx.lookup("ejb/fr/test/ejbtest/EJBTest2Home");
    EJBTest2Home cacheHome = (EJBTest2Home)javax.rmi.PortableRemoteObject.narrow(obj, EJBTest2Home.class);I think my InitialContext is Websphere Portal Server so it cannot access to my EJB interface deployed on the Websphere Application Server 5.1
    Thx for your help !

    Hi,
    I guess u had made 2 mistakes.
    First one as to ur guess, u got the IntialContext wrong and secondly u should lookup the HomeObject using JNDI name instead of the fully qualified classpath.
    I am not so sure of websphere5.1, but for most of the servers have diff context for webcontainer and BeanContainer
    First u try to get it done changing the code to,
    ctx.lookup("ejb/fr/test/ejbtest/EJBTest2Home");
    to
    ctx.lookup("JNDIName");
    if it doesnt workout then do changes to the context as well
    Thanks and Regards
    Srikanth

  • EJB client recovery

    Hi,
    I have a java client application using EJBs, and talking to a EJB server (j2ee sdk 1.3) successfully.
    Now I stop the EJB server while the client is running, and restart the server again. I would like my client to recover automatically without the need of stoppin/restarting it.
    When the server stops, my client enters in a 'resume mode' when it tries to recreate new EJBs.
    Unfortunately, when the server is back up and running, the creation of EJBs still raises a MarshallException and it even hangs after a while.
    My approach is a bit innocent, but is there a smarter solution that would work?
    Thanks

    Try to do a clean up at the client code when u determine that the EJB server is down. Is the intent to failover to another ejb server and continue with the session then you may require Sun's enterprise edition which supports sfsb failover.

  • Netbeans: adding to jPanel via code after init (jFreeChart)

    This will be my second post. Many thanks to those who replied to my first questions.
    I am using netbeans 5.5
    I am attempting to run the following jFreeChart demo but in netbeans.
    Original demo located here: http://www.java2s.com/Code/Java/Chart/JFreeChartPieChartDemo7.htm
    Instead of programically creating the jPanel like the demo does, i would like to do it using the netbeans GUI and then add the code to create the jFreeChart.
    In netbeans i create a new project, create a new jFrame and place a new jPanel on the form (keeping the variable name jPanel1) as illustrated below:
    * MainForm.java
    * Created on June 28, 2007, 1:48 PM
    package mypkg;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.plot.PiePlot;
    import org.jfree.chart.plot.PiePlot3D;
    import org.jfree.data.general.DefaultPieDataset;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;
    * @author  me
    public class MainForm extends javax.swing.JFrame {
        /** Creates new form MainForm */
        public MainForm() {
            initComponents();
        /** Netbeans Auto-Generated Code goes here which I have omitted */                       
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new MainForm().setVisible(true);
        private void CreateChart() {
            DefaultPieDataset dataset = new DefaultPieDataset();
            dataset.setValue("Section 1", 23.3);
            dataset.setValue("Section 2", 56.5);
            dataset.setValue("Section 3", 43.3);
            dataset.setValue("Section 4", 11.1);
            JFreeChart chart3 = ChartFactory.createPieChart3D("Chart 3", dataset, false, false, false);
            PiePlot3D plot3 = (PiePlot3D) chart3.getPlot();
            plot3.setForegroundAlpha(0.6f);
            plot3.setCircular(true);
            jPanel1.add(new ChartPanel(chart3));
            jPanel1.validate();
        // Variables declaration - do not modify                    
        private javax.swing.JPanel jPanel1;
        // End of variables declaration                  
    }I then attempted to call the CreateChart() function in several places (in the MainForm() function, in the pre and post creation code properties of the jPanel's properties dialog in netbeans (as well as pre and post init in the same screen)) and nothing seems to work. the program compiles and the jFrame comes up but the chart does not show.
    If i run the example at the above noted link it runs fine in netbeans if i copy and paste the code directly, it just doesnt work when i try to get it to work through the netbeans GUI builder and the jPanel i create through it.
    Can any more advanced netbeans/java users lend me a hand or point me in the right direction?
    NOTE: in the code pasted above, i am only trying to run one of the four chart demo's listed in the original source in the link.
    NOTE2: in the code pasted above it doesnt show me calling CreateChart() from anywhere, im hoping to get some advice on how to proceed from here.
    Message was edited by:
    amadman

    Here is the netbeans generated code that i had omitted in the post above:
    private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            CreateChart(); //this is one of the many places i tried sticking the function
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 546, Short.MAX_VALUE)
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 398, Short.MAX_VALUE)
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            pack();
        }// </editor-fold>   I believe this is what you mentioned looking for, or close to it:
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);any thoughts?

  • Error while running EJB Client

    Hi All,
    I have just written a program in EJB for currency conversion. But while running the client , i am getting the following error:
    C:\Java Source Code\EJB>java CalculatorClient
    java.lang.NoSuchMethodError: loadClass0
    at com.sun.corba.ee.internal.util.JDKClassLoader.specialLoadClass(Native
    Method)
    at com.sun.corba.ee.internal.util.JDKClassLoader.loadClass(JDKClassLoade
    r.java:58)
    at com.sun.corba.ee.internal.util.JDKBridge.loadClassM(JDKBridge.java:18
    0)
    at com.sun.corba.ee.internal.util.JDKBridge.loadClass(JDKBridge.java:83)
    at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.loadClass(Util.java:37
    8)
    at javax.rmi.CORBA.Util.loadClass(Unknown Source)
    at javax.rmi.PortableRemoteObject.createDelegateIfSpecified(Unknown Sour
    ce)
    at javax.rmi.PortableRemoteObject.<clinit>(Unknown Source)
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav
    a:57)
    etc........
    The files that have been created are in the same folder which are as follows:
    Calculator.java Calculator.class - Remote Interface
    CalculatorHome.java CalculatorHome.class - Home Interface
    CalculatorEJB.java CalculatorEJB.class - EJB class
    ejbClient.jar - Client Jar
    ejb.ear
    The version for J2EE is 1.2.1
    Version for Jdk is 1.4.2
    Operating System - WinXP
    Could somebody pls help?
    Cooljacks

    ... but you did deploy it to an application server, right?

Maybe you are looking for

  • It's official: iPhone 3G doesn't work on Rogers/Fido 3G network

    I have been experiencing missing calls since I got the phone but it's getting ridiculous lately. Now about 90% of the calls go directly to voice-mail while on 3G. It's been 2.1 will fix it, then 2.2 will fix it. Reset your phone, reset your settings,

  • Image compare hurt by "noise" around edges within digitized image

    Using 1411 IMAQ card and an NTSC color camera. Retrieving only luminance information. Snapping the same image under the same conditions twice in a row, I get a difference in the images. This occurs around the dark and light edges within the images. H

  • Watching .avi files with quicktime?  Help

    Hi all, I have a bunch of .avi movie files I want to watch, but when I try to open them with quicktime, I'm told I may need additional components to watch them. I'm taken to a screen with a bunch of vendors offering Quicktime components, but I have n

  • Search Help in Select - Options

    Dear experts, i use three select options and they work fine. In the node of the view i declared the attributes i need and bound a search help (F4 help) to them. here is the problem. One attribute has the help visible when i start the application, the

  • Where are my tabs......?

    I have an extremely aggravating problem, and really hope someone out there will have an answer or suggestion. When I plug my iTouch into the pc, and itunes is open, when I select my device, there are no tabs whatsoever. I can't manipulate a single th