csk
csk

Reputation: 576

UnauthorizedAccessException while running jar on linux machine

I am getting the following stacktrace while running jar file on a linux machine . However it works perfectly on windows machine

     Exception in thread "Thread-0" java.lang.NoClassDefFoundError: com/sun/servicetag/UnauthorizedAccessException
    at com.montior.activemq.util.MQProperty.loadProperties(MQProperty.java:31)
    at com.montior.activemq.util.MonitorThread.loadProperties(MonitorThread.java:82)
    at com.montior.activemq.util.MonitorThread.run(MonitorThread.java:39)
    at java.lang.Thread.run(Thread.java:679)
    Caused by:java.lang.ClassNotFoundException:com.sun.servicetag.UnauthorizedAccessException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    ... 4 more

And this is my loadProperies() method

    public static void loadProperties() throws FileNotFoundException,IOException,ArgumentMissingException {
        props=new Properties();

        // load a properties file
        String path = "./util.properties";
        props.load(new FileInputStream(new File(path)));
        ActiveMqClient.readProperties(props);


}

Can anyone please help me with this Exception?

Upvotes: 0

Views: 1644

Answers (2)

Anya Shenanigans
Anya Shenanigans

Reputation: 94829

The error is java.lang.ClassNotFoundException caused when looking for the class com.sun.servicetag.UnauthorizedAccessException. I can find this class in the file db/lib/register.jar in the official Oracle JDK. This leads me to the following possible conclusions:

  • You're running with the Oracle JVM under Windows
  • You're not running with the Oracle JVM under Linux (It's probably OpenJDK).

According to mvnrepository, you can find the missing class in the sysnet-registration.jar archive. I used jar-download.com to backtrack from the class name to a jar containing it (not linked as the previous link ended up at a spam farm)

You could try adding that jar to your run-time class-path and see if it solves the issue.

Upvotes: 1

Rupesh
Rupesh

Reputation: 2667

check do you have appropriate access to run applications like java. Try sudo... By default root has these accesses.

You need to have execute permission on file, you can try. chmod +x filename

Upvotes: 0

Related Questions