公共静态类的YAJSW错误

时间:2012-02-03 16:36:19

标签: java service wrapper java-service-wrapper

我有一个java应用程序,我正在尝试使用YAJSW。它只是一个简单的“Hello World”应用程序,我按照这里的说明进行操作:http://yajsw.sourceforge.net/#mozTocId527639

我做了以下事情:

  • 将我的项目从eclipse导出为可运行的JAR文件。

  • 我跑了genconfig - 没问题

  • 我编辑了wrapper.conf并添加了jar文件的位置

  • 运行runConsole.bat,我收到此错误:

      

    java.lang.IllegalAccessException:class org.rzo.yajsw.app.WrapperJVMMain无法使用修饰符“public static”访问类xxxx的成员

它引用的类是主类,它必须是公共静态的。我卡住了!那里的人有建议吗?

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,(在Java 1.6.0_30-b12上运行yajsw-stable-11.0,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

在我的例子中,包含静态公共main方法的类未被声明为public,因此它是package-private,这是默认值。

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

属于不同包的类不能看到包私有类的公共方法,所以这就是我的问题。请参阅示例https://stackoverflow.com/questions/5260467/public-methods-in-package-private-classes

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

如上所述公开课程解决了我的问题。也许你可以发布关于整个问题的更多细节,有人会发布一个解决方案。 问候 -gf