EJB troubles

Alloha,
Having troubles to understand EJB annotations , I have a question here sometimes the @Remote annotation is used at the interface level and in some examples @Remote() is used at the Bean class

Hi,
The remote interface let us configure the bean's support for remote client view via the remote business interface HelloWorldInterface instead of using deployment discriptor.
using @remote on the bean or o the business interface is the same thing, there just one difference in my knowledge : using @Remote on the bean make it not required that the bean implements the business interfaces.
You can just declare a session bean and mark it with @Remote without implementing any interface but this is not a good practice !

Similar Messages

  • Trouble building simple EJB

    Hi, just going through an example ejb and then adapting the method used to create my own bean. Trouble is when I edit the main Bean class, in this case JujitsuFacadeBean, it comes up with some parse error and starts to create an interface in the ejbModule package.
    IDE is eclipse, JDK is 5.
    i followed the example as per the book. Where am I going wrong?
    Here is the errors reported in the console...
    Buildfile: /home/tam/workspace/JuJitent/.metadata/.plugins/org.eclipse.jst.j2ee.ejb.annotations.xdoclet/tempAnt.xml
    init:
    ejbdoclet:
    [ejbdoclet] (XDocletMain.start                   47  ) Running <deploymentdescriptor/>
    [ejbdoclet] Generating EJB deployment descriptor (ejb-jar.xml).
    [ejbdoclet] Error parsing File /home/tam/workspace/JuJitent/JujitsuEJB/ejbModule/com/jujitsu/ejb/JujitsuFacadeBean.java:Encountered "<" at line 80, column 19.
    [ejbdoclet] Was expecting one of:
    [ejbdoclet] <IDENTIFIER> ...
    [ejbdoclet] "[" ...
    [ejbdoclet] "." ...
    [ejbdoclet] "(" ...
    [ejbdoclet] (XDocletMain.start                   47  ) Running <remoteinterface/>
    [ejbdoclet] Generating Remote interface for 'com.jujitsu.ejb.JujitsuFacadeBean'.
    [ejbdoclet] (TemplateEngine.invokeMethod         547 ) Invoking method failed: xdoclet.modules.ejb.intf.InterfaceTagsHandler.extendsFrom, line=10 of template file: jar:file:/home/tam/opt/xdoclet-1.2.3/lib/xdoclet-ejb-module-1.2.3.jar!/xdoclet/modules/ejb/intf/resources/remote.xdt
    [ejbdoclet] java.lang.reflect.InvocationTargetException
    [ejbdoclet] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [ejbdoclet] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [ejbdoclet] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [ejbdoclet] at java.lang.reflect.Method.invoke(Method.java:585)
    plus more errors...This is the code for JujitsuFacadeBean, this implements the interface JujitsuFacade whose jar file has been included in the project.
    package com.jujitsu.ejb;
    import java.rmi.RemoteException;
    import java.util.Set;
    import javax.ejb.EJBException;
    import javax.ejb.SessionContext;
    import com.jujit.model.Club;
    import com.jujit.model.Instructor;
    import com.jujit.model.Student;
    import com.jujit.services.ClubFacade;
    import com.jujit.services.JujitsuFacade;
    * <!-- begin-user-doc -->
    * A generated session bean
    * <!-- end-user-doc -->
    * <!-- begin-xdoclet-definition -->
    * @ejb.bean name="JujitsuFacade"     
    *           description="An EJB named JujitsuFacade"
    *           display-name="JujitsuFacade"
    *           jndi-name="JujitsuFacade"
    *           type="Stateless"
    *           transaction-type="Container"
    * @ejb.transaction
    *   type="Supports"
    * <!-- end-xdoclet-definition -->
    * @generated
    public abstract class JujitsuFacadeBean implements JujitsuFacade, javax.ejb.SessionBean {
         private JujitsuFacade jujitsuFacade;
          * @ejb.interface-method view-type="both"
         public boolean doesClubExist(String clubId){
              return jujitsuFacade.doesClubExist(clubId);
          *@ejb.interface-method view-type="both"
         public boolean createClub(Club newClub){
              return jujitsuFacade.createClub(newClub);
          * @ejb.interface-method view-type="both"
         public Instructor findInstructor(String id){
              return jujitsuFacade.findInstructor(id);
          * @ejb.interface-method view-type="both"
         public Student findStudent(String id){
              return jujitsuFacade.findStudent(id);
          * @ejb.interface-method view-type="both"
         public Club findClub(String id){
              return jujitsuFacade.findClub(id);
          * @ejb.interface-method view-type="both"
         public Set<Student> getStudentsForClub(String clubId){
              return jujitsuFacade.getStudentsForClub(clubId);
          * <!-- begin-xdoclet-definition -->
          * @ejb.create-method view-type="remote"
          * <!-- end-xdoclet-definition -->
          * @generated
         public void ejbCreate() {
              jujitsuFacade = ClubFacade.getJujitsuFacade();
          * <!-- begin-xdoclet-definition -->
          * @ejb.interface-method view-type="remote"
          * <!-- end-xdoclet-definition -->
          * @generated
          * //TODO: Must provide implementation for bean method stub
         public String foo(String param) {
              return null;
         /* (non-Javadoc)
          * @see javax.ejb.SessionBean#ejbActivate()
         public void ejbActivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         /* (non-Javadoc)
          * @see javax.ejb.SessionBean#ejbPassivate()
         public void ejbPassivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         /* (non-Javadoc)
          * @see javax.ejb.SessionBean#ejbRemove()
         public void ejbRemove() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         /* (non-Javadoc)
          * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
         public void setSessionContext(SessionContext arg0) throws EJBException,
                   RemoteException {
              // TODO Auto-generated method stub
         public JujitsuFacadeBean() {
              // TODO Auto-generated constructor stub
    }Suprisingly the build after editing starts to assemble an interface JujitsuFacade...terribly.
    * Generated by XDoclet - Do not edit!
    package com.jujitsu.ejb;
    * Remote interface for JujitsuFacade.
    * @generated
    * @wtp generated
    public interface JujitsuFacade
       extends Edited by: tamscot on Nov 21, 2007 9:58 AM
    Edited by: tamscot on Nov 21, 2007 10:21 AM
    Edited by: tamscot on Nov 21, 2007 10:52 AM

    Have managed to figure out for myself what the problem was. Compiler compliance. I was using ejb 2.3, JBoss 4.0.5 and Java5. ejb could not handle Java5 generics and so reported correctly an error. Fix was to change compiler compliance in the Eclipse Workspace from 5 to 1.4 and the same goes for each of the Projects in the workspace. This also meant editing each class declaration using generics to the old way of casting.
    SORTED.

  • Having trouble to call my EJB object

    Hi All:
    I used JDeveloper 2 to deploy the helloworld EJB sample. The
    deployment wnet well and I am able to see test/Hello object under
    Published JServer Objects. However, I am having trouble to call
    Hello thru the Client application and got the following error:
    javax.naming.CommunicationException: Unknown service:
    127.0.0.1:900:2481test
    at
    oracle.aurora.jndi.sess_iiop.SessionCtx.initialContext(Compiled
    Code)
    at
    oracle.aurora.jndi.sess_iiop.SessionCtx.<init>(Compiled Code)
    at
    oracle.aurora.jndi.sess_iiop.ServiceCtx.createSession(Compiled
    Code)
    at oracle.aurora.jndi.sess_iiop.ServiceCtx.login(Compiled
    Code)
    at
    oracle.aurora.jndi.sess_iiop.ServiceCtx.defaultSession(Compiled
    Code)
    at
    oracle.aurora.jndi.sess_iiop.ServiceCtx.lookup(Compiled Code)
    at
    oracle.aurora.jndi.sess_iiop.sess_iiopURLContext.lookup(Compiled
    Code)
    at
    oracle.aurora.jndi.sess_iiop.sess_iiopURLContext.lookup(Compiled
    Code)
    at javax.naming.InitialContext.lookup(Compiled Code)
    at Client.main(Compiled Code)
    Any helps are greatly appreciated!
    Frank
    null

    Thank for the quick reply!
    There were 2 things I did wrong and both of them you pointed out.
    I left off sid in the url and did not include the jar in my
    project. Now it works!
    Thanks again!
    Frank
    JDeveloper Team (guest) wrote:
    : Hi Frank,
    : couple of things to look out for
    : - >create a database connection through the connection manager
    in
    : JDeveloper using your parameters 127.0.0.1 (host ) 900 (port)
    : 2481test(sid). ( I grepped this from your error message)
    : See if the connection is successful and you are able to see the
    : deployed ejb.
    : -> second make sure you have added the client side generated
    jar
    : files as part of your project properties for the project.
    : regards
    : raghu
    : Frank Zhang (guest) wrote:
    : : Hi All:
    : : I used JDeveloper 2 to deploy the helloworld EJB sample. The
    : : deployment wnet well and I am able to see test/Hello object
    : under
    : : Published JServer Objects. However, I am having trouble to
    call
    : : Hello thru the Client application and got the following
    error:
    : : javax.naming.CommunicationException: Unknown service:
    : : 127.0.0.1:900:2481test
    : : at
    oracle.aurora.jndi.sess_iiop.SessionCtx.initialContext(Compiled
    : : Code)
    : : at
    : : oracle.aurora.jndi.sess_iiop.SessionCtx.<init>(Compiled Code)
    : : at
    oracle.aurora.jndi.sess_iiop.ServiceCtx.createSession(Compiled
    : : Code)
    : : at oracle.aurora.jndi.sess_iiop.ServiceCtx.login(Compiled
    : : Code)
    : : at
    oracle.aurora.jndi.sess_iiop.ServiceCtx.defaultSession(Compiled
    : : Code)
    : : at
    : : oracle.aurora.jndi.sess_iiop.ServiceCtx.lookup(Compiled Code)
    : : at
    oracle.aurora.jndi.sess_iiop.sess_iiopURLContext.lookup(Compiled
    : : Code)
    : : at
    oracle.aurora.jndi.sess_iiop.sess_iiopURLContext.lookup(Compiled
    : : Code)
    : : at javax.naming.InitialContext.lookup(Compiled Code)
    : : at Client.main(Compiled Code)
    : : Any helps are greatly appreciated!
    : : Frank
    null

  • I am having trouble testing EJB across network.

    I am trying to test an ejb client, with jboss being the App Server, that would call a method of an EJB running on say "theserver.domain.com" machine. I get the following error when I run the client program from my PC.
    The EJB and client works fine when jboss and client is on the same machine.
    This is an example that comes from jboss site (http://www.jboss.org/doco_files/) called documentation-example.zip. I have modified the client as listed below. However, I have not touched the InterestBean which contains one business method called calculateCompoundInterest. It's very straight forward.
    Does any one see anything wrong with the client code. Do you have to do anything special when deploying EJB to "theserver.domain.com" vs. running locally with client.
    Thanks for your help.
    Error:
    [java] Got context
    [java] javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    [java] java.net.ConnectException: Connection refused: connect]
    Code:
    package org.jboss.docs.interest;
    import java.rmi.RemoteException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.sql.*;
    import javax.sql.DataSource ;
    import oracle.jdbc.driver.* ;
    import oracle.jdbc.* ;
    import javax.naming.InitialContext ;
    import javax.naming.NamingException;
    import javax.naming.Context ;
    This class contains the implementation for the `calculateCompoundInterest'
    method exposed by this Bean. It includes empty method bodies for the methods
    prescribe by the SessionBean interface; these don't need to do anything in this
    simple example.
    class InterestClient
    /** This method does all the work. It creates an instance of the Interest EJB on
    the EJB server, and calls its `calculateCompoundInterest()' method, then prints
    the result of the calculation.
    public static void main(String[] args)
    // Enclosing the whole process in a single `try' block is not an ideal way
    // to do exception handling, but I don't want to clutter the program up
    // with catch blocks
    try
    Properties env = new Properties();
    env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
    env.setProperty("java.naming.provider.url", "jnp://theserver.domain.com:1099");
    env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
    // cachedCTX = new InitialContext(env);
    // Get a naming context
    InitialContext jndiContext = new InitialContext(env);
    // InitialContext jndiContext = new InitialContext();
    System.out.println("Got context");
    // Get a reference to the Interest Bean
    Object ref = jndiContext.lookup("interest/Interest");
    System.out.println("Got reference");
    // Get a reference from this to the Bean's Home interface
    InterestHome home = (InterestHome)
    PortableRemoteObject.narrow(ref, InterestHome.class);
    // Create an Interest object from the Home interface
    Interest interest = home.create();
    // call the calculateCompoundInterest() method to do the calculation
    System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
    System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
    catch(Exception e)
    System.out.println(e.toString());

    Hello! We have the same firewall problem with JBoss 2.4.x as App. Server and a Java Application (Swing) as EJB client. How did you go around it?

  • Trouble finding optic.jar while looking up EJB in remote OC4J (OAS)

    I have a BPEL process that I am deploying to an embedded OC4j (lightweight) that is available with the default install of BPEL Process Mgr developer version using JDeveloper. In that BPEL process I have a BPEL-exec (java embeding) that tries to invoke an EJB running in a separate Oracle Application Server instance (in the same box).
    My BPEL process is unable to find the optic.jar support classes that is needed for a client to lookup the remote EJB. It needs the opticexception classes etc..
    My settings in the Java standalone program that is being invoked via bpel-exec include:
    private String initialContextFactory = "com.evermind.server.rmi.RMIInitialContextFactory";
        //private String initialContextFactory = "com.evermind.server.ApplicationClientInitialContextFactory";
        private String providerUrl = "opmn:ormi://10.14.2.2:6003:home/Sanity";
        private String urlPkgPrefixes = "";
        private String mapEjbJndiName = "Redlands";
        public String getDefaultMapName() {
          try {
              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY, getInitialContextFactory());
              env.put(Context.PROVIDER_URL, getProviderUrl());
              if (getUrlPkgPrefixes() != null && !getUrlPkgPrefixes().equals(""))
                  env.put(Context.URL_PKG_PREFIXES, getUrlPkgPrefixes());
                env.put(Context.SECURITY_PRINCIPAL,"admin");
                env.put(Context.SECURITY_CREDENTIALS,"welcome");
                env.put("dedicated.connection", "true");   
    context = new InitialContext(env);I even tried including all the needed jars in the BPEL-INF\lib directory, but still I see these messages in the BPEL console (unable to find the needed classes). How can I solve this?
    Here is the error message I get:
    05/12/27 11:30:48 java.lang.NoClassDefFoundError: oracle/ias/opmn/optic/OpticExc
    eption
    05/12/27 11:30:48 at com.evermind.server.rmi.RMIInitialContextFactory.getI
    nitialContext(RMIInitialContextFactory.java:275)
    05/12/27 11:30:48 at javax.naming.spi.NamingManager.getInitialContext(Nami
    ngManager.java:662)
    05/12/27 11:30:48 at javax.naming.InitialContext.getDefaultInitCtx(Initial
    Context.java:243)

    Hi clemens,
    thanks for responding.
    As suggested by you I copied the files into applib directory of oc4j/j2ee/home. In addition, I verified the system classpath of BPEL (when it launches), It has the actual physical directory where optic.jar was located. It still fails!
    Here are the files in the applib directory. These sames jars I even copied to my BPEL-INF directory and verified it is in the BPEL suitcase.
    ejb.jar
    javax77.jar
    jms.jar
    jmxri.jar
    jndi.jar
    oc4jclient.jar
    optic.jar
    readme.txt
    servlet.jar
    I still get this error:
    05/12/29 09:12:52 oracle/ias/opmn/optic/OpticException
    05/12/29 09:12:52 java.lang.NoClassDefFoundError: oracle/ias/opmn/optic/OpticExc
    eption
    05/12/29 09:12:52 at com.evermind.server.rmi.RMIInitialContextFactory.getI
    nitialContext(RMIInitialContextFactory.java:275)
    05/12/29 09:12:52 at javax.naming.spi.NamingManager.getInitialContext(Nami
    ngManager.java:662)
    05/12/29 09:12:52 at javax.naming.InitialContext.getDefaultInitCtx(Initial
    Context.java:243)
    05/12/29 09:12:52 at javax.naming.InitialContext.init(InitialContext.java:
    219)
    05/12/29 09:12:52 at javax.naming.InitialContext.<init>(InitialContext.jav
    a:195)
    05/12/29 09:12:52 at com.esri.adf.ejb.test.MapFinder.getDefaultMapName(Map
    Finder.java:58)
    05/12/29 09:12:52 at bpel.p0.ExecLetBxExe1.execute(ExecLetBxExe1.java:62)
    05/12/29 09:12:52 at com.collaxa.cube.engine.ext.wmp.BPELXExecWMP.__execut
    eStatements(BPELXExecWMP.java:49)
    05/12/29 09:12:52 at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perfo
    rm(BPELActivityWMP.java:185)
    05/12/29 09:12:52 at com.collaxa.cube.engine.CubeEngine.performActivity(Cu
    beEngine.java:3398)
    05/12/29 09:12:52 at com.collaxa.cube.engine.CubeEngine.handleWorkItem(Cub
    eEngine.java:1905)
    05/12/29 09:12:52 at com.collaxa.cube.engine.dispatch.message.instance.Per
    formMessageHandler.handleLocal(PerformMessageHandler.java:75)
    05/12/29 09:12:52 at com.collaxa.cube.engine.dispatch.DispatchHelper.handl
    eLocalMessage(DispatchHelper.java:100)
    05/12/29 09:12:52 at com.collaxa.cube.engine.dispatch.DispatchHelper.sendM
    emory(DispatchHelper.java:185)
    05/12/29 09:12:52 at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEng
    ine.java:5410)
    05/12/29 09:12:52 at com.collaxa.cube.engine.CubeEngine.createAndInvoke(Cu
    beEngine.java:1300)
    05/12/29 09:12:52 at com.collaxa.cube.engine.delivery.DeliveryService.hand
    leInvoke(DeliveryService.java:509)
    05/12/29 09:12:52 at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.han
    dleInvoke(CubeDeliveryBean.java:307)
    05/12/29 09:12:52 at ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.
    handleInvoke(ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.java:1796)
    05/12/29 09:12:52 at com.collaxa.cube.engine.dispatch.message.invoke.Invok
    eInstanceMessageHandler.handle(InvokeInstanceMessageHandler.java:37)
    05/12/29 09:12:52 at com.collaxa.cube.engine.dispatch.DispatchHelper.handl
    eMessage(DispatchHelper.java:76)
    05/12/29 09:12:52 at com.collaxa.cube.engine.dispatch.BaseScheduledWorker.
    process(BaseScheduledWorker.java:70)
    05/12/29 09:12:52 at com.collaxa.cube.engine.ejb.impl.WorkerBean.onMessage
    (WorkerBean.java:86)
    05/12/29 09:12:52 at com.evermind.server.ejb.MessageDrivenBeanInvocation.r
    un(MessageDrivenBeanInvocation.java:123)
    05/12/29 09:12:52 at com.evermind.server.ejb.MessageDrivenHome.onMessage(M
    essageDrivenHome.java:748)
    05/12/29 09:12:52 at com.evermind.server.ejb.MessageDrivenHome.run(Message
    Note:
    I just wanted to let you know that the java application I am working with works fine in standalone mode. IT is able to lookup as long as these client dependant jars are in its classpath. The problem is that it fails when it is used part of bpelexec.

  • Trouble looking up EJB from a JSP in another server

    I'm using the Sun Reference Implementation of J2EE. I'm deploying a session EJB in one J2EE app on one machine, and accessing it from a JSP in another J2EE app on another machine. My lookup code that is called from the JSP first sets the properties of the InitialContext as follows:
            Properties env = new Properties();
            env.put(Context.INITIAL_CONTEXT_FACTORY,
                    "com.sun.jndi.cosnaming.CNCtxFactory");
            env.put(Context.PROVIDER_URL, "iiop://afowlertest:1050");
            Context initial = new InitialContext(env);When I run both apps in the same server using this code, they work fine. However, when I run them in separate servers, the code throws the following exception (even if the JSP and EJB are deployed in the same server):
    javax.naming.NameNotFoundException.  Root exception is org.omg.CosNaming.NamingContextPackage.NotFound:
    IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
            at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
            at org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:406)
            at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:440)
            at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:492)
            at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:470)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)
            at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:599)
            at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:90)
            at microminer.client.SearchHandler.search(SearchHandler.java:127)
            at org.apache.jsp.test$jsp._jspService(test$jsp.java:79)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            . . .(My class is the microminer.client.SearchHandler in the stack above.)
    I've searched the forum for answers, but have not hit on anything yet. Any ideas? Thanks in advance!
    Abraham Fowler

    I'm going to answer my own question, because I kept searching the forums and eventually found the answer... maybe someone else in the same situation will find this answer here too. I got the answer from the following thread:
    http://forum.java.sun.com/thread.jsp?forum=13&thread=256151
    Basically, if you are doing a JNDI lookup with "java:comp/env" prefixed to the JNDI name, the app server will try to do a lookup within the current machine. If you leave that prefix off, it will look up using whatever properties you set in the InitialContext. At least, this is how I understood it from the thread I mentioned above.

  • Trouble looking up ejb (sun app server 8.1)

    Hi,
    I am using the below code to lookup a stateless session ejb
    Hashtable env = new Hashtable();
    env.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
    env.put("java.naming.provider.url", "iiop://127.0.0.1:3700");
    javax.naming.Context c = new javax.naming.InitialContext(env);
    Object remote = c.lookup("java:comp/env/ejb/TestBean");
    com.mycomp.testing.ejb.session.TestRemoteHome rv = (com.mycomp.testing.ejb.session.TestRemoteHome) javax.rmi.PortableRemoteObject.narrow(remote, com.mycomp.testing.ejb.session.TestRemoteHome.class);I debug through the lines (using sun java studio enterprise), and find that I get a null pointer exception on the 4th line (while getting the instance of initial context). Is it a problem with the iiop port i am using ?
    Thanks,
    Aju

    See: http://forum.java.sun.com/thread.jspa?threadID=765320&tstart=0

  • EJB Postgres Primary Key Troubles

    I'm using Postgres 8.03 and have a table with a serial id (aka auto increment) as it's primary key.
    Is there an easy way to handle the auto increment field with an EJB? Currently I have to manually set the Primary key during an insert. Is there a way to do an insert and let the auto increment do it's job without me having to manually set it?
    Will I have to query to get the highest value in the primary key field?
    The only other way I could think of to handle this would be to make the primary key field a var char and create a GUID each time I do an insert.
    Thoughts on this would be great!
    Thank you!

    Hi
    Is there an easy way to handle the auto increment
    field with an EJB? Currently I have to manually set
    the Primary key during an insert. Is there a way to
    do an insert and let the auto increment do it's job
    without me having to manually set it?you mean ejb3?
    i used, when i migrated from hsqldb to postgresql, this kind of id generator
    @SequenceGenerator(name = "board_sequence", sequenceName = "board_id_seq")
    class Xyz....
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    getId() {
    .....EJB3 will create a sequence on his own, so you can use it.

  • Trouble in communicating with another EJB from an EJB

    I have created a stateless session bean, and inside this bean I have methods that calls methods in another stateless session bean (called myEJB, for example). When I run the code, it kept giving me the "noClassDefFoundError":
    java.rmi.RemoteException: Error in ejbCreate:; nested exception is:
         java.lang.NoClassDefFoundError: com.mybean.myEJBHome
    Someone suggested to me that this is because they aren't remote objects, so I created local interfaces for "myEJB". When I run the code again (by binding to the Local interface now), I got this error:
    javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve
    'app/ejb/mybeans.jar#myEJB/local-home' Resolved: 'app/ejb/ Unresolved:'mybeans.jar#myEJB' ;
    remaining name 'mybeans.jar#myEJB/local-home']; Link Remaining Name:
    'java:app/ejb/mybeans.jar#myEJB/local-home'
    Any ideas??
    Thanks

    To refer a Ejb from another Ejb include <ejb-ref> in ejb-jar.xml
    <session>
    <ejb-name>EjbA</ejb-name>
    <ejb-ref>
    <ejb-ref-name>Ejb2</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.ejb.Ejb2Home</home>
    <remote>com.ejb.Ejb2</remote>
    </ejb-ref>
    <session>
    Include a <reference-discriptor> in weblogic-ejb-jar.xml
    <weblogic-enterprise-bean>
    <ejb-name>EjbA</ejb-name>
    <reference-descriptor>
    <ejb-reference-description>
    <ejb-ref-name>Ejb2</ejb-ref-name>
    <jndi-name>protocol://<Ejb2host>:<PortNumber>/com.ejb.Ejb2Home</jndi-name>
    </ejb-reference-description>
    </reference-descriptor>
    </weblogic-enterprise-bean>
    Example <jndi-name>:http://localhost:7001/com.ejb.Ejb2Home
    In EjbA bean class refer to Ejb2 method with a reference to Ejb2 remote interface.
    InitialContext initialContext = new InitialContext();
    Ejb2Home ejb2Home = (Ejb2Home)initialContext.lookup("protocol://<Ejb2host>:<PortNumber>/com.ejb.Ejb2Home");

  • Trouble saving date in CMP EJB on OC4J

    I have a CMP EJB that I'm trying to update and there is a field that maps to date type in the table.
    I get the following error when I try to assign a string literal of the type YYYY-MM-DD:
    javax.ejb.EJBException: Error saving state: ORA-01861: literal does not match format string
    How do you know what format string the container is using/expecting to pass to the database???
    How can you specify that? The EJB itself has the field as a String, not a Date. Should it be a Date?
    The OC4J container created it that way to begin with.
    I'm using JDeveloper with embedded OC4J and the database is 8i.

    Yes, the CMP-field's Java type should be Date. On the database side, the column-type is DATE.

  • WL 8.1 EJB sample tutorial troubles..

    Hello Everyone,
    I am just learning WL 8.1 and decided to run through the included tutorials. I have followed the WebLogic tutorial instructions to the detail and tried and tried and tried to build and deploy part 1 of the EJBProjectTutorial/myEJBProject/examples.ejb20.relationships.bands
    My project builds but I am getting a runtime error. I placed the local-ejb-ref tag in the weblogic.xml and double checked the link name w/no luck. What am I missing? If anyone can point me in the right direction, I really would appreciate it.
    Thanks in advance!
    I get the following exceptions in my WebLogic Server Console.
    weblogic.management.DeploymentException:
    Exception:weblogic.management.ApplicationException: activate failed for WebAppStepOne_Standard
    Module: WebAppStepOne_Standard Error: weblogic.management.DeploymentException: Could not setup environment - with nested exception:
    [weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'MyEJBProject.jar#Music' declared in the ejb-ref or ejb-local-ref 'ejb/MusicLink' in the application module 'WebAppStepOne_Standard' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.]
    weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'MyEJBProject.jar#Music' declared in the ejb-ref or ejb-local-ref 'ejb/MusicLink' in the application module 'WebAppStepOne_Standard' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.
    at weblogic.deployment.EnvironmentBuilder.addEJBLinkRef(EnvironmentBuilder.java:657)
    at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:466)
    at weblogic.servlet.internal.CompEnv.init(CompEnv.java:123)
    at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:5616)
    at weblogic.servlet.internal.WebAppServletContext.setActive(WebAppServletContext.java:5588)
    at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:841)
    at weblogic.j2ee.J2EEApplicationContainer.activateModule(J2EEApplicationContainer.java:3127)
    at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2081)
    at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2062)
    at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2592)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2515)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2317)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.checkAutoCommit(SlaveDeployer.java:2399)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.prepare(SlaveDeployer.java:2311)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2479)
    at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:798)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:507)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:465)
    at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    --------------- nested within: ------------------
    weblogic.management.DeploymentException: Could not setup environment - with nested exception:
    [weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'MyEJBProject.jar#Music' declared in the ejb-ref or ejb-local-ref 'ejb/MusicLink' in the application module 'WebAppStepOne_Standard' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.]
    at weblogic.servlet.internal.CompEnv.init(CompEnv.java:133)
    at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:5616)
    at weblogic.servlet.internal.WebAppServletContext.setActive(WebAppServletContext.java:5588)
    at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:841)
    at weblogic.j2ee.J2EEApplicationContainer.activateModule(J2EEApplicationContainer.java:3127)
    at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2081)
    at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2062)
    at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2592)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2515)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2317)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.checkAutoCommit(SlaveDeployer.java:2399)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.prepare(SlaveDeployer.java:2311)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2479)
    at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:798)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:507)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:465)
    at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2517)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2317)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.checkAutoCommit(SlaveDeployer.java:2399)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.prepare(SlaveDeployer.java:2311)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2479)
    at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:798)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:507)
    at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:465)
    at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    No Exception Messages

    Hi Ram,
    WebAppStepOne_Standard
    web.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd" >
    <!-- The web.xml file is a configuration file used to control the behavior of WebLogic server.
    In most cases, you will not need to modify this file. For more information on web.xml, please
    consult the Web.xml Deployment Descriptor Elements chapter of the "Developing WebLogic Server
    Applications" documentation on edocs.bea.com. -->
    <web-app>
    <display-name>Workshop Application</display-name>
    <filter>
    <filter-name>PageFlowJspFilter</filter-name>
    <filter-class>com.bea.wlw.netui.pageflow.PageFlowJspFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>PageFlowJspFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    <listener>
    <listener-class>
    com.bea.wlw.runtime.core.servlet.WebappContextListener
    </listener-class>
    </listener>
    <ejb-local-ref>
    <ejb-ref-name>ejb/BandLink</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>examples.ejb20.relationships.bands.MusicHome</local-home>
    <local>examples.ejb20.relationships.bands.Music</local>
    <ejb-link>MyEJBProject.jar#Music</ejb-link>
    </ejb-local-ref>
    <!-- Standard Action Servlet Configuration (with debugging) -->
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>com.bea.wlw.netui.pageflow.PageFlowActionServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/.pageflow-struts-generated/jpf-struts-config.xml</param-value>
    </init-param>
    <init-param>
    <param-name>config/-global</param-name>
    <param-value>/WEB-INF/.pageflow-struts-generated/jpf-struts-config--global.xml</param-value>
    </init-param>
    <init-param>
    <param-name>debug</param-name>
    <param-value>2</param-value>
    </init-param>
    <init-param>
    <param-name>detail</param-name>
    <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <!-- Struts Action Servlet Mappings -->
    <!-- Note that because Struts takes the last mapping here as the extension to add to
    actions posted from forms, we must have *.do come after *.jpf. -->
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.jpf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <error-page>
    <error-code>500</error-code>
    <location>/error.jsp</location>
    </error-page>
    <!-- Define the NetUI tag library TLDs -->
    <taglib>
    <taglib-uri>netui-tags-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/netui-tags-html.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>netui-tags-databinding.tld</taglib-uri>
    <taglib-location>/WEB-INF/netui-tags-databinding.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>netui-tags-template.tld</taglib-uri>
    <taglib-location>/WEB-INF/netui-tags-template.tld</taglib-location>
    </taglib>
    </web-app>
    Thanks,
    S

  • I have a trouble in ejb

    C:\HelloWorld>java -classpath C:\Sun\AppServer\lib\j2ee.jar;.;HelloWorldClient.j
    ar; Client
    javax.naming.NoInitialContextException: Need to specify class name in environmen
    t or system property, or as an applet parameter, or in an application resource f
    ile: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at Client.main(Client.java:15)
    i don't know what i have lost?
    thank you

    Create code as below to create the InitialContext...
    InitialContext getInitialContext(String url, String contextFactory){
    Properties p = new Properties();
    p.put( Context.INITIAL_CONTEXT_FACTORY, contextFactory);
    p.put(Context.PROVIDER_URL, url);
    return new InitialContext(p);
    For Sun Java System App Server, write code as
    getInitialContext(" "iiop://<host>:<port>", "com.sun.jndi.cosnaming.CNCtxFactory");
    For other app servers, read their document.
    You can also choose to use application client container, which makes it even easier to write ejb clients. There you can just do a new InitialContext() and things would work. More on this can be found in chapter #24 of J2EE 1.4 tutorial (http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html)
    Sahoo

  • Trouble using MS SQL Server with CMP EJBs

    Hi all,
    I have an application which uses CMP EJBs. I am migrating it from a DB2 backend (where it works like a dream) to a SQL Server 2000 backend. I am using WebSphere 5.0 and I am able to launch the application on the test server without problems, but when I run the EJB test client and try to create any of the EJBs, I get a mass of exceptions - the most pertinent part of which seems to be:
    Method createManagedConnctionWithMCWrapper caught an exception during creation of the ManagedConnection for resource jdbc/msissuetracker, throwing ResourceAllocationException. Original exception: com.ibm.ws.exception.WsException: DSRA8100E: Unable to get a PooledConnection from the DataSource.
    Why am I unable to get a PooledConnection? I am using the JDBC driver which I downloaded from the MS website, and the doco says it supports connection pooling. I am very unfamiliar with SQLServer, so can anyone tell me if I'm missing something here??
    Help much appreciated! Cheers, Ben.

    Problem is now sorted. A bit embarassing really. It was a permissions issue. Nothing about permission or access denied was mentioned anywhere in the few hundred lines of exceptions. A more descriptive exception message would have been helpful instead of "Unable to get a PooledConnection from the DataSource". Yes! But WHY?

  • Having trouble with getting ejb working

    Hi,
    i am one of the many people who are trying their hand on writing ejb3.0 on sun app server. As guessed, my context is not able to find the local interface. Here is my ejb code
    @Stateless
    public class CalculatorBean implements com.cal.CalculatorLocal {   
    /** Creates a new instance of CalculatorBean */
    public CalculatorBean() {
    public int add(int a , int b){
    System.out.println("Came in the add method of the Calculator bean");
    return a+b;
    My interface is
    @Local
    public interface CalculatorLocal {
    public int add(int a,int b);
    On the client side i am using
    try{
    InitialContext ctx = new InitialContext();
    cal = (CalculatorLocal)ctx.lookup(CalculatorLocal.class.getName());
    }catch(javax.naming.NamingException e){  }
    if (cal == null){
    System.out.println("Calculator Object is null");
    }else{
    System.out.println("The value of add is " + cal.add(3,8));
    Here are the all important jar files which are packaged inmy war file. war file structure is as follows
    .jsp files (all jsp files)
    WEB-INF
    ---->classes
    -------->all class files
    ---->lib
    -------->appserv-rt.jar
    -------->Calculator.jar (This my packaged ejb)
    -------->all other jar files.
    Both the ejb and the war file are deployed through the sun app server admin console.
    Please let me know what i am doing wrong why cant i load the stub for CalculatorLocal interface.
    Thanks
    Rashid

    The local ejb view is only accessible from within web components and ejbs running within the same application as the local ejb. Local interfaces use pass-by-reference semantics, which wouldn't be possible to achieve from a client running outside the JVM of the application server. You'll need to use a Remote business interface to access the ejb from your client. You can find more information on this in our ejb faq :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Having trouble with ejb jar...

    Hi experts,
    I've created a simple Java Enterprise Application project. Which contain, a web client and a ejb. The ejb package (ejb jar) contain one session interface and a session object. The web package (war) contain a index.jps which call a serlet (controller). This servlet invoke an object located into the ejb jar project. I don't want to create a .ear.
    I deployed both files into a glassfish server. So, i'm getting a .war file and ejb .jar file. Now, my question is why am i having a ClassNotFound exception when the servlet invoke the ClientSessionRemote interface of the ejb? Currently, the only way i've found to remove this exception is to include the ejb jar file into the classpath of the war... but it doesn't make sens!
    any help would be appreciate.
    I joined some code....
    ClientSessionRemote.java
    package com.imagem;
    import javax.ejb.Remote;
    @Remote
    public interface ClientSessionRemote {
       public java.lang.String SayHello();
    }ClientSession.java
    package com.imagem;
    import javax.ejb.Stateful;
    @Stateful
    public class ClientSession implements ClientSessionRemote  {
       public String SayHello(){
             String msg="Hello! I am Session Bean";
             System.out.println(msg);
             return msg;
    } Controller.java (servlet)
    public class Controller extends HttpServlet {
       @EJB
       private ClientSessionRemote m_testClientSessionBean;
       ...some code...
       public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          PrintWriter out;
          response.setContentType("text/html");
          String title = "EJB Example";
          out = response.getWriter();
          out.println("<html>");
          out.println("<head>");
          out.println("<title>Hello World Servlet!</title>");
          out.println("</head>");
          out.println("<body>");
          out.println("<p align=\"center\"><font size=\"4\" color=\"#000080\">Servlet Calling Session Bean</font></p>");
          try{
                //ClientSessionRemote client = (ClientSessionRemote) new InitialContext().lookup("java:comp/env/StatefulClientSession");
             //ClientSessionRemote client = (ClientSessionRemote) new InitialContext().lookup(ClientSessionRemote.class.getName());
             //out.println("<p align=\"center\"> Message from Session Bean is: <b>" + client.SayHello() + "</b></p>");
             //System.out.println("Message = " + client.SayHello());
             out.println("<p align=\"center\"> Message from Session Bean is: <b>" + m_testClientSessionBean.SayHello() + "</b></p>");
          catch(Exception CreateException){
             CreateException.printStackTrace();
          out.println("<p align=\"center\"><a href=\"javascript:history.back()\">Go to Home</a></p>");
          out.println("</body>");
          out.println("</html>");
          out.close();
       ...some code...
    }thks
    Mart.

    yorkroad wrote:
    If you just have the .war and .jar file deployed separatley then how is the Servlet going to know about the EJB classes? It doesn't, hence the ClassNotFoundException. You should at least include the EJB interfaces in the war file. Is there a particular reason for notwanting an .ear file? Just asking as it could simply things :)
    mI think you're seriously wrong on this one. Isn't the whole point of placing your logic in EJBs in not having to include anything in separate projects that are going to share it?
    @pm.renaud
    It could be the @EJB annotation. It doesn't work properly on some app servers (though I believe it should work just fine on Glassfish). Try getting to the EJB manually, through a JNDI call.

Maybe you are looking for

  • What is an M2TS file?

    Is this the right place to ask this? I recently bought a Panasonic HDC-TM300 video camera. (Yes, it's lovely.)  Played with it shooting stuff on the street etc. Imported them to my computer and they played fine using an ordinary viewer. Now my comput

  • Improving existing PDF image quality without losing text

    I have finished PDFs, the result of an OCR process that produced text under image files.  I would like to modify the lighting of the images without changing the text part of the PDF.  Is this possible in any version of Acrobat Pro?  And, if so, which

  • Convert mpeg files to mkv or avi

    Hi, I have some videos made with a digital camera in mjpeg format and I want to convert so something else, into xvid, mkv or I dont know, just to made them smaller without quality lose. So is there something GUI for this, or I need to start reading t

  • Can not install any program

    I can't install any program in my mac OS X(10.6.3) I didn't install any harmful program before or change any things in system. I am new in mac and just use it for browsing internet. I can not copy any thing in Application folder. when I install progr

  • Cisco Web Auth Page

    We have url-directed login page for web authentication. Why does the Cisco page flashed, in a bit of a sec, before it goes ahead to the directed url. Unfortunately, some customers are not happy with this. Can that Cisco page be totally eliminated?