【问题标题】:YAJSW error with public static class公共静态类的 YAJSW 错误
【发布时间】:2012-02-26 06:32:55
【问题描述】:

我有一个 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 的成员

它所指的类是主类,必须是public static。我被困住了!有大佬给点建议吗?

【问题讨论】:

  • 您能否上传您作为服务运行的 hello world 代码我想检查它是如何工作的...或者您可以回答我关于 yajsw 的问题...谢谢
  • 我已经不再使用它并找到了另一个解决方案。祝你好运。

标签: java service wrapper java-service-wrapper


【解决方案1】:

我遇到了同样的问题,(在 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 方法的类没有被声明为公共的,所以它是包私有的,这是默认的。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    • 2016-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-26
    相关资源
    最近更新 更多