EJB Application Client clarification

Hi EJB Guru,
I would like some clarification on accessing Remote/Local Session Bean using an Application Client. In other word,
there appears to be more than one approach to the same Session bean. Let's start by declaring the Converter EJB:
package converter.ejb;
import java.math.BigDecimal;
import javax.ejb.Remote;
@Remote
public interface Converter {
    public BigDecimal dollarToYen(BigDecimal dollars);
    public BigDecimal yenToEuro(BigDecimal yen);
package converter.ejb;
import java.math.BigDecimal;
import javax.ejb.Stateless;
@Stateless
public class ConverterBean implements converter.ejb.Converter {
    private BigDecimal euroRate = new BigDecimal("0.0070");
    private BigDecimal yenRate = new BigDecimal("112.58");
    public BigDecimal dollarToYen(BigDecimal dollars) {
        BigDecimal result = dollars.multiply(yenRate);
        return result.setScale(2, BigDecimal.ROUND_UP);
    public BigDecimal yenToEuro(BigDecimal yen) {
        BigDecimal result = yen.multiply(euroRate);
        return result.setScale(2, BigDecimal.ROUND_UP);
}I have two method to accessing this bean.
( i ) Lookup JNDI using the following set of code:
package converter.client;
import converter.ejb.Converter;
import java.math.BigDecimal;
import javax.ejb.EJB;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
public class ConverterClient {
    public static void main(String[] args) {
        try {
            InitialContext ctx = new InitialContext();
            ConverterRemote jndiconverter = (ConverterRemote) ctx.lookup("converter.ejb.ConverterRemote");
            BigDecimal param = new BigDecimal("100.00");
            BigDecimal yenAmount = jndiconverter.dollarToYen(param);
            System.out.println("$" + param + " is " + yenAmount + " Yen.");
            BigDecimal euroAmount = jndiconverter.yenToEuro(yenAmount);
            System.out.println(yenAmount + " Yen is " + euroAmount + " Euro.");
            System.exit(0);
        } catch (javax.naming.NamingException ne) {
            System.err.println("Caught an unexpected exception!");
            ex.printStackTrace();
}( ii ) Application Client lookup?
package converter.client;
import converter.ejb.Converter;
import java.math.BigDecimal;
import javax.ejb.EJB;
public class ConverterClient {
    @EJB
    private static Converter converter;
    /** Creates a new instance of Client */
    public ConverterClient(String[] args) {
    public static void main(String[] args) {
        ConverterClient client = new ConverterClient(args);
        client.doConversion();
    public void doConversion() {
        try {
            BigDecimal param = new BigDecimal("100.00");
            BigDecimal yenAmount = converter.dollarToYen(param);
            System.out.println("$" + param + " is " + yenAmount + " Yen.");
            BigDecimal euroAmount = converter.yenToEuro(yenAmount);
            System.out.println(yenAmount + " Yen is " + euroAmount + " Euro.");
            System.exit(0);
        } catch (Exception ex) {
            System.err.println("Caught an unexpected exception!");
            ex.printStackTrace();
}It is the first time I come a cross method ( ii ) and could not get it to work properly. The error message
received were:
SJSAS server side
**RemoteBusinessJndiName: converter.ejb.Converter; remoteBusIntf: converter.ejb.Converter
LDR5010: All ejb(s) of [converter] loaded successfully!
Registering ad hoc servlet: WebPathPath: context root = "/converter", path = "/converter-app-client'
Java Web Start services started for application com.sun.enterprise.appclient.jws.ApplicationContentOrigin@c91c07
registration name=converter
    [email protected]3900 registration name=converter, context
root=/converter/converter-app-client, module name=
, parent=converter
WEB0100: Loading web module [converter:converter-war.war] in virtual server [server] at [/converter]
Class [ Lconverter/ejb/Converter; ] not found. Error while loading [ class converter.client.ConverterClient ]
Error in annotation processing: java.lang.NoClassDefFoundError: Lconverter/ejb/Converter;
deployed with moduleid = converter-app-client
Converter-app-client side
Caught an unexpected exception!
java.lang.NullPointerException
        at converter.client.ConverterClient.doConversion(ConverterClient.java:59)
        at converter.client.ConverterClient.main(ConverterClient.java:53)Here is the JNDI listing in ASADMIN:
C:\>asadmin
Use "exit" to exit and "help" for online help.
asadmin> list-jndi-entries
Jndi Entries for server within root context:
converter.ejb.Converter: javax.naming.Reference
converter.ejb.Converter#converter.ejb.Converter: javax.naming.Reference
jbi: com.sun.enterprise.naming.TransientContext
jdbc: com.sun.enterprise.naming.TransientContext
UserTransaction: com.sun.enterprise.distributedtx.UserTransactionImpl
ejb: com.sun.enterprise.naming.TransientContext
converter.ejb.Converter__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
Command list-jndi-entries executed successfully.
asadmin>My questions are:
( a ) Why does the error occur?
( b ) what is the architecture difference in accessing the same bean? Does JNDI lookup allows one to access EJB from remote host as opposed the method ( ii ) which is only restricted to local access on the same JVM/Container?
( c ) What are the pros & cons between the two?
I am using Application Client to lookup these Session Beans on Netbeans 5.5, SJSAS 9.0, SDK 1.5.0_11 on Windows XP platform.
Any guideance/advice would be very much appreciated.
Thanks alot,
Henry

Hi, may be you can help me with a similar problem that I have, I transcript the post in the netbeans forum, I really hope that you or someone can help me with this. Thanks in advance!
I hope that somebody can help me solving this issue.
Environment:
NetBeans 6.0 beta1 + glassfish b58g fresh installed
Windows XP
Make a new enterprise application with application client. Run the empty Main and it runs ok.
Now create a Stateless Session Bean with hello method.
In the Application Client Main insert a reference to the EJB using the wizard. (@EJB etc...)
invoke the hello method from the main().
right click on libraries from application client and add the application-ejb project
Deploy and it deploys ok, but when you run it throws an exception:
client:
java.lang.NullPointerException
server:
Error in annotation processing: java.lang.NoClassDefFoundError: Lorg/arautos/revista/sacrae/server/business/SACRAEFacadeRemote;
java.io.FileNotFoundException: C:\opt\glassfish-v2-b58g\domains\domain1\applications\j2ee-modules\SACRAE-app-client\SACRAE-ejb.jar (El sistema no puede hallar el archivo especificado)
Remember we added the project to the appclient libraries. If I place the missing file in the applications directory of glassfish it wont work, because when you run it, deploying on the server will erase it again. But, if you copy the jar file in the directory and open it with 7zip or any other application that can keep the file open, when you run it again it will work (because the server is not able to delete the file).
Although this is a workaround, there should be something I am doing wrong to cause this behavior, now when I try to use Java Web Start to execute the client it fails (surprisingly) with this exception:
java.lang.reflect.InvocationTargetException
Caused by: java.lang.NoClassDefFoundError: org/arautos/revista/sacrae/server/business/SACRAEFacadeRemote
at org.arautos.revista.sacrae.client.desktop.Main.main(Main.java:30)
... 21 more
And I don't know where in the domain1 directory place the jar, worse, I don't know how to solve the issue with the ejb-jar in the first place, does anybody has an idea, link, same problem? I have googled, netbeans-ed and java.net-ed a lot but didn't find anything :(
Thanks in advance for any help.
Best Regards.

Similar Messages

  • Netbeans 6.9 Glassfish server 3 EJB application client deployment error

    I have an example that I downloaded from the Netbeans docs and whenever I try to run it on my machine, the application client that is supposed to print out a hello message gives me the following error.
    post-dist:
    dist-directory-deploy:
    pre-run-deploy:
    Initial deploying EntAppClient to D:\SCT400\LIFESPRING EE\EntAppClient\dist\gfdeploy\EntAppClient
    Completed initial distribution of EntAppClient
    deploy?path=D:\SCT400\LIFESPRING EE\EntAppClient\dist\gfdeploy\EntAppClient&name=EntAppClient&force=true failed on GlassFish Server 3
    D:\SCT400\LIFESPRING EE\EntAppClient\nbproject\build-impl.xml:257: The module has not been deployed.
    BUILD FAILED (total time: 1 second)
    The full example of the project is found in the following url [Netbeans project|http://netbeans.org/kb/docs/javaee/javaee-gettingstarted.htm]
    my JDK is 6 update 21 and I'm using Java EE6. Help me through this because my project is anchored on being distributed and I cannot proceed until I get this right.

    I got the same problem, the error log detail is below, I have checked the gf-client.jar, it is right in the folder.
    SEVERE: Exception while loading the app
    java.lang.RuntimeException: java.io.FileNotFoundException: C:\Program%20Files\glassfish-3.0.1\glassfish\modules\gf-client.jar (The system cannot find the path specified)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo$1.run(JavaWebStartInfo.java:259)
    at org.glassfish.appclient.server.core.jws.JavaWebStartState.transition(JavaWebStartState.java:84)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo.start(JavaWebStartInfo.java:253)
    at org.glassfish.appclient.server.core.AppClientServerApplication.start(AppClientServerApplication.java:134)
    at org.glassfish.appclient.server.core.AppClientServerApplication.start(AppClientServerApplication.java:126)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.io.FileNotFoundException: C:\Program%20Files\glassfish-3.0.1\glassfish\modules\gf-client.jar (The system cannot find the path specified)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:114)
    at java.util.jar.JarFile.<init>(JarFile.java:133)
    at java.util.jar.JarFile.<init>(JarFile.java:97)
    at org.glassfish.appclient.server.core.jws.JWSAdapterManager.getGFClientModuleClassPath(JWSAdapterManager.java:612)
    at org.glassfish.appclient.server.core.jws.JWSAdapterManager.addStaticSystemContent(JWSAdapterManager.java:243)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo.addSignedSystemContent(JavaWebStartInfo.java:497)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo.initClientStaticContent(JavaWebStartInfo.java:478)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo.addClientContentToHTTPAdapters(JavaWebStartInfo.java:420)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo.startJWSServices(JavaWebStartInfo.java:312)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo.access$100(JavaWebStartInfo.java:96)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo$1.run(JavaWebStartInfo.java:257)
    ... 35 more
    WARNING: Exception while cleaning module 'org.glassfish.internal.data.EngineRef@f185b0'java.lang.NullPointerException
    java.lang.NullPointerException
    at org.glassfish.appclient.server.core.AppClientDeployer.clean(AppClientDeployer.java:265)
    at org.glassfish.internal.data.EngineInfo.clean(EngineInfo.java:114)
    at org.glassfish.internal.data.EngineRef.clean(EngineRef.java:171)
    at com.sun.enterprise.v3.server.ApplicationLifecycle$1.actOn(ApplicaPEa�POST /forums/post!post.jspa?forumID=972, I got the same problem, the error log detail is below, I have checked the gf-client.jar, it is right in the folder.
    SEVERE: Exception while loading the app
    java.lang.RuntimeException: java.io.FileNotFoundException: C:\Program%20Files\glassfish-3.0.1\glassfish\modules\gf-client.jar (The system cannot find the path specified)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo$1.run(JavaWebStartInfo.java:259)
    at org.glassfish.appclient.server.core.jws.JavaWebStartState.transition(JavaWebStartState.java:84)
    at org.glassfish.appclient.server.core.jws.JavaWebStartInfo.start(JavaWebStartInfo.java:253)
    at org.glassfish.appclient.server.core.AppClientServerApplication.start(

  • J2EE Application Client

    I used Sun Java Studio Enterprise to create a stateful session bean (Cart as in the J2ee Tutorial) and deployed it to Sun Application Server (v7). Then in the same application, I creaed a New EJB Test Application (web based test application) called Cart_TestApp by highlighting the Cart (EJB) node and clicking "Create New EJB Test Application" . Everything is perfect and I could use this Cart_TestApp (once again it is web based test app) to test each function defined in the CartHome, Cart. After that, I created another application client to test this Cart bean. The way I did is that I created another J2EE Application Client called CartTestClient by using Templates-->J2EE--->Application Client. Then in the property sheet of this Application Client, I specified two properties:
    1. Application Server----- Server1 (localhost:8080)
    2. EJB Reference----
    2.1 Reference Name---- ejb/Cart
    2.2 Reference EJB Name----Cart
    2.3 Type---Session
    2.4 Home Interface ----CartHome
    2.5 Remote Interface ---Cart
    After that, I built this Application Client and executed the Application Client, but Studio prompts the following error message:
    You must either set a target application, or provide a client stub jar path in the Sun Java System AS tab on the client property sheet!
    In this case, I clicked ellipse for the "Target Application" on the property sheet, which finally only allows me to specify "Cart_TestApp" , note not Cart(EJB), as the Target Application. And I did it. Finally it works just fine for the Application Test.
    Now my questions are:
    1. How to get the EJB client stub jar in the studio for this Cart (EJB)?
    2. Why does the Application Client work just fine after I specified the "Target Application" item in the property sheet as "Cart_TestApp" since "Cart_TestApp" is only a web based test application for the Cart (EJB)? It seems to me that the EJB Application Client has nothing to do with "Cart_TestApp" since both of them are just test clients (one is web based, another standalone java client). Any insights??
    Thanks.
    Yang

    I have figured it out now and actually Cart_TestApp is just an enterprise application generated by Studio with Cart(EJB) inside. Got confused it with SJSAS v8.

  • EJB 3.0 Application Client threw Remote nested exception

    Hi All,
    I came across the following EJBException message when trying to retrieve an Employee record (entity bean in EJB 3.0) after having successfully added it into EMPLOYEE table using stateless session bean:
    *10/03/2009 8:53:14 PM com.sun.enterprise.appclient.MainWithModuleSupport <init>*
    WARNING: ACC003: Application threw an exception.
    javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: null; nested exception is:
    java.lang.NullPointerException
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: null; nested exception is:
    java.lang.NullPointerException
    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.__EmployeeRemote_Remote_DynamicStub.findEmployee(ejb/__EmployeeRemote_Remote_DynamicStub.java)
    at ejb._EmployeeRemote_Wrapper.findEmployee(ejb/_EmployeeRemote_Wrapper.java)
    at client.EmployeeApplicationClient.printEmployee(EmployeeApplicationClient.java:608)
    at client.EmployeeApplicationClient.main(EmployeeApplicationClient.java:55)
    Below is the code snippets of EmployeeApplicationClient.java:
    public class EmployeeApplicationClient {
        @EJB
        private static EmployeeRemote employeebean1;
        @EJB
        private static EmployeeRemote employeebean2;
        public EmployeeApplicationClient() {}
        public static void main(String[] args)
            EmployeeApplicationClient employee_application_client = new EmployeeApplicationClient();
            employee_application_client.addEmployee(1, John, Smith);
            employee_application_client.printEmployee(1);
        public void addEmployee(int id, String firstname, String surname)
            try {
                Employee employee1 = new Employee();
                employee1.setID(id);                       
                employee1.setfirstname(firstname);                       
                employee1.setsurname(surname);                       
                employeebean1.createEmployee(employee1);
            catch {.....}
        public void printEmployee(int employee_id)
           Employee employee2 =  employeebean2.findEmployee(employee_id);
           System.out.println("employee Id: " + employeebean2.getId());
           System.out.println("employee firstname: " + employeebean2.getfirstname());
           System.out.println("employee surname: " + employeebean2.getsurname());
    }Using employeebean1/employeebean2 in printEmployee() did not make any difference.
    The error message appears to indicate that I have incorrectly structured these methods.
    The deployment of EmployeeBean was successful and employee1 is in EMPLOYEE table via SQL query.
    I am using JDK1.6.07, Glassfish v2 with MySQL 5.0 and Netbeans 6.1 on Windows XP platform.
    Any assistance would be greatly appreciated.
    Thanks,
    Jack

    Hi Ataraxisme,
    Thank you for responding to this post.
    This is a J2EE Application Client that was created and deployed along as an Netbeans EAR (both Application Client and EJB) project which uses resource injection as opposed to JNDI lookup.
    I am trying to get employeeApplicationClient.java to work the same way as the following travelAgentApplicationClient.java example which has successfully retrieved its record record immediately after adding using resource injection:
    public class TravelAgentClient {
        @EJB
        private static TravelAgentRemote travelagent;
        public TravelAgentClient() {
        public static void main(String[] args) {
            TravelAgentClient client = new TravelAgentClient();
            client.doTravelAgent();
        public void doTravelAgent() {
            try {
                Cabin cabin_1 = new Cabin();
                cabin_1.setId(1);
                cabin_1.setName("Master Suite");
                cabin_1.setDeckLevel(1);
                cabin_1.setShipId(1);
                cabin_1.setBedCount(3);
                travelagent.createCabin(cabin_1);
                Cabin cabin_2 = travelagent.findCabin(1);
                System.out.println(cabin_2.getName());
                System.out.println(cabin_2.getDeckLevel());
                System.out.println(cabin_2.getShipId());
                System.out.println(cabin_2.getBedCount());
             ......Thanks,
    Jack

  • Steps to deploy an ejb application and running an ejb client in weblogic server6.1

    steps to deploy an ejb application and steps to run an ejb client in weblogic server6.1
    if the client is an simple java application and if the client is a servlet

    Hi.
    Check out the beanManaged example that ships with WLS and read the accompanying docs. This
    is a simple EJB with a servlet that invokes it.
    Michael
    shekhar sachdev wrote:
    steps to deploy an ejb application and steps to run an ejb client in weblogic server6.1
    if the client is an simple java application and if the client is a servlet--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • How to run application client of an EJB application?

    Hi,
    My EJB application is deployed on websphere. I have written a small java client program to interact with an EJB which is working fine if I compile and run it in websphere studio environment.
    However I am getting runtime exception when I tried to run it at command line.
    RemoteConn.java
    import java.util.Hashtable;
    import com.deque.HelloJavaHome;
    import com.deque.HelloJava;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.ejb.EJBHome;
    import javax.ejb.EJBObject;
    public class RemoteConn {
    public static void main(String[] ar) throws Exception{
    String name="Paruchuri!!";
    String greeting = "";
    try{
    Hashtable env = new Hashtable();
    //env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ws.naming.util.WsnInitCtxFactory");
    env.put(Context.PROVIDER_URL, "iiop://localhost:2809");
    InitialContext initContext = new InitialContext(env);
    Object obj = initContext.lookup("ejb/HelloJavaHome");
    HelloJavaHome home = (HelloJavaHome) javax.rmi.PortableRemoteObject.narrow(obj, HelloJavaHome.class);
    HelloJava remote = home.create();
    greeting = remote.getGreeting(name);
    catch(Exception e){
    e.printStackTrace();
    System.out.println("Greeting::"+ greeting);
    I have set the application ejb client jar in the class path of client program.
    The exception I am getting at runtime is
    Exception in thread "main" java.lang.NoClassDefFoundError: com.ibm.CORBA.iiop.GlobalORBFactory
    at com.ibm.ejs.oa.EJSORBImpl.class$(EJSORBImpl.java:44)
    at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:195)
    at com.ibm.ejs.oa.EJSClientORBImpl.(EJSClientORBImpl.java:93)
    at com.ibm.ejs.oa.EJSClientORBImpl.(EJSClientORBImpl.java:65)
    at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:385)
    at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:284)
    at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:369)
    at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:112)
    at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:422)
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:143)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at RemoteConn.main(RemoteConn.java:38)
    Initially I thought I shuold set some jar file of websphere in the classpath of client. But I did not find such a jar containing the above class in websphere studio.
    Basically the error is generated at the below statement at runtime.
    Object obj = initContext.lookup("ejb/HelloJavaHome");
    The only difference I discovered was that the client application has a descriptor file (application-client.xml ) available to it when it ran in websphere studio,. I guess the same META-INF should be provided to client when it runs at command line.
    Right now I am not using any client descriptor file to run the client program. If the above error is due to not supplying META-INF to the client application, how should I make this folder available to client at runtime?
    I greatly appreciate if I could get help ASAP.
    Thanks

    Hey got what is going on. In order to invoke EJB, deployed on WebSpehre App Server, from application client we need to install either WebSphere Application Pluggable Client or WebSphere Thin client on the workstation. Pluggable client is a wrapper to SUN JRE where as Thin Client uses IBM JRE.

  • Dependency Injection of EJB in application client

    Hello,
    I did a quick search and did not find a similar posting on this. I apologize if I missed one.
    I wrote a simple stateless session bean based on EJB 3.0 specification. I wrote a simple client called TestCVTApplication. I am hoping to inject this EJB. Here is how I defined my application-client.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <application-client xmlns="http://java.sun.com/xml/ns/j2ee"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                                            http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd"
                        version="1.4">
        <ejb-ref>     
            <ejb-ref-name>cvt.server.HelloBean</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <remote>cvt.server.Hello</remote>
            <injection-target>
                <injection-target-class>cvt.client.TestCVTApplication</injection-target-class>
                <injection-target-name>helloEJB</injection-target-name>     
            </injection-target>  
        </ejb-ref>                   
        <callback-handler>
            cvt.client.MyCallbackHandler
        </callback-handler>
    </application-client>When I run my client, I am getting the below exception
    Exception in thread "main" java.lang.InstantiationException: Injection of multiple references to the same target[class = cvt.client.TestCVTApplication, field/property = helloEJB]
    Thanks for your help.
    Mustafa

    Injection is required to be supported in Application Client main classes. This error probably means you have defined two different dependencies that have the same target field name in the main class. Did you put an @EJB annotation in the main class in addition to adding the ejb-ref in the application-client.xml? You should just use either one or the other. Also make sure that the field in the main class has a "static" modifier.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to create and run J2EE application client for Hello World EJB

    Hi
    I am new to NWDS EJB deployment.I have created a "Hello World" bean. But how to deploy it and run using a J2EE application client step by step.
    Also please help in the steps of the deploy tool.
    Thanks in Advance

    Hi Ananda
    Check this link,
    http://help.sap.com/saphelp_nw04/helpdata/en/55/600e64a6793d419b82a3b7d59512a5/content.htm
    cheers
    Sameer

  • I unable to run ejb with application client using oc4j j2ee container

    Hi,
    I have installe oracle9i (1.0.2.2) oc4j j2ee container.
    I unable to run the ejbs . please help me how to run ejbs with application client and which files are shall configure.
    See the client application is :
    public static void main (String []args)
    try {
    //Hashtable env = new Hashtable();
    //env.put("java.naming.provider.url", "ormi://localhost/Demo");
    //env.put("java.naming.factory.initial", "com.evermind.server.ApplicationClientInitialContextFactory");
    //env.put(Context.SECURITY_PRINCIPAL, "guest");
    //env.put(Context.SECURITY_CREDENTIALS, "welcome");
    //Context ic = new InitialContext (env);
    System.out.println("\nBegin statelesssession DemoClient.\n");
    Context context = new InitialContext();
    Object homeObject = context.lookup("java:comp/env/DemoApplication");
    DemoHome home= (DemoHome)PortableRemoteObject.narrow(homeObject, DemoHome.class);
    System.out.println("Creating Demo\n");
    Demo demo = home.create();
    System.out.println("The result of demoSelect() is.. " +demo.sayHello());
    }catch ( Exception e )
    System.out.println("::::::Error:::::: ");
    e.printStackTrace();
    System.out.println("End DemoClient....\n");
    When I am running client application I got this type of Exception
    java.lang.SecurityException : No such domain/application: sampledemo
    at com.evermind.server.rmi.RMIConnection.connect(RMIConnection.java : 2040)
    at com.evermind.server.rmi.RMIConnection.connect(RMIConnection.java : 1884)
    at com.evermind.server.rmi.RMIConnection.lookup(RMIConnection.java : 1491)
    at com.evermind.server.rmi.RMIServer.lookup(RMIServer.java : 323)
    at com.evermind.server.rmi.RMIContext.lookup(RMIConext.java : 106)
    at com.evermind.server.administration.LazyResourceFinder.lookup(LazyResourceFinder.java : 59)
    at com.evermind.server.administration.LazyResourceFinder.getEJBHome(LazyResourceFinder.java : 26)
    at com.evermind.server.Application.createContext(Application.java: 653)
    at com.evermind.server.ApplicationClientInitialContext.getInitialContext(ApplicationClientInitialContextFactory.java :179 )
    at javax.naming.spi.NamingManager.getInitialContext(NamingManger.java : 246)
    at javax.naming.InitialContext.getDefaultInitialCtx(InitialContext.java : 246)
    at javax.naming.InitialContext.init(InitialContext.java : 222)
    at javax.naming.InitialContext.<init>(InitialContext.java : 178)
    at DemoClient.main(DemoClient.java : 23)
    .ear file is copied into applications directory.
    I have configured server.xml file like this
    <application name="sampledemo" path="../applications/demos.ear" />
    demos.ear file Contains following files
    application.xml
    demobean.jar
    Manifest.mf
    demobean.jar file contains following files
    application-client.xml
    Demo.class
    DemoBean.class
    DemoHome.class
    ejb-jar.xml
    jndi.properties
    Mainifest.mf
    Please give me your valuable suggestions. Which are shall i configure .
    Thanks & Regards,
    Badri

    Hi Badri,
    ApplicationClientInitialContextFactory is for clients which got deployed inside OC4J container..
    For looking up EJB from a stand alone java client please use RMIInitialContextFactory..So please change ur code....
    Also please check ur server.xml
    Since you have specified your ejb domain as "sampledemo"
    you have to use that domian only for look up..But it seems that you are looking up for "Demo" domain instead of "sampledemo" domain...So change your code to reflect that..
    Code snippet for the same is :
    Hashtable env = new Hashtable();
    env.put("java.naming.provider.url", "ormi://localhost/sampledemo");
    env.put("java.naming.factory.initial", "om.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "guest");
    env.put(Context.SECURITY_CREDENTIALS, "welcome");
    Context ic = new InitialContext (env);
    Hope this helps
    --Venky                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to call ejb from a Swing gui application client?

    Hi Everyone,
    I am new to EJB and I have question for calling an ejb from a Swing GUI application client. Can anyone give me an example of how my Swing GUI can call an EJB from a SUN ONE Application Server. If anyone can give me some insight, I appreciate it.

    I have looked up various sources and just can't get it to work. I know I have to use the lookup() method, but I have also seen lookups using IIOP://servename......
    Context ctx = getInitialContext();
    DemoHome dhome = (DemoHome)ctx.lookup("demo.DemoHome");
    or
    Context ctx = getInitialContext();
    DemoHome dhome = (DemoHome)ctx.lookup(java:comp/......)
    so can anyone tell what is the difference between using iiop://servername..... as the lookup string and java:comp/......
    and if using java:comp/ what does this mean? Does it mean that lookup() method is looking for the ejb somewhere in this directory. I would really appreciate if someone can give an example of a Swing GUI calling a ejb from an application server and how the code is actually doing the lookup in and what are each steps it goes through.
    Thanks

  • Application Client to call JSP...

    Hi all,
    I am using Websphere to write EJB codes and JSP pages and print report based on data retrieved from database. Every morning, i need to manually print sales reports and copied it to a network folder. I found it very tedious. I planned to write an application client to automate the task at midnite. I managed to call the session bean using the client but how can I call the jsp page to print the report? Is it possible? Can I save the jsp page to network folder automatically? Thank you for your help.
    Regards,
    Dreon

    Here is some simple code to read from a url
    private String loadPage() throws Exception
              StringWriter      out;
              URL                url;
              URLConnection     conn;
              BufferedReader     reader;
              String               inputString;
              out = new StringWriter();
              if ( logLoads ) System.out.println("Running loadPage, for URL : " + url );
              conn = _url.openConnection();
              conn.connect();
              if (DEBUG) System.out.println(" connected to server...");
              _contentType = conn.getContentType();
              if (DEBUG) System.out.println(" got Content Type : " + conn.getContentType() );
              reader = new BufferedReader( new InputStreamReader( conn.getInputStream() ) );
              if (DEBUG) System.out.println(" Ready to read data..." );
              while (true) {
                   inputString = reader.readLine();
                   int index = inputString.toUpperCase().indexOf("<HTML>");
                   if ( index >= 0 ) {
                        if (DEBUG) System.out.println(" found <HTML> tag in line : '" + inputString + "'");
                        out.write( inputString.substring( index, inputString.length() ).trim() + "\n" );
                        break;
              inputString = reader.readLine().trim();
              while ( inputString != null ) {
                   if ( inputString.length() > 0 )
                        out.write( inputString + "\n" );
                   inputString = reader.readLine();
              if (DEBUG) System.out.println(" finished.");
              return out.toString();
    }

  • Combining single transaction between session bean & application client

    Hi All,
    The following transaction exception was encountered when trying to combine a EmployeeSessionBean.create(Employee) method in an application client:
    Application Client output
    SEVERE: null
    javax.transaction.SystemException: org.omg.CORBA.UNKNOWN: ----------BEGIN server-side stack trace----------
    org.omg.CORBA.UNKNOWN: WARNING: IOP00010002: Unknown user exception thrown by the server - exception: org.eclipse.persistence.exceptions.DatabaseException; message:
    Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    Error Code: 0
    Call: INSERT INTO EmployeeDB.Project (ID, NAME) VALUES (?, ?)
    bind => [2 parameters bound]
    Query: InsertObjectQuery(domain.Project@19d2d53) vmcid: OMG minor code: 2 completed: Maybe
    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:117)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:126)
    ----------END server-side stack trace---------- vmcid: OMG minor code: 2 completed: Maybe
    at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:332)
    at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:184)
    at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:873)
    at com.sun.enterprise.transaction.UserTransactionImpl.commit(UserTransactionImpl.java:208)
    at applicationClient(*applicationClient.java:229*)
    GF 3.1 Server log
    WARNING: A system exception occurred during an invocation on EJB EmployeeSessionBean method public void ejb.EmployeeSessionBean.create(Employee) javax.ejb.EJBException
    Caused by: javax.persistence.TransactionRequiredException
    at ejb.EmployeeSessionBean.create(*EmployeeSessionBean.java:27*)
    SEVERE: RAR5027:Unexpected exception in resource pooling
    java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    WARNING: RAR7132: Unable to enlist the resource in transaction. Returned resource to pool. Pool name: [ mysqlPool ]
    WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ mysqlPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.]
    WARNING: Local Exception Stack:
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: cannot add non-XA Resource to global JTS transaction.
    Below is the code snippet of EmployeeSessionBean & client.applicationClient:
    @Stateless
    //@TransactionManagement(TransactionManagementType.BEAN)
    public class EmployeeSessionBean implements EmployeeService {   
        @PersistenceContext(unitName="EmployeeDB-PU")
        private EntityManager manager;
        public void create(Employee employee) {
            manager.persist(employee);  // line 27
    import javax.transaction.UserTransaction;
    public class applicationClient {
    @Resource UserTransaction tx;
    @EJB private static EmployeeService bean;
    try {
        tx.begin();
        Employee employee = new Employee()
            bean.create(employee);
    } finally {
           try {
                 tx.commit();  // line 229
    }How to relinguish transaction on EmployeeSessionBean so that all transaction could take place in applicationClient side only?
    I am trying to apply examples in Pro JPA 2 to a Java EE 6 ManyToMany application.
    Your assistance would be much appreciated.
    Thanks,
    Jack

    Hi r035198x,
    Thank you for some solid advice and would rather JPA take care of all the special cases such as keeping the records unique.
    Below are the changes made as suggested in ( 1 ), ( 2 ), ( 3 ):
    @Entity
    @IdClass(EmployeePK.class)
    @Table(name="EMPLOYEE", catalog="EmployeeDB", schema="")
    public class Employee implements Serializable {
        @Id
        @Column(name="FIRSTNAME")
        private String firstName;
        @Id
        @Column(name="SURNAME")
        private String surName;
        @Id
        @Column(name="DOB")
        @Temporal(TemporalType.DATE)
        private Date dob;
        @ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.EAGER)
        @JoinTable(name="EMPLOYEE_PROJECT", catalog="EmployeeDB", schema="",
               joinColumns={@JoinColumn(name="FIRSTNAME_ID", referencedColumnName="FIRSTNAME"),
                            @JoinColumn(name="SURNAME_ID", referencedColumnName="SURNAME"),
                            @JoinColumn(name="DOB", referencedColumnName="DOB")},
               inverseJoinColumns={@JoinColumn(name="PROJECT_ID")})
            private Set<Project> projects = new HashSet<Project>();
    @Entity
    @Table(name="PROJECT", catalog="EmployeeDB", schema="")
    public class Project implements Serializable {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name="ID")
        private int id;
        @ManyToMany(mappedBy="projects", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.EAGER)
            @JoinTable(name="EMPLOYEE_PROJECT", catalog="EmployeeDB", schema="",
               joinColumns={@JoinColumn(name="PROJECT_ID", referencedColumnName="PROJECT_ID")},
               inverseJoinColumns={@JoinColumn(name="FIRSTNAME_ID", referencedColumnName="FIRSTNAME"),
                            @JoinColumn(name="SURNAME_ID", referencedColumnName="SURNAME"),
                            @JoinColumn(name="DOB_ID", referencedColumnName="DOB")})
        private Set<Employee> employees = new HashSet<Employee>();
    @Stateless
    public class EmployeeSessionBean implements EmployeeService {
        @PersistenceContext(unitName="EmployeeDB-PU") private EntityManager manager;
        public void create(Employee employee)
            manager.persist(employee);
    public class applicationClient {
        @EJB
        private static EmployeeService bean;
        public static void main(String[] args) {
        Employee employee = new Employee()
        bean.create(employee);   // line 209
    } I have diverged slightly from using simple primary key (EMPLOYEE_ID) to composite key class (FIRSTNAME, SURNAME, DOB) to resemble the actual application.
    Also gone back to using non - XADatasources since I am depending on JTA to do all the hardwork on the server side.
    Unfortunately, we have hit a snag once again with the following exception still:
    Application Client Output
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:432)
    at org.glassfish.appclient.client.AppClientFacade.launch(AppClientFacade.java:182)
    at org.glassfish.appclient.client.AppClientGroupFacade.main(AppClientGroupFacade.java:65)
    Caused by: javax.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is:
    org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
    org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
    Caused by: java.io.StreamCorruptedException: WARNING: ORBIO00013: Stream corrupted
    ----------END server-side stack trace---------- vmcid: OMG minor code: 11 completed: Maybe
    at ejb._EmployeeService_Wrapper.create(ejb/_EmployeeService_Wrapper.java)
    at applicationClient(applicationClient.java:209)
    GF 3.1 Server log
    WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream
    org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
    Caused by: java.lang.NullPointerException
    WARNING: ORBIO00013: Stream corrupted
    java.io.StreamCorruptedException: WARNING: ORBIO00013: Stream corrupted
    Your valuable input would be very appreciated.
    Thanks,
    Jack

  • Problem while running ejb application in Oracle Application Server

    I have created sample ejb application in jdeveloper with ejb 3.1 version,
    i also created jsp page which will invoke ejb client and display result,
    its running perfectly in embeded oc4j server, but while deploying application in
    Oracle application server its is giving below error message
    Javax naming exception: unable to find remote interface., i am confusing please give me sollution .

    Hi Mr.Frank,
    i have created remote interface by importing javax.ejb.Remote,
    my interface name is additionEjb
    and i defined a sample method and in my client i called like below
    additionEjb AdditionEjb = (additionEjb)context.lookup("additionEjb");
    In embeded oc4j server its running perfectly but after deploying to OAS below error throwing
    The exception is : javax.naming.NameNotFoundException: additionEjb not found
    Help me regrding this.

  • Calling a webservice from weblogic EJB Application

    Hello,
    I have a webservice running on IIS server. I created a simple java client program to call the webservice and it works fine. However, when I wrapped the same java client program as a EJB Application, I am unable to call the webservice.
    I get the following error:
    ####<Apr 3, 2007 1:59:30 AM CDT> <Info> <WebService> <CASEJBServer> <ExecuteThread: '24' for queue: 'weblogic.kernel.Default'> <<anonymous>> <> <BEA-220094> <An IOException was thrown trying to access the WSDL at the given URL.>
    And
    "java.io.FileNotFoundException: Response: '401: Unauthorized' for url: XXXXXX"
    Could you please give some simple steps as what are the JAR Files required to be included in the Weblogic Server's classpath to call the webservice.
    Thanks.

    To start off you need to make sure that your client api is in the classpath, either in your ejb or your ear or the server classpath.
    The other concern I would have is that it seems you are just not authorized to access the URL.
    - Does the WSDL require credentials? So in other words when you go to the URL are you allowed to access the WSDL without athenticating.
    - How does your Impl get created?
    MyServiceImpl service = new MyServiceImpl()
    If you are using the empty constructor then what is the wsdl endpoint in your jar file since that is the wsdl it will use. If the endpoint is localhost/xxx/xxx then you will have issues since that means your not deployed on localhost. What url is at the endpoint? Do you have access to the url from your server?
    If you are using "new MyServiceImpl(url);" then again is the wsdl locked down because in this case you will need to do somthing like http://username:[email protected]/xxx?wsdl
    Hope this helps.
    -Jesus

  • How to run a pure java application client with ear deployed on 9ias

    Hello all,
    We want to run a pure java application client which is packed with target bean in the same ear file. In the application-client.xml we refer to some EJBs.
    We deployed the ear file which contains ejb jar module and application client module to oracle 9ias 904 through enterprise manager on unix. The jndi.properties we used looks like this
    java.naming.factory.initial=com.evermind.server.rmi.ApplciationClientInitialContextFactory
    java.naming.provider.url=opmn:ormi://opmn_host:opmn_port:oc4j_instance_name/application_name
    java.naming.security.principal=test
    java.naming.security.credentials=test
    Is there anybody knows how to run such an application client? Do we need to provide such a jndi.properties or not at all?
    Thanks,
    9ias user

    Refer OpenEJB User - Oracle ADF Essential and TomEE+
    Also refer Bug in tomee 1.5.2. Fixed in 1.6.
    https://issues.apache.org/jira/browse/TOMEE-756

Maybe you are looking for

  • Spool output not appearing on one page

    Hello Experts, When program runs in foreground, I am getting correct output i.e. ALV blocks are displayed on one page only. But when running same program in background, I got output in spool and when looked at spool output that time I realized that t

  • Creating PDF forms: possible in InDesign?

    Hi there I'd like to create PDF forms to be used for email questionnaires and surveys. The last time I looked into it I found that I needed to create the PDF first and then use another application (I can't remember the name) to add the fields for the

  • Filtering e-mail on iPhone

    Is the a way, when iPhone downloads my e-mail from my office via POP, to filter out unwanted messages or not download certain messages? I'd rather not download e-mail from a tech listserv I'm on, which can mount up and I'd rather check when I get bac

  • Trouble exporting to DVDSP

    I'm trying to export using Quicktime Conversion so as to import into DVD Studio Pro. I keep getting the message: "sequence needs to be rendered first." There isn't a render bar above the sequence. Everything appears fine. What could be the problem? W

  • Setting a security method in Adobe forms

    Hi all, This is th Adobe form developemnt. the output PDF will be downloaded to the Presentation server.When ever i am viwing the PDF Document-> Security.> Show security settings it is showing as 'No security'. But I need to set the set the security