7 Replies Latest reply: Dec 12, 2012 8:56 PM by 859967 RSS

    main class not found

    859967
      Hi,

      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");
                  }
                  System.out.println("Successful!");
              } 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(
      UndeployedLaunchable.java:218)
              at org.glassfish.appclient.client.acc.AppClientContainer.setClient(AppCl
      ientContainer.java:324)
              at org.glassfish.appclient.client.acc.AppClientContainerBuilder.createCo
      ntainer(AppClientContainerBuilder.java:185)
              at org.glassfish.appclient.client.acc.AppClientContainerBuilder.newConta
      iner(AppClientContainerBuilder.java:172)
              at org.glassfish.appclient.client.AppClientFacade.createContainerForAppC
      lientArchiveOrDir(AppClientFacade.java:492)
              at org.glassfish.appclient.client.AppClientFacade.createContainer(AppCli
      entFacade.java:454)
              at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFa
      cade.java:269)
              at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.prem
      ain(AppClientContainerAgent.java:82)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:601)
              at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Instrumenta
      tionImpl.java:382)
              at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Instrument
      ationImpl.java:397)
      could you help me out?

      thanks,
        • 1. Re: main class not found
          r035198x
          Did you create a class called "mainclass" somewhere? You need to add it to the classpath.
          • 2. Re: main class not found
            859967
            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
              859967
              if i run it from NetBean ide, hence it works fine.

              anything went wrong here if you know?
              • 4. Re: main class not found
                r035198x
                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
                  859967
                  so weird that the issue is gone now, perhaps because the computer restarted.

                  thanks,
                  • 6. Re: main class not found
                    gimbal2
                    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
                      859967
                      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.