7 Replies Latest reply on Dec 13, 2012 2:56 AM by litpuvn

    main class not found


      I am running a simple application client. It just accesses EJB instance and invoke a remote method.
      I am running Glassfish 3.1.2, javaee6,
      Here is the client code:
       try {
                  // TODO code application logic here
                  //System.out.println("Hello world!");
                  System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
                  System.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
                  System.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
                  System.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
                  System.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
                  InitialContext context = new InitialContext();
                  EJBRemote rm = (EJBRemote) context.lookup(EJBRemote.PORTABLE_JNDI);
                  if( rm != null){
                      System.out.println("NOT NULL");
              } catch (NamingException ex) {
                  System.out.println("NOT successful");
                  Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
      i got this exception:
      java.lang.ClassNotFoundException: <mainclass>
              at org.glassfish.appclient.client.acc.UndeployedLaunchable.getMainClass(
              at org.glassfish.appclient.client.acc.AppClientContainer.setClient(AppCl
              at org.glassfish.appclient.client.acc.AppClientContainerBuilder.createCo
              at org.glassfish.appclient.client.acc.AppClientContainerBuilder.newConta
              at org.glassfish.appclient.client.AppClientFacade.createContainerForAppC
              at org.glassfish.appclient.client.AppClientFacade.createContainer(AppCli
              at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFa
              at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.prem
              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(Method.java:601)
              at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Instrumenta
              at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Instrument
      could you help me out?

        • 1. Re: main class not found
          Did you create a class called "mainclass" somewhere? You need to add it to the classpath.
          • 2. Re: main class not found
            no, i didn't . the class simply testme.Main

            and i have set this main class in manifest.

            so, it is testme package, containing Main class, and a static main method.

            this client imports an interface ( the interface to access remote method)

            Edited by: CardM on Dec 9, 2012 9:25 PM
            • 3. Re: main class not found
              if i run it from NetBean ide, hence it works fine.

              anything went wrong here if you know?
              • 4. Re: main class not found
                What are you running from Netbeans? The client or the server?
                Maybe you have that class (or jar with that class) in your netbeans build path somewhere.
                • 5. Re: main class not found
                  so weird that the issue is gone now, perhaps because the computer restarted.

                  • 6. Re: main class not found
                    litpu wrote:
                    so weird that the issue is gone now, perhaps because the computer restarted.
                    No, that was not the reason. Rebooting the computer to fix problems with software is something from the 90's when we were still using Dos and Windows 95.

                    And it was not weird, you only think it is because you don't understand. It is not too productive to go out of your way to keep it that way by labeling stuff weird and then trying to forget about it. Its just too easy.
                    • 7. Re: main class not found
                      yeah, it is my little understanding of JavaEE6 and glassfish and i don't have much time to start reading. So i hope that you understand and not being annoyed when i posted any silly questions.

                      Regarding to the problem of "mainclass" we are discussing, i figured out that when i added gf-client.jar in class-path (i googled and somewhere suggested), manifest file, it causes this problem. Actually java should not throw this exception since it is just a lib.

                      Then i removed it from manifest, because latter i know if is not required for glassfish 3; And add the lib for remote interface instead, then i can now invoke remote session method.

                      thanks for your discussion.