Search code examples
javaservicewrapperjava-service-wrapper

YAJSW error with public static class


I have a java application I am trying to start using YAJSW. It is just a simple "Hello World" application and I follow the instructions here: http://yajsw.sourceforge.net/#mozTocId527639

I have done the following:

  • exported my project from eclipse as a runnable JAR file.

  • I ran genconfig - no problems

  • I editted wrapper.conf and added the location of the jar file

  • ran runConsole.bat and I get this error:

    java.lang.IllegalAccessException: class org.rzo.yajsw.app.WrapperJVMMain can not access a member of class xxxx with modifiers "public static"

The class it refers to is the main class, which must be public static. I am stuck! Anyone out there with advice?


Solution

  • I had the same problem, (running yajsw-stable-11.0 on Java 1.6.0_30-b12, Win XP Pro v 2002 SP3):

    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|init 
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|ahessian jmx service bound to port 15002
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|set state IDLE->STARTING
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|Win service: before service init
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|starting Process
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|Controller State: UNKNOWN -> WAITING
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|+ ServiceMain callback
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|reporting status 0
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|reporting status 0
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|onstart
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|working dir C:\dev\workspaceTax\socket-proxy
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:32|create script: scripts/trayMessage.gv
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|found script scripts/trayMessage.gv
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|spawning wrapped process
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|started process with pid 3720
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|waiting for termination of process
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|set state STARTING->RUNNING
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:33|[INFO] DefaultFileReplicator - Using "C:\WINDOWS\TEMP\vfs_cache" as temporary files store.
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:33|java.lang.IllegalAccessException: Class org.rzo.yajsw.app.WrapperJVMMain can not access a member of class [...].socketproxy.Proxy with modifiers "public static"
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|Trigger found: Exception
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:33| at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|start script scripts/trayMessage.gv
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:33| at java.lang.reflect.Method.invoke(Unknown Source)
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:33| at org.rzo.yajsw.app.WrapperJVMMain.executeMain(WrapperJVMMain.java:53)
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:33| at org.rzo.yajsw.app.WrapperJVMMain.main(WrapperJVMMain.java:36)
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:33|end script scripts/trayMessage.gv
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:34|process terminated
    INFO|3720/0|Service socket-proxy|12-04-11 11:48:34|Controller State: WAITING -> PROCESS_KILLED
    INFO|wrapper|Service socket-proxy|12-04-11 11:48:34|restart process due to default exit code rule
    

    In my case the class containing the static public main method was not declared public, so it was package-private which is the default.

    class Proxy {
    ...
        public static void main(String args[]) throws IOException{
            ...
            }
    }
    

    Public methods of package private classes are not visible by classes belonging to a different package, so this was the problem in my case. See for example https://stackoverflow.com/questions/5260467/public-methods-in-package-private-classes.

    public class Proxy {
    ...
        public static void main(String args[]) throws IOException{
            ...
            }
    }
    

    Declaring the class public as above solved the problem for me. Maybe you could post some more details about the whole problem and somebody will post a solution. Regards -GF