Application client / jndi

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".)

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;
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)          
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 - got same behavior.
    Is this a bug in OC4J? This seems to work fine with ejb modules, but not application client modules.

    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!

  • 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.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: null; nested exception is:
    at ejb.__EmployeeRemote_Remote_DynamicStub.findEmployee(ejb/
    at ejb._EmployeeRemote_Wrapper.findEmployee(ejb/
    at client.EmployeeApplicationClient.printEmployee(
    at client.EmployeeApplicationClient.main(
    Below is the code snippets of
    public class EmployeeApplicationClient {
        private static EmployeeRemote employeebean1;
        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);
        public void addEmployee(int id, String firstname, String surname)
            try {
                Employee employee1 = new Employee();
            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.

    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 to work the same way as the following example which has successfully retrieved its record record immediately after adding using resource injection:
    public class TravelAgentClient {
        private static TravelAgentRemote travelagent;
        public TravelAgentClient() {
        public static void main(String[] args) {
            TravelAgentClient client = new TravelAgentClient();
        public void doTravelAgent() {
            try {
                Cabin cabin_1 = new Cabin();
                cabin_1.setName("Master Suite");
                Cabin cabin_2 = travelagent.findCabin(1);

  • 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 we used looks like this
    Is there anybody knows how to run such an application client? Do we need to provide such a or not at all?
    9ias user

    Refer OpenEJB User - Oracle ADF Essential and TomEE+
    Also refer Bug in tomee 1.5.2. Fixed in 1.6.

  • Application-client.xml - resourceBundle

    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 ->
    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?

    This fixed my problem:
    - JNDI initial context factory -
    - jndi provider url -

  • J2EE Tutorial - Application Client

    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!
    at javax.rmi.PortableRemoteObject.narrow(
    at ConverterClient.main(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    at java.lang.reflect.Method.invoke(
    at com.sun.enterprise.util.Utility.invokeApplicationMain(
    at com.sun.enterprise.appclient.Main.<init>(
    at com.sun.enterprise.appclient.Main.main(
    Caused by: java.lang.ClassCastException
    Finally, can anybody recommend a good tutorial or book as I think the J2EE tutorial is unusually bad.
    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.
    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
    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.
            } 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.

  • 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(
         at weblogic.corba.j2ee.naming.ORBHelper.parseURL(
         at weblogic.corba.j2ee.naming.ORBHelper.getORBReference(
         at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(
         at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(
         at weblogic.jndi.WLInitialContextFactory.getInitialContext(
         at javax.naming.spi.NamingManager.getInitialContext(
         at javax.naming.InitialContext.getDefaultInitCtx(
         at javax.naming.InitialContext.init(
         at javax.naming.InitialContext.<init>(
    Anyone know what my mistake is ;P

    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(
         at weblogic.corba.j2ee.naming.ContextImpl.lookup(
         at weblogic.corba.j2ee.naming.ContextImpl.lookup(
         at javax.naming.InitialContext.lookup(
    Caused by: weblogic.corba.cos.naming.NamingContextAnyPackage.NotFound: IDL:weblogic/corba/cos/naming/NamingContextAny/NotFound:1.0
         at weblogic.corba.cos.naming._NamingContextAnyStub.resolve_any(
         at weblogic.corba.j2ee.naming.ContextImpl.lookup(
         ... 4 more

  • Regarding JMS standalone application client

    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.

    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.

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

    I have installe oracle9i ( 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:::::: ");
    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( : 2040)
    at com.evermind.server.rmi.RMIConnection.connect( : 1884)
    at com.evermind.server.rmi.RMIConnection.lookup( : 1491)
    at com.evermind.server.rmi.RMIServer.lookup( : 323)
    at com.evermind.server.rmi.RMIContext.lookup( : 106)
    at com.evermind.server.administration.LazyResourceFinder.lookup( : 59)
    at com.evermind.server.administration.LazyResourceFinder.getEJBHome( : 26)
    at com.evermind.server.Application.createContext( 653)
    at com.evermind.server.ApplicationClientInitialContext.getInitialContext( :179 )
    at javax.naming.spi.NamingManager.getInitialContext( : 246)
    at javax.naming.InitialContext.getDefaultInitialCtx( : 246)
    at javax.naming.InitialContext.init( : 222)
    at javax.naming.InitialContext.<init>( : 178)
    at DemoClient.main( : 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
    demobean.jar file contains following files
    Please give me your valuable suggestions. Which are shall i configure .
    Thanks & Regards,

    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

  • 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 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;
    public interface Converter {
        public BigDecimal dollarToYen(BigDecimal dollars);
        public BigDecimal yenToEuro(BigDecimal yen);
    package converter.ejb;
    import java.math.BigDecimal;
    import javax.ejb.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.");
            } catch (javax.naming.NamingException ne) {
                System.err.println("Caught an unexpected exception!");
    }( ii ) Application Client lookup?
    package converter.client;
    import converter.ejb.Converter;
    import java.math.BigDecimal;
    import javax.ejb.EJB;
    public class ConverterClient {
        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);
        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.");
            } catch (Exception ex) {
                System.err.println("Caught an unexpected exception!");
    }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 [email protected]
    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!
            at converter.client.ConverterClient.doConversion(
            at converter.client.ConverterClient.main( is the JNDI listing in 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,

    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.
    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:
    Error in annotation processing: java.lang.NoClassDefFoundError: Lorg/arautos/revista/sacrae/server/business/SACRAEFacadeRemote; 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:
    Caused by: java.lang.NoClassDefFoundError: org/arautos/revista/sacrae/server/business/SACRAEFacadeRemote
    at org.arautos.revista.sacrae.client.desktop.Main.main(
    ... 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 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.

    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();
              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" );
              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([email protected]) vmcid: OMG minor code: 2 completed: Maybe
    at com.sun.gjc.spi.base.DataSource.getConnection(
    at org.eclipse.persistence.sessions.JNDIConnector.connect(
    ----------END server-side stack trace---------- vmcid: OMG minor code: 2 completed: Maybe
    at com.sun.jts.jta.TransactionManagerImpl.commit(
    at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(
    at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(
    at com.sun.enterprise.transaction.UserTransactionImpl.commit(
    at applicationClient(**)
    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(**)
    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:
    public class EmployeeSessionBean implements EmployeeService {   
        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 {
        Employee employee = new 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.

    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 ):
    @Table(name="EMPLOYEE", catalog="EmployeeDB", schema="")
    public class Employee implements Serializable {
        private String firstName;
        private String surName;
        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")},
            private Set<Project> projects = new HashSet<Project>();
    @Table(name="PROJECT", catalog="EmployeeDB", schema="")
    public class Project implements Serializable {
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        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>();
    public class EmployeeSessionBean implements EmployeeService {
        @PersistenceContext(unitName="EmployeeDB-PU") private EntityManager manager;
        public void create(Employee employee)
    public class applicationClient {
        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
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.glassfish.appclient.client.acc.AppClientContainer.launch(
    at org.glassfish.appclient.client.AppClientFacade.launch(
    at org.glassfish.appclient.client.AppClientGroupFacade.main(
    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: WARNING: ORBIO00013: Stream corrupted
    ----------END server-side stack trace---------- vmcid: OMG minor code: 11 completed: Maybe
    at ejb._EmployeeService_Wrapper.create(ejb/
    at applicationClient(
    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 WARNING: ORBIO00013: Stream corrupted
    Your valuable input would be very appreciated.

  • 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(
            at javax.naming.InitialContext.getDefaultInitCtx(
            at javax.naming.InitialContext.getURLOrDefaultInitCtx(
            at javax.naming.InitialContext.lookup(
            at aoc.arkansas.ReconcileClient.main( 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.

    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" ( 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