Application client / jndi

hello
how can i get access to a bean running on a application server from a application client that doesn't run i a container ( is not statred e.g. with suns runclient -client... ). what do i have to write in my lookup(..) call? lookup(java:comp/env/ejb...) doesn't work. ( errormessage: " can use java:comp/env only from a j2ee component".)
thanks

You can use the following code to get the reference to Context
* url - url of the app server
* username - username for accessing the appserver
* password - password for accessing the appserver
public static Context getInitialContext(String url, String username, String password)
Context context = null;
try
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL, url);
prop.put(Context.SECURITY_PRINCIPAL, username);
prop.put(Context.SECURITY_CREDENTIALS, password);
context = new InitialContext(prop);
catch (NamingException ne)          
ne.printStackTrace();     
return context;          
"weblogic.jndi.WLInitialContextFactory" is a class specific to WebLogic. You should refer to the documentation for the app server you are using for this fully qualified class name

Similar Messages

  • Env-entry-mapping in orion-application-client not available in JNDI lookup

    I have an application client module in my EAR file that I've configured to auto-start.
    It has a few env-entry defined in it's application-client.xml.
    When I deploy the EAR file to OC4J 10.1.3, the application client module gets started and can access these env-entry properties from its JNDIContext.
    Now, comes the problem. During the deployment process, I edit the Deployment Plan, and change the env-entry property values, and then deploy the application.
    However, the application client module still gets the original values when it does the JNDI lookups of those env-entry names.
    I have checked to see that OC4J creates an orion-application-client.xml during deployment and it shows the env-entry-mapping elements with the updated values.
    Why is the JNDI lookup returning the values from application-client.xml and not the overriden values set in orion-application-client.xml?
    I have tried this on OC4J 10.1.3, as well as 10.1.3.1.0 - got same behavior.
    Is this a bug in OC4J? This seems to work fine with ejb modules, but not application client modules.
    Thanks,
    Kalpak

    Avi!
    Of course, I had tried it before I wrote the question. I put the modified xml file into the application area. After that AS restarts OC4J instance. And then I find my xml without any changes I made! I tried to do the same thing from the AS console. The same!
    Leonid

  • 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

  • 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

  • Application-client.xml - resourceBundle

    Hi..
    I have a problem creating a standalone application client...
    I have crated an application-client.xml file containing ejb-refs to 2 Sessionbeans : Like this ->
    <ejb-ref>
    <ejb-ref-name>bean/AdvisorProxy</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>app.common.proxy.AdvisorProxyHome</home>
    <remote>app.common.proxy.AdvisorProxy</remote>
    </ejb-ref>
    <ejb-ref>
    <ejb-ref-name>bean/AdminProxy</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>app.common.proxy.AdminProxyHome</home>
    <remote>app.common.proxy.AdminProxy</remote>
    </ejb-ref>
    When I try to run my app I get an exception when I try to get my bean through the context :
    java.util.MissingResourceException: Can't find bundle for base name com/evermind/client/assembler/Assembler, locale en_GB
    Is there something else I have to specify anywhere?
    Thanks...
    johan

    This fixed my problem:
    - JNDI initial context factory -
    com.evermind.server.rmi.RMIInitialContextFactory
    - jndi provider url -
    opmn:ormi://servername

  • J2EE Tutorial - Application Client

    Hi,
    I've been trying to work through the J2EE Tutorial and I've come to a complete standstill at the EJB section. I have a few problems.
    First of all my deployment tool does not have a JNDI Names Tag as shown in the Mapping The Enterprize Beans Section (Chapter 19). How do I do this?
    I am getting the following error when I try to run my J2EE Application Client.
    Caught an unexpected exception!
    java.lang.ClassCastException
    at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableR
    emoteObject.java:229)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
    at ConverterClient.main(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:23
    7)
    at com.sun.enterprise.appclient.Main.<init>(Main.java:425)
    at com.sun.enterprise.appclient.Main.main(Main.java:97)
    Caused by: java.lang.ClassCastException
    at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableR
    emoteObject.java:212)
    Finally, can anybody recommend a good tutorial or book as I think the J2EE tutorial is unusually bad.

    http://docs.sun.com/source/819-0079/dgacc.html
    Finally, can anybody recommend a good tutorial or
    book as I think the J2EE tutorial is unusually bad.Search for Mastering EJB by Ed Roman. It should give a better understanding.

  • How to run a application client in jboss?

    Hi guys i'm new to EJB and may have some qns to ask.
    I have create ejb java files, compile and package it as jar. Next i also create the .jsp pages and package it as war. I package the war and jar together with the xml files for deployment. The file works.
    Now i create a java file as an application client along with the application-client.xml file. Next i jar both the class and xml files together.
    Now , how am i going to run the client class file to produce the results since its jar up. I using jboss 4.0 to run the application.
    thanks
    Regards ChongMing

    Your J2SE client code should simply look up the required EJB homes using JNDI, and use the client interface to execute the EJB code. The example interfaces ejb.interfaces.SimpleHome and ejb.interfaces.Simple need to be packaged into the client JAR and placed in the classpath of test.java
    Example:
    import javax.ejb.EJBException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.rmi.PortableRemoteObject;
    import ejb.interfaces.SimpleHome;
    import ejb.interfaces.Simple;
    public class test {
        public static void main(String[] args) {
            try {
                 InitialContext ctx = new InitialContext();
                 SimpleHome home = PortableRemoteObject.narrow(ctx.lookup("ejb/Simple"), SimpleHome.class);
                 Simple simple = home.create(); // or findByPrimaryKey(), etc.
                 simple.aMethod();
            } catch (NamingException ne) {
                // unable to look up SimpleHome
            } catch (EJBException ejbe) {
               // generic EJBException, maybe something went wrong with Simple?
            } catch (ClassCastException cce) {
               // SimpleHome was of the wrong type
    }I may have screwed up the JNDI lookup, as I might not be getting the context correctly, but I usually don't call EJB code from the command line. If I'm wrong, the only thing that will change is that ctx will have to be initialized differently. The rest should work the same.
    Brian

  • Application client troubles

    Hey guys,
    I'm having some trouble getting my application client to pass a message to my jms queue. My code may be right and my queue maybe setup correctly but the input parameter I use to set the InitialContex keep throwing the exception:
    parameter: t3:\\localhost:7001
    The code works on a different laptop (that i don't have access to) so i'm thinking the parameter is being entered wrong :(
    Exception in thread "Main Thread" javax.naming.InvalidNameException: url does not contain //
         at weblogic.corba.j2ee.naming.NameParser.parseURL(NameParser.java:395)
         at weblogic.corba.j2ee.naming.ORBHelper.parseURL(ORBHelper.java:611)
         at weblogic.corba.j2ee.naming.ORBHelper.getORBReference(ORBHelper.java:503)
         at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:85)
         at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:31)
         at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:41)
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
         at javax.naming.InitialContext.init(InitialContext.java:223)
         at javax.naming.InitialContext.<init>(InitialContext.java:197)
         at cms.crown.jms.QueueSend.getInitialContext(QueueSend.java:119)
         at cms.crown.jms.QueueSend.main(QueueSend.java:87)
    Anyone know what my mistake is ;P
    thanks

    Sorry, I stopped using the commandline parameter and hardcoded the url. New error...
    Exception in thread "Main Thread" javax.naming.NameNotFoundException: Exception in lookup.: `weblogic/examples/jms/exampleQueue' could not be found. [Root exception is weblogic.corba.cos.naming.NamingContextAnyPackage.NotFound: IDL:weblogic/corba/cos/naming/NamingContextAny/NotFound:1.0]
         at weblogic.corba.j2ee.naming.Utils.wrapNamingException(Utils.java:65)
         at weblogic.corba.j2ee.naming.ContextImpl.lookup(ContextImpl.java:230)
         at weblogic.corba.j2ee.naming.ContextImpl.lookup(ContextImpl.java:168)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at cms.crown.jms.QueueSend.init(QueueSend.java:47)
         at cms.crown.jms.QueueSend.main(QueueSend.java:93)
    Caused by: weblogic.corba.cos.naming.NamingContextAnyPackage.NotFound: IDL:weblogic/corba/cos/naming/NamingContextAny/NotFound:1.0
         at weblogic.corba.cos.naming.NamingContextAnyPackage.NotFoundHelper.read(NotFoundHelper.java:72)
         at weblogic.corba.cos.naming._NamingContextAnyStub.resolve_any(_NamingContextAnyStub.java:87)
         at weblogic.corba.j2ee.naming.ContextImpl.lookup(ContextImpl.java:208)
         ... 4 more

  • Regarding JMS standalone application client

    Hi,
    I m new to JMS.
    I m using NetBeans IDE and would like to know how can i create connection factories and destinations either administratively or through JNDI.
    Btw, i m writing a simple stand alone application client which has a queuesender and a queuereceiver.
    Regards.

    Hi,
    I m using Jboss4.2.0GA...plz tell me how to create a connection factory and a destination queue......and then how to look them up via JNDI??
    I m writing a simple stand alone application client with a sender and a receiver.
    Regards,
    Chowdary.

  • 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 Are Application Clients Run By OC4J?

    Since no one seems to have an answer to my post concerning utilizing java.util.Timer and java.util.TimerTask in application clients started automatically by OC4J, I will generalize my question.
    If I start the client myself, I would type the following at the command line:
    java -jar myClient.jar myArgument
    This is fairly obvious. My question is this: how exactly does OC4J automatically start the client assuming a client-module with auto-start="true" in orion-application.xml? I would like as much technical minutiae (e.g. reflection, wrappers involved, etc.)as you can provide since I need to know the gory details if I am to attempt to solve my challenging problem.
    Thanks very much for your insight.

    When auto-start="true," we are required to provide the a value for the user attribute of client-module. Of course, that is not required when I run the client manually. Is there a user that is understood when I run the client manually? There is a user specified in the jndi.properties in the client jar file, but I am not sure if that refers to the same thing. (I thought that was more to authenticate the client to the EJB container, whereas I imagine the user attribute is for authenticating the user to the client) I am not sure how the users are related if at all, so I would appreciate any insight. Thanks.

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

  • 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

  • Getting the InitialContext in an application client

    I have an application client deployed in my application. When I run the client like this:
    java -jar reconcile-client/reconcile-client.jar
    It is failing with this exception when trying to look up anything through the InitialContext object:
    Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
            at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
            at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
            at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)
            at aoc.arkansas.ReconcileClient.main(ReconcileClient.java:26)Is there another way I should be running the client? According to this link I shouldn't have to supply any information to the constructor of the InitialContext object. http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/servjndi011.htm

    You missed the part where it says you have to use "oracle.j2ee.naming.ApplicationClientInitialContextFactory" and that you should see "Configuring an Oracle Initial Context Factory" (http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/servjndi011.htm#CIACBCHB). Follow that link and you'll find you have to pass in a map with the "java.naming.factory.initial" property set to that factory, and with the "java.naming.provider.url" property set up to point to the OC4J server.

Maybe you are looking for