First ejb

hi everyone
I am deploying my first EJB in weblogic 5.1 .When i try to load the jar
file in weblogic's EJB deployer.I am getting the following errors.
org.xml.sax.SAXParseException: Element "session" requires additional
elements.
at com.sun.xml.parser.Parser.error(Parser.java:2775)
at
com.sun.xml.parser.ValidatingParser$ChildrenValidator.done(ValidatingParser.
java:322)
at com.sun.xml.parser.Parser.maybeElement(Parser.java:1411)
at com.sun.xml.parser.Parser.content(Parser.java:1498)
at com.sun.xml.parser.Parser.maybeElement(Parser.java:1399)
at com.sun.xml.parser.Parser.content(Parser.java:1498)
at com.sun.xml.parser.Parser.maybeElement(Parser.java:1399)
at com.sun.xml.parser.Parser.parseInternal(Parser.java:491)
at com.sun.xml.parser.Parser.parse(Parser.java:283)
at weblogic.xml.dom.SunDOMParser.getDocument(SunDOMParser.java:69)
at weblogic.xml.dom.DOMParser.getDocument(DOMParser.java:102)
at
weblogic.ejb.deployment.dd.DescriptorLoader.<init>(DescriptorLoader.java:151
at
weblogic.ejb.ui.deployer.DeployerFrame.loadDeploymentUnit(DeployerFrame.java
:1123)
at
weblogic.ejb.ui.deployer.AbstractProjectRootNode.loadDeploymentUnit(Abstract
ProjectRootNode.java:161)
at
weblogic.ejb.ui.deployer.DeployerProjectRootNode.load(DeployerProjectRootNod
e.java:120)
at
weblogic.ejb.ui.deployer.DeployerProjectRootNode.load(DeployerProjectRootNod
e.java:101)
at
weblogic.ejb.ui.deployer.ProjectLoaderWorker$LoaderThread.run(ProjectLoaderW
orker.java, Compiled Code)
--------------- nested within: ------------------
Received SAXParseException from Sun Parser at line 13, column -1:
org.xml.sax.SAXParseException: Element "session" requires additional
elements.
at weblogic.xml.dom.SunDOMParser.getDocument(SunDOMParser.java:72)
at weblogic.xml.dom.DOMParser.getDocument(DOMParser.java:102)
at
weblogic.ejb.deployment.dd.DescriptorLoader.<init>(DescriptorLoader.java:151
at
weblogic.ejb.ui.deployer.DeployerFrame.loadDeploymentUnit(DeployerFrame.java
:1123)
at
weblogic.ejb.ui.deployer.AbstractProjectRootNode.loadDeploymentUnit(Abstract
ProjectRootNode.java:161)
at
weblogic.ejb.ui.deployer.DeployerProjectRootNode.load(DeployerProjectRootNod
e.java:120)
at
weblogic.ejb.ui.deployer.DeployerProjectRootNode.load(DeployerProjectRootNod
e.java:101)
at
weblogic.ejb.ui.deployer.ProjectLoaderWorker$LoaderThread.run(ProjectLoaderW
orker.java, Compiled Code)
Unable to parse: null
Failed to load C:\weblogic\examples\divya\session.jar
Here are my java files
1)home interface----------
package examples.divya;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface HelloHome extends EJBHome{
Hello create() throws RemoteException, CreateException;
2)remote interface---------
package examples.divya;
import javax.ejb.*;
import java.rmi.RemoteException;
import java.rmi.Remote;
public interface Hello extends EJBObject{
public String hello() throws java.rmi.RemoteException;
3)bean class-----
package examples.divya;
import javax.ejb.*;
public class HelloBean implements SessionBean{
public void ejbCreate(){
System.out.println("ejbCreate()");
public void ejbRemove(){
System.out.println("ejbRemove()");
public void ejbActivate(){
System.out.println("ejbActivate()");
public void ejbPassivate(){
System.out.println("ejbPassivate()");
public void setSessionContext(SessionContext ctx){
System.out.println("setSessionContext()");
public String hello(){
System.out.println("hello()");
return "Hello, World";
xml file is-----
<?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>divya</ejb-name>
<home>examples.divya.HelloHome</home>
<remote>examples.divya.Hello</remote>
<ejb-class>examples.divya.HelloBean</ejb-class>
<session-type>Stateless</session-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>divya</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
please help.....thanks in advance
divya

Luca -
I assume you are building EJBs using the older 2.1 specification? If so, you'll need to declare the name of your bean in a deployment descriptor. But if you are creating new EJBs, you might want to use EJB 3.0 instead - then you can just use the EntityManager to get hold of resources like other EJBs with no deployment descriptor needed. Regardless of the version you're developing, this article addresses the old way and the new way:
http://www.onjava.com/pub/a/onjava/2006/01/04/dependency-injection-java-ee-5.html
I found this linked from our EJB3 page, which has loads of information for EJB newbies:
http://www.oracle.com/technology/tech/java/ejb30.html
Hope this helps,
Lynn Munsinger
JDeveloper Product Management

Similar Messages

  • Stuck In the Mud with First EJB

    I am using the apress 'Beginning Java EE, from Novice to Professional' book. In its first EJB example it attempts to create am extremely simple stateless session bean. There are two classes and a remote interface as follows;
    package beans;
    import javax.ejb.Remote;
    @Remote
    public interface SimpleSession
    public String getEchoString(String clientString);
    package beans;
    import javax.ejb.Stateless;
    @Stateless
    public class SimpleSessionBean implements SimpleSession {
    public String getEchoString(String clientString) {
    return clientString + " - from session bean";
    package client;
    import beans.SimpleSession;
    import javax.naming.InitialContext;
    public class SimpleSessionClient {
    public static void main(String[] args) throws Exception
    InitialContext ctx = new InitialContext();
    SimpleSession simpleSession
    = (SimpleSession) ctx.lookup(SimpleSession.class.getName());
    for (int i = 0; i < args.length; i++) {
    String returnedString = simpleSession.getEchoString(args);
    System.out.println("sent string: " + args[i] +
    ", received string: " + returnedString);
    The directory structure is;
    SimpleSessionApp
    |-beans
    |-SimpleSession
    |-SimpleSessionBean
    |-client
    |-SimpleSessionClientThe tells you to add the following to your classpath;
    set CLASSPATH=.;C:\jboss\lib\concurrent.jar;
    C:\jboss\lib\jboss-common.jar;
    c:\jboss\client\jboss-j2ee.jar;
    c:\jboss\lib\commons-httpclient.jar;
    C:\jboss\server\all\lib\jboss.jar;
    C:\jboss\server\all\lib\jboss-remoting.jar;
    C:\jboss\server\all\lib\jboss-transaction.jar;
    C:\jboss\server\all\lib\jnpserver.jar;
    C:\jboss\server\all\deploy\ejb3.deployer\jboss-ejb3.jar;
    C:\jboss\server\all\deploy\ejb3.deployer\jboss-ejb3x.jar;
    C:\jboss\server\all\deploy\jboss-aop.deployer\
    jboss-aop.jar;
    C:\jboss\server\all\deploy\jboss-aop.deployer\
    jboss-aspect-library.jar
    The next step is to compile the java source  code;
    javac -d . client/*.java
    javac -d . beans/*.javaAfter this you create an ejb3 jar;
    jar cf SimpleSessionApp.ejb3 beans\*.javaAnd deploy this jar to your jboss deploy directory while jboss is running. Once this is done you run the client with the following arguments and switches while inside the client directory of SimpleSessionApp;
    java
    -Djava.naming.factory.initial=
    org.jnp.interfaces.NamingContextFactory
    -Djava.naming.factory.url.pkgs=
    org.jboss.naming:org.jnp.interfaces
    -Djava.naming.provider.url=
    localhost client.SimpleSessionClient
    Now is the time for all good men
    After having done all of this I get the following error
    +Exception in thread "main" java.lang.NoSuchMethodError: main+
    why is this? This is my first attempt at creating an ejb and I'm totally lost. Any help would be appreciated.
    Edited by: Jazman on Feb 19, 2008 2:42 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    if you turn the computer off and turn it back on while you hold down the mouse key that should get the disc out.

  • First EJB problem:  HTTP 404 NOT FOUND

    I was running the first EJB example(Coverter) in J2EE Tutorial. My HTTP port is 4848.
    I can deploy the application at localhost:4848, and I can connect to http://localhost:4848/asadmin/
    The context root for web client is /converter.
    But when I try to connect http://localhost:4848/converter, It gave me HTTP 404 NOT FOUND error.
    Why?

    Now I know.
    Admin Port is 4848. Http Port is 4421.

  • Thank you,there is a error in my FIRST EJB,can you help me?

    This in a servlet:
    public int getNo()
    TestSessionEJB test = new TestSessionEJB();
    return test.getNo();
    This in a TestSessionEJB class�F
    package test;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    public class TestSessionEJB {
    private TestSessionHome testSessionHome = null;
    public TestSessionEJB() {
    try {
    Context ctx = new InitialContext();
    Object ref = ctx.lookup("TestSession");
    testSessionHome = (TestSessionHome) PortableRemoteObject.narrow(ref, TestSessionHome.class);
    catch(Exception e) {
    e.printStackTrace();
    public TestSessionHome getHome() {
    return testSessionHome;
    public int getNo()
    TestSession test = null;
    int li_rtn = 0;
    try
    this.getHome();
    test = testSessionHome.create();
    li_rtn = test.getNo();
    catch(Exception e)
    return li_rtn;
    Not use bas4.5,is there any error?Thanks a lot.

    I don't think you know the first thing about EJBs. I think you better go back and read a book or two first before attempting to write an EJB. Mastering EJBs or Professional EJB are both good books. You are not even close to writing your first EJB.

  • Error building my first EJB

    I am trying to build my first EJB. However, everytime I giev the "ant build" command, I get an erro saying "Validation Problems Were Found". This is the only error i get and Not any syntax errors. Does this have something to do with my remote, local and Home interfaces, the Bean Class or Client, OR is it my build. xml file that has some error in it.

    Looks like your ejb-jar.xml is not correct (check the element
    <enterprise-beans>). You may post this file so that I can take a look at it.
    --Sathish
    <Waqar Ahmad> wrote in message news:[email protected]...
    Thanks for replying. Here is the build.xml file and the error output that
    I get when I execute the ant command. My BEAN here is called
    <b>SecuirtyEJB.java</b> and all the files including this BEAN are in a
    foler named SecuritySystem. Now, here is the build.xml file:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <project name="ejb20-basic-SecuritySystem" default="all" basedir=".">
    <!-- set global properties for this build -->
    <property environment="env"/>
    <property file="../../../../../examples.properties"/>
    <property name="build.compiler" value="${compiler}"/>
    <property name="source" value="${basedir}"/>
    <property name="bean.ear" value="ejb20StatelessEar"/>
    <property name="dist" value="${source}/${bean.ear}"/>
    <property name="ejb.name" value="ejb20StatelessEjb"/>
    <property name="package"
    value="examples/ejb/ejb20/basic/SecuritySystem"/>
    <property name="ejb.client.jar"
    value="ejb20_basic_SecuritySystem_client.jar"/>
    <target name="all" depends="build, deploy"/>
    <target name="build" depends="clean,
    prepare.example,
    build.ear,
    compile.client"/>
    <target name="clean">
    <delete dir="${dist}" failonerror="false"/>
    <delete dir="${examples.build.dir}/${bean.ear}" failonerror="false"/>
    <delete dir="${client.classes.dir}/${package}" failonerror="false"/>
    <delete dir="${client.classes.dir}/${ejb.client.jar}"
    failonerror="false"/>
    </target>
    <!-- prepare directories for split directory deployment -->
    <target name="prepare.example"
    description="Prepare the example for compilation and deployment.">
    <mkdir dir="${dist}"/>
    <mkdir dir="${dist}/META-INF"/>
    <mkdir dir="${dist}/${ejb.name}"/>
    <mkdir dir="${dist}/${ejb.name}/${package}"/>
    <antcall target="copy.files"/>
    </target>
    <!-- copy files for split directory deployment -->
    <target name="copy.files"
    description="Copy example files to distribution structure.">
    <copy todir="${dist}/META-INF">
    <fileset dir="${source}">
    <include name="*application.xml"/>
    </fileset>
    </copy>
    <copy todir="${dist}/${ejb.name}/${package}">
    <fileset dir="${source}">
    <include name="*.java"/>
    <exclude name="Client.java"/>
    </fileset>
    </copy>
    <!-- rename bean to .ejb so that wlcompile
    can recognize its to be EJBGen'd -->
    <copy file="${source}/SecurityEJB.java"
    tofile="${dist}/${ejb.name}/${package}/SecurityEJB.ejb"/>
    </target>
    <!-- compile EAR for split directory deployment -->
    <target name="build.ear">
    <wlcompile srcdir="${dist}" destdir="${examples.build.dir}/${bean.ear}"
    includes="${ejb.name}">
    <ejbgen source="${sourceVersion}"/>
    <javac deprecation="${deprecation}" />
    <javac debug="${debug}" />
    </wlcompile>
    <wlappc source="${examples.build.dir}/${bean.ear}"
    debug="${debug}" deprecation="${deprecation}"/>
    </target>
    <!-- deploy split directory application -->
    <target name="deploy"
    description="Deploy ear to WebLogic on ${wls.hostname}:${wls.port}.">
    <wldeploy
    user="${wls.username}"
    password="${wls.password}"
    adminurl="t3://${wls.hostname}:${wls.port}"
    debug="true"
    action="deploy"
    source="${examples.build.dir}/${bean.ear}"
    failonerror="${failondeploy}"/>
    </target>
    <!-- package the application a J2EE formatted exploded ear -->
    <target name="package.exploded.ear">
    <wlpackage srcdir="${dist}" destdir="${examples.build.dir}/${bean.ear}"
    toDir="${dist}" />
    </target>
    <!-- compile example client -->
    <target name="compile.client" description="Compile client.">
    <!--
    http://bugs.bea.com/WebClarify/CREdit?CR=CR199960
    <move file="${user.dir}/${ejb.client.jar}"
    tofile="${client.classes.dir}/${ejb.client.jar}"
    failonerror="false"/>
    -->
    <copy file="${user.dir}/${ejb.client.jar}"
    tofile="${client.classes.dir}/${ejb.client.jar}"/>
    <delete file="${user.dir}/${ejb.client.jar}"/>
    <javac srcdir="${source}" destdir="${client.classes.dir}"
    deprecation="${deprecation}" debug="${debug}"
    classpath="${ex.classpath};${client.classes.dir}/${ejb.client.jar}"
    includes="Client.java"/>
    </target>
    <!-- Run the example -->
    <target name="run">
    <java classname="examples.ejb.ejb20.basic.SecuritySystem.Client"
    fork="yes" failonerror="true">
    <arg value="t3://${wls.hostname}:${wls.port}"/>
    <classpath>
    <pathelement
    path="${ex.classpath};${client.classes.dir}/${ejb.client.jar}"/>
    </classpath>
    </java>
    </target>
    </project>
    Here is the output that I am getting:
    build.ear:
    [ejbgen] EJBGen 9.0
    [ejbgen] Creating
    C:\bea\weblogic90\samples\server\examples\build\ejb20State
    lessEar\ejb20StatelessEjb\\ejb-jar.xml
    [ejbgen] Creating
    C:\bea\weblogic90\samples\server\examples\build\ejb20State
    lessEar\ejb20StatelessEjb\\weblogic-ejb-jar.xml
    [ejbgen] Creating
    C:\bea\weblogic90\samples\server\examples\build\ejb20State
    lessEar\ejb20StatelessEjb\ejbgen-build.xml
    [move] Moving 2 files to
    C:\bea\weblogic90\samples\server\examples\build\ej
    b20StatelessEar\ejb20StatelessEjb\META-INF
    [javac] Compiling 1 source file to
    C:\bea\weblogic90\samples\server\examples
    \build\ejb20StatelessEar\ejb20StatelessEjb
    [javac] Compiling 5 source files to
    C:\bea\weblogic90\samples\server\example
    s\build\ejb20StatelessEar\ejb20StatelessEjb
    [wlappc] <Oct 28, 2005 8:51:48 PM EDT> <Info> <J2EE> <BEA-160186>
    <Compiling
    EAR module 'ejb20StatelessEjb'>
    [wlappc] <Oct 28, 2005 8:51:49 PM EDT> <Error> <J2EE> <BEA-160187>
    <weblogic.
    appc failed to compile your application. Recompile with the -verbose
    option for
    more details. Please see the error message(s) below.>
    <b>BUILD FAILED</b>
    C:\bea\weblogic90\samples\server\examples\src\examples\ejb\ejb20\basic\SecurityS
    ystem\build.xml:68: weblogic.utils.compiler.ToolFailureException:
    <b>VALIDATION PROBLEMS WERE FOUND</b>
    C:\bea\weblogic90\samples\server\examples\src\examples\ejb\ejb20\basic\Securit
    ySystem\ejb20StatelessEar\ejb20StatelessEjb\META-INF\ejb-jar.xml:13:6:13:6:
    prob
    lem: cvc-complex-type.2.4c: Expected elements
    'session@http://java.sun.com/xml/n
    s/j2ee entity@http://java.sun.com/xml/ns/j2ee
    message-driven@http://java.sun.com
    /xml/ns/j2ee' before the end of the content in element
    enterprise-beans@http://j
    ava.sun.com/xml/ns/j2ee:<C:\bea\weblogic90\samples\server\examples\src\examples\
    ejb\ejb20\basic\SecuritySystem\ejb20StatelessEar\ejb20StatelessEjb/META-INF/ejb-
    jar.xml:13:6>
    Total time: 2 minutes 8 seconds
    C:\bea\weblogic90\samples\server\examples\src\examples\ejb\ejb20\basic\SecurityS
    ystem>
    This is the part of the output whee the error message appears and I think
    this is the one you want. Hope you can figure out what the problem is here
    coz as I said, this is my first EJB program. Thanks

  • The Naming problem in my first ejb program.

    Dear experts,
    I am new to Enterprise applications.
    I am ,now, in my first step in developinf Enterprise Java bean.
    I use Sun System Application Server.
    The following s my very first code:
    Hello.java (Remote interface)
    import java.rmi.*;
    import javax.ejb.*;
    public interface Hello extends EJBObject{
         public void displayMessage() throws RemoteException;
    HelloHome.java (Home interface)
    import java.rmi.*;
    import javax.ejb.*;
    public interface HelloHome extends EJBHome{
         public Hello create() throws RemoteException,CreateException;
    HelloBean.java (Bean Implementation class)
    import java.rmi.*;
    import javax.ejb.*;
    public class HelloBean implements SessionBean{
         public void displayMessage(){
              System.out.println("Success..Success..SLK won atlast");
         public void ejbCreate(){
         public void ejbRemove(){
         public void ejbActivate(){
         public void ejbPassivate(){
         public void setSessionContext(SessionContext ct){
    I did go thro the following steps:
    1.I save all these files inside c:\MyEjb folder.
    2.First I compile the following files with javac complier
         Hello.java,HelloHome.java and HelloBean.java
    3.I open deploytool and created a Application HelloApplication.It gives me HelloApplication.ear file inside c:\MyEjb folder.
    4.I created a bean jar into the HelloApplication.The bean jar created is Hello.jar.
    5.Then I deploy HelloApplication with out checking/selecting the Return Client jar check box.
    6.After the application is deployed, I select, from the tree view,LocalHost 4848.
    I select HelloApplication from the deployed applications list, and click the Click Jar...button.It returns HelloApplicationClient.jar into c:\MyEjb folder.
    Here goes my Client java file:
    HelloClient.java
    import javax.ejb.*;
    import javax.naming.*;
    import java.rmi.*;
    import java.util.*;
    public class HelloClient{
         public static void main(String s[]){
              try{
                   Properties prop = new Properties();
                   prop.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
                   prop.put(javax.naming.Context.PROVIDER_URL,"file:c:\\");
                   Context ctx = new InitialContext(prop);
                   HelloHome hHome = (HelloHome)ctx.lookup("Hello");
                   Hello hObj = hHome.create();
                   hObj.displayMessage();
              }catch(Exception e){
                   e.printStackTrace();
    This also is in C:\MyEjb folder.
    Now I compile HelloClient.java.
    Then I tried to run HelloClient using java HelloClient
    It just says javax.naming.NameNotFoundException:Hello
    Why is this so? Does Sun App server uses any other naming service than FileSystem (fscontext) like CORBA Naming service COS Naming?If so I can download COS Naming provider and use that in my client code.
    Is this correct way to run my client code? or should I go thro File->New->Application Client...etc and use appclient utility?
    I tried that too and run using the command appclient -client HelloAppClient.jar -mainclass HelloClient
    Again I get the same exception,javax.naming.NameNotFoundException:Hello.
    I checked the JNDI Name for my HelloBean and its correctly set as 'Hello'.
    Why is this error? Should I have any special folder structure to run EJB?
    Help me resolve this.
    Thanx in advance
    unique

    Try rewriting your Hello client like this:
    import javax.ejb.*;
    import javax.naming.*;
    import java.rmi.*;
    import java.util.*;
    public class HelloClient
        public static void main(String s[])
            try
                Context initial = new InitialContext();
                Content myEnv   = (Context)initial.lookup("java:comp/env");
                Object o        = myEnv.lookup("ejb/Hello");
                HelloHome hHome = (HelloHome)PortableRemoteObject.narrow(o, HelloHome.class);
                Hello greeter   = hHome.create();
                greeter.displayMessage();
            catch(Exception e)
                e.printStackTrace();
    }See if that's better.

  • Weblogic 10.3 First EJB bean invocation is throwing NameNotFoundException

    I'm gettting the below error, during the first invocation of the EJB session bean in weblogic 10.3. Please help on this.
    org.springframework.remoting.RemoteLookupFailureException: Failed to locate remote EJB [TestSessionBean]; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'TestSessionBean'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'TestSessionBean'. Resolved '']; remaining name 'TestSessionBean'
    Caused by: javax.naming.NameNotFoundException: Unable to resolve 'TestSessionBean'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'TestSessionBean'. Resolved '']; remaining name 'TestSessionBean'
    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
    at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
    at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
    at weblogic.jndi.internal.ServerNamingNode_1030_WLStub.lookup(Unknown Source)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:392)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:380)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:123)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:121)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:146)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:91)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.lookup(AbstractRemoteSlsbInvokerInterceptor.java:92)
    at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.getHome(AbstractSlsbInvokerInterceptor.java:147)
    at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.create(AbstractSlsbInvokerInterceptor.java:171)
    at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.newSessionBeanInstance(AbstractRemoteSlsbInvokerInterceptor.java:205)
    at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.getSessionBeanInstance(SimpleRemoteSlsbInvokerInterceptor.java:108)
    at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.doInvoke(SimpleRemoteSlsbInvokerInterceptor.java:74)
    at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.invoke(AbstractRemoteSlsbInvokerInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy60.loadMyData(Unknown Source)
    at com.test.MyController.formBackingObject(MyController.java:74)
    at org.springframework.web.servlet.mvc.AbstractFormController.getErrorsForNewForm(AbstractFormController.java:343)
    at org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:323)
    at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:263)
    at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:819)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:754)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:399)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:354)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(Unknown Source)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.execute(Unknown Source)
    at weblogic.servlet.internal.ServletRequestImpl.run(Unknown Source)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: javax.naming.NameNotFoundException: Unable to resolve 'TestSessionBean'. Resolved ''
    at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
    at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:252)
    at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
    at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
    at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
    at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    ... 2 more
    Edited by: 940874 on Jun 15, 2012 4:34 AM

    ur prob has been resolved? I want to the resolution becoz m facing the same error for setting up proxy for RSS Feeds.
    pls let me know the fix,
    thanks, ripan

  • Java.lang.NoClassDefFoundError when trying to create my first EJB

    Hi All,
    I am trying to learn EJB's on my own. I installed the WebLogic Server Trial version and then wrote the Home Interface, Component Interface and the Bean Class. Now I started the WebLogic server and tried and create the deployment descriptor.. I am getting the error below even after I set the classpath. Is there any other correct way to set the classpath?
    C:\bea\jdk150_04\bin\ejb\demo>set classpath=C:\bea\weblogic92\server\lib\weblogic.jar;
    C:\bea\jdk150_04\bin\ejb\demo>java weblogic.ejb.utils.DDCreator -dir dploymentDescriptor.txt
    Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/ejb/utils/DDCreator
    Please help me.
    Thanks.

    If you're just learning EJBs now I'd recommend you start with the EJB 3.0 API. It's much
    easier to use than past releases and otherwise much of what you learn (e.g. Home/Component
    interfaces) are not emphasized in EJB 3.0. You can start with the EJB chapters in the
    Java EE 5 Tutorial :
    http://java.sun.com/javaee/5/docs/tutorial/doc/
    We have some additional resources here :
    https://glassfish.dev.java.net/javaee5/ejb/
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need help to run  The First EJB program

    hello i m new to the ejb
    i tried to run the very simple exaple i was able to compile the following code and deploy them to the j2ee server but i wavs un able to run the cilent program in the same machine
    here are the codes
    // this is remote intterface class
    public interface remote extends javax.ejb.EJBObject{
    public String show() throws java.rmi.RemoteException;
    //home interface
    import javax.ejb.*;
    import java.rmi.*;
    public interface homeinter extends EJBHome{
    remote create()throws CreateException,RemoteException;
    //bean
    import javax.ejb.SessionBean;
    import javax.ejb.EJBException;
    import java.rmi.RemoteException;
    import javax.ejb.SessionContext;
    public class bean implements SessionBean {
    SessionContext sct;
    public String show() throws RemoteException {
    return " this is from bean";
    public void ejbActivate(){}
    public void ejbPassivate(){}
    public void ejbCreate(){}
    public void ejbRemove(){}
    public void setSessionContext(SessionContext set){
    this.sct=set;
    // client
    import javax.ejb.*;
    import javax.rmi.*;
    import javax.naming.*;
    import java.rmi.*;
    public class client {
    public static void main(String[] args) {
    try{
    InitialContext ic= new InitialContext();
    Object obj= ic.lookup("MySecond");
    homeinter h=(homeinter)PortableRemoteObject.narrow(obj,homeinter.class);
    remote r=h.create();
    System.out.println("the return value is" + r.show());
    }catch(Exception e){
    e.printStackTrace();
    in the DOS prompt i tried to run the programme like
    set CPATH=.;c:\j2ee\lib\j2ee.jar;secondClient.jar
    java -Dorg.omg.CORBA.ORBInitialHost=lacalhost -classpath %CPATH% client
    then i had the following error mesage
    C:\ejb>set CPATH=.;c:\j2ee\lib\j2ee.jar;secondClient.jar
    C:\ejb>java -Dorg.omg.CORBA.ORBInitialHost=Localhost -classpath .;c:\j2ee\lib\
    j2ee.jar;secondClient.jar client
    Exception in thread "main" 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)
    at com.sun.enterprise.naming.SerialContext.<init>(SerialContext.java:79)
    at com.sun.enterprise.naming.SerialInitContextFactory.getInitialContext(
    SerialInitContextFactory.java:54)
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at client.main(client.java:10)
    pls give me a solution
    thank you

    1. which app server u r using ? R u using RI ?
    2. what is this secondclient.jar ?
    3. Have u added server specific jar containing implementation of IntialConrtextFactory in the classpath of client?
    4. If using RI, then I suppose u will have to set "Support Client Choice" (Possibly) to true, then generate client.jar.
    5. Which IDE u r using (If any) ?
    6. Are u sure that ur jar file (containng EJBs) deployed successfully ?
    7. Almost every server provides GUI console sort of , u can check whether it was deployed successfuly ?
    Pls update
    GiveMeJ
    Sanjeev

  • Need Help For My First EJB Application!

    Hi, all
    I was learning EJB 3days agao and it took me 3days to write a hello world program, however, I did not figure out how to do it, everytime I run it , it shows up a exception called "NameNotFoundException" and it really drive me creazy, so if anyone who know how to configure the computer envirement or anything that make the Hello World program run, please reply,
    Thanks to anyone who read and reply this.

    There's a simple hello world ejb example in the Java EE 5 tutorial. Try going through that.
    http://java.sun.com/javaee/5/docs/tutorial/doc/
    We also have a few simple examples on our Glassfish ejb page :
    https://glassfish.dev.java.net/javaee5/ejb/EJB30.html
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Can not find my EJB's from my Servlet

    Hi
    I am new to EJB and am trying to get a Servlet to call some sessionless EJB beans. I have got it working in JDeveloper but when I deploy it to orion application server I keep getting a javax.naming.NameNotFoundException exception throw from the Servlet when it tries to find the first EJB.
    The code in the Servlet is:
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "jewels");
    // env.put(Context.PROVIDER_URL, "ormi://localhost:23891/current-workspace-app");
    env.put(Context.PROVIDER_URL, "ormi://localhost:23791/dev");
    Context ctx = new InitialContext(env);
    System.out.println("Getting mapping class ejb");
    //mapping
    ExponentMappingServiceHome mappingHome = (ExponentMappingServiceHome)ctx.lookup("ExponentMappingServiceHome");
    ExponentMappingService mapping = mappingHome.create();
    My EJB xml looks like this:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!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>
    <description>Session Bean ( Stateless )</description>
    <display-name>ExponentMappingService</display-name>
    <ejb-name>ExponentMappingService</ejb-name>
    <home>com.exponent.ejb.service.map.ExponentMappingServiceHome</home>
    <remote>com.exponent.ejb.service.map.ExponentMappingService</remote>
    <ejb-class>com.exponent.ejb.service.map.ExponentMappingServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>ExponentMappingViewsService</display-name>
    <ejb-name>ExponentMappingViewsService</ejb-name>
    <home>com.exponent.ejb.service.map.ExponentMappingViewsServiceHome</home>
    <remote>com.exponent.ejb.service.map.ExponentMappingViewsService</remote>
    <ejb-class>com.exponent.ejb.service.map.ExponentMappingViewsServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>FalconService</display-name>
    <ejb-name>FalconService</ejb-name>
    <home>com.exponent.ejb.service.FalconServiceHome</home>
    <remote>com.exponent.ejb.service.FalconService</remote>
    <ejb-class>com.exponent.ejb.service.FalconServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    I have been trying for a while to get the JNDI naming right but everything I try gets the above error. Any help would be great.
    Thanks
    Andre

    You have to lookup for "ExponentMappingService", and not "ExponentMappingServiceHome"
    The name you give in the <ejb-name> tag in ejb-jar.xml is the JNDI name of the EJB. This is the name u have to look up.

  • Noob Question: Problem with Persistence in First Entity Bean

    Hey folks,
    I have started with EJB3 just recently. After reading several books on the topic I finally started programming myself. I wanted to develop a little application for getting a feeling of the technology. So what I did is to create a AppClient, which calls a Stateless Session Bean. This Stateless Bean then adds an Entity to the Database. For doing this I use Netbeans 6.5 and the integrated glassfish. The problem I am facing is, that the mapping somehow doesnt work, but I have no clue why it doesn't work. I just get an EJBException.
    I would be very thankfull if you guys could help me out of this. And don't forget this is my first ejb project - i might need a very detailed answer ... I know - noobs can be a real ....
    So here is the code of the application. I have a few methods to do some extra work there, you can ignore them, there are of no use at the moment. All that is really implemented is testConnection() and testAddCompany(). The testconnection() Methode works pretty fine, but when it comes to the testAddCompany I get into problems.
    Edit:As I found out just now, there is the possibility of Netbeans to add a Facade pattern to an Entity bean. If I use this, everythings fine and it works out to be perfect, however I am still curious, why the approach without the given classes by netbeans it doesn't work.
    public class Main {
        private EntryRemote entryPoint = null;
        public static void main(String[] args) throws NamingException {
            Main main = new Main();
            main.runApplication();
        private void runApplication()throws NamingException{
            this.getContext();
            this.testConnection();
            this.testAddCompany();
            this.testAddShipmentAddress(1);
            this.testAddBillingAddress(1);
            this.testAddEmployee(1);
            this.addBankAccount(1);
        private void getContext() throws NamingException{
            InitialContext ctx = new InitialContext();
            this.entryPoint = (EntryRemote) ctx.lookup("Entry#ejb.EntryRemote");
        private void testConnection()
            System.err.println("Can Bean Entry be reached: " + entryPoint.isAlive());
        private void testAddCompany(){
            Company company = new Company();
            company.setName("JavaFreaks");
            entryPoint.addCompany(company);
            System.err.println("JavaFreaks has been placed in the db");
        }Here is the Stateless Session Bean. I added the PersistenceContext, and its also mapped in the persistence.xml file, however here the trouble starts.
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    @Stateless(mappedName="Entry")
    public class EntryBean implements EntryRemote {
        @PersistenceContext(unitName="PersistenceUnit") private EntityManager manager;
        public boolean isAlive() {
            return true;
        public boolean addCompany(Company company) {
            manager.persist(company);
            return true;
        public boolean addShipmentAddress(long companyId) {
            return false;
        public boolean addBillingAddress(long companyId) {
            return false;
        public boolean addEmployee(long companyId) {
            return false;
        public boolean addBankAccount(long companyId) {
            return false;
    }That you guys and gals will have a complete overview of whats really going on, here is the Entity as well.
    package ejb;
    import java.io.Serializable;
    import javax.persistence.*;
    @Entity
    @Table(name="COMPANY")
    public class Company implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        @Column(name="COMPANY_NAME")
        private String name;
        public Long getId() {
            return id;
        public void setId(Long id) {
            this.id = id;
       public String getName() {
            return name;
        public void setName(String name) {
            this.name = name;
            System.err.println("SUCCESS:  CompanyName SET");
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (id != null ? id.hashCode() : 0);
            return hash;
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof Company)) {
                return false;
            Company other = (Company) object;
            if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                return false;
            return true;
        @Override
        public String toString() {
            return "ejb.Company[id=" + id + "]";
    }And the persistence.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
      <persistence-unit name="PersistenceUnit" transaction-type="JTA">
        <provider>oracle.toplink.essentials.PersistenceProvider</provider>
        <jta-data-source>jdbc/sample</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
          <property name="toplink.ddl-generation" value="create-tables"/>
        </properties>
      </persistence-unit>
    </persistence>And this is the error message
    08.06.2009 10:30:46 com.sun.enterprise.appclient.MainWithModuleSupport <init>
    WARNUNG: ACC003: Ausnahmefehler bei Anwendung.
    javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
            java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaktion für Zurücksetzung markiert.; nested exception is:
            javax.transaction.RollbackException: Transaktion für Zurücksetzung markiert.
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
            java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaktion für Zurücksetzung markiert.; nested exception is:
            javax.transaction.RollbackException: Transaktion für Zurücksetzung markiert.
            at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:243)
            at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
            at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
            at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
            at ejb.__EntryRemote_Remote_DynamicStub.addCompany(ejb/__EntryRemote_Remote_DynamicStub.java)I spend half the night figuring out whats wrong, however I couldnt find any solution.
    If you have any idea pls let me know
    Best regards and happy coding
    Taggert
    Edited by: Taggert_77 on Jun 8, 2009 2:27 PM

    Well I don't understand this. If Netbeans created a Stateless Session Bean as a facade then it works -and it is implemented as a CMP, not as a BMP as you suggested.
    I defenitely will try you suggestion, just for curiosity and to learn the technology, however I dont have see why BMP will work and CMP won't.
    I also don't see why a stateless bean can not be a CMP. As far as I read it should not matter. Also on the link you sent me, I can't see anything related to that.
    Maybe you can help me answering these questions.
    I hope the above lines don't sound harsh. I really appreciate your input.
    Best regards
    Taggert

  • EJB 3.0 & Netbeans 5.5

    I have tried to create simple EJB 3.0 project with Netbeans 3.0. (SJAS 9.0)
    New project -> Enterprise -> Enterprise application.
    My project is "first", uncheck "Create Web Application module", check "Create Application Client Module".
    Next, I create Stateless Bean.
    In first-ejb-> Source Packages create java package "test".
    In package test right click mouse and select New->File/Folder->Enterprise->Session Bean
    Choose "Next", then create bean "MyTest"
    Session type: Stateless
    Create interface: remote only.
    Add public metod String getAnswer().
    Next in client application main class add Enterprise call.
    In Main.java right click and choose Enterprise resources->Call Enterprise Bean, choose MyTestBean.
    Add some code to main class:
    System.out.println(myTestBean.getAnswer());
    Build, Deploy, Run client application.
    I got NullPointerException in main class and this message in Application Server log:
    Class [ Ltest/MyTestRemote; ] not found. Error while loading [ class first.Main ]
    Error in annotation processing: java.lang.NoClassDefFoundError: Ltest/MyTestRemote;
    I do nothing with code anywere, and not modified any xml files.
    Where could I take any mistakes?
    Thanks you!
    My code:
    package test;
    MyTestRemote.java
    import javax.ejb.Remote;
    * This is the business interface for MyTest enterprise bean.
    @Remote
    public interface MyTestRemote {
        String getAnswer();
    }MyTestBean.java
    package test;
    import javax.ejb.Stateless;
    * @author andrey
    @Stateless
    public class MyTestBean implements test.MyTestRemote {
        /** Creates a new instance of MyTestBean */
        public MyTestBean() {
        public String getAnswer() {
            return "Simple answer";
    }Main.java
    package first;
    import javax.ejb.EJB;
    import test.MyTestRemote;
    * @author andrey
    public class Main {
        @EJB
        private static MyTestRemote myTestBean;
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            System.out.println(myTestBean.getAnswer());
    }

    i think the line would not appear in client console but in server console,please check the server console. make sure you have deploy the ejb

  • Getting started with EJB

    I am trying to run my first EJB program without having to use JBoss or Sun's app server. I want to write a program and understand various jar files, and be able to deploy it in app server of my choice. I looked at example in Java EE tutorial but development and deployment is very specific to Net Beans and Sun's App Server. I am just trying to understand the concept. I understand the code and basic Annotations but not really understanding various .xml files that are required.
    I downloaded the tutorial but it has myriad number of .xml files, I just want to know what's standard and their use, so that It could be used in various app servers.
    I am also trying to understand example "coverter" that comes in Java EE tutorial. My question is how does Client looks up the remote client with just the help of @EJB.

    You might want to take a look at some simple "hello, world" EJB 3.0 examples we have here :
    https://glassfish.dev.java.net/javaee5/ejb/EJB30.html
    They just use ant to package up the applications. There are no deployment descriptors needed.
    A client application that wants to use @EJB is coded as an Application Client component. It runs
    within an application client container and it's the container that injects the Remote EJB reference
    at runtime. You can find more information on this in our EJB FAQ :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

  • How to call an EJB from another EJB

    Hi
    I have a problem here. I need to execute a second EJB which has to get the input from the first EJB as data for execution. So when I call the first EJB, the first EJB should give the data to the second EJB and execute it and provide the result.
    Cheers,
    Raj

    ok.. Here it goes.. I am writing a sample code..
    public class EJB1LogBean implements SessionBean {
    // test is a method of stateless session beam
    public void test ( TestVal val )
    throws RemoteException{
    try {
    EJB2LogHome ejb2Home= (EJB2LogHome)getHome("java:comp/env/ejb/EJB2LogHome",1);
    EJB2Log ejb2Log = ejb2LogHome.create ( val );
    } catch ( CreateException e ) {
         System.out.println("Create Exception occurred ");
         e.printStackTrace();
         } catch ( RemoteException e ) {
         System.out.println( "RemoteException Occured");
    e.printStackTrace();
         throw new RemoteException () ;
         } catch(Exception ee) {
    ee.printStackTrace();
    private EJBHome getHome(String jndiName,int type) {
    try {
    Context context = new InitialContext();
    Object ref = context.lookup( jndiName );
    switch(type)
    case 1:
    EJB2LogHome ejb2LogHome = ( EJB2LogHome )
    PortableRemoteObject.narrow( ref, EJB2LogHome.class );
    return ejb2LogHome;
    } catch ( Exception e ) {
    e.printStackTrace();
    return null;
    }//EJB1LogBean ends
    Here as you can see, EJB1LogBean(session bean) is calling a second EJB, EJB2LogBean (entity bean). TestVal is a sample value object passed. It is plain java class and can vary from app to app and it has got nothing to do with ejbs.
    "java:comp/env/ejb" is a J2EE standard and while getting a home interface, you have to append the home interface class name to "java:comp/env/ejb". Here I am passing "java:comp/env/ejb/EJB2LogHome" and "1" to getHome method, whose job is to get a reference to a home interface. getHome method is a local method. "1" is passed just to give a flexibility to getHome method as you can have more ejbs to invoked. In that case, you can go on adding different case statements for 2, 3 etc.
    The only thing you have to keep in mind is that your deployment descriptor for EJB1LogBean will contain the entires for both the beans i.e. for EJB1LogBean and EJB2LogBean. This is because EJB2LogBean is wrapped by EJB1LogBean.
    Hope this helps.
    Please let me know if you need anything more.
    - Amit

Maybe you are looking for

  • Web service returned error: "Unable to process the request"

    Hello, i´ve created a small Rule Project to test creating webservices. I´m using XSD to define the Rules. After this, i´ve created the .ear file with the webservice generation tool and i´ve deployed the file. I´ve built and deployed the Rule Project

  • Disable Auto-Rotation in OCR Process (Acrobat 9 Pro)

    Is there a way to disable the auto-rotation step as part of the OCR process? I have documents which I assemble in from images of tables. (If I had acces to the text of the tables, I wouldn't be using images of them). I place each screenshot in the co

  • DIRECT DELIVERY RECEIPT HAS RECEIVING DESTINATION_TYPE ISSUE

    hi all, i have issue that create a purchase order with type "standard" and receipt type "direct delivery" line qty=3 shipment qty=3 distribution qty=2,1(two lines) while i creating the receipt it shows the destination_type as "receive" & subinventory

  • Extract all new fields added to  tables

    Hello. I need to extract all fieldnames that have been added to the specific tables in my data dictionary. The user inputs a date then i have a SQL query but i'm not really sure about the results it gives me.   SELECT tabname fieldname as4date FROM D

  • Crystal Reports 11 - Can't double click on report

    I have Crystal Reports 11 install.  When I try and double click on a report I get the message "This action is only valid for applications that have been installed".  I can open the report via the CR11 File Open menu though.  Any idea on how I can fix