Thursday, May 18, 2023

How to fix "java.lang.SecurityException: Missing required Permissions manifest attribute in main jar" [Solved]

If you are working Java Web start application using JNLP and suddenly started throwing "java.lang.SecurityException: Missing required Permissions manifest attribute in the main jar", then check whether you have updated the Java or JRE on your machine. From JDK 1.7 update 51, Java has tightened the security further with a number of changes like

1) Block all self-signed and unsigned Java applications and Applets if you have opted for HIGH security in Java Control Panel, which is also the default one.

2) Require a "Permission" attribute for a High-security setting

3) Warning users of missing permission attributes for the medium security settings.


In order to fix this error, you must first know about the "Permission" attribute in the Manifest file. This attribute tells Java Runtime what permission an Applet needs to run on a user machine. You must add this attribute before signing your JAR file. This attribute can be set to two values:

sandbox 

Application with this permission level runs in a security sandbox and doesn't need additional permissions.

all-permissions

The application needs to access the user's system resource e.g. file system, network, and other resources.


If you cannot modify the JAR file and subsequently the manifest, then the only option left with you is to relax security settings in your machine. This may make your machine vulnerable to various Java security attacks but this is what you can do without modifying the manifest file and signing the JAR file again.

If you are new to modify the manifest file, see this tutorial http://docs.oracle.com/javase/tutorial/deployment/jar/modman.html


How to change Security Settings of Java

In order to change the security settings of Java, go to the Java Control Panel like in Windows, click Start and Configure Java, or in Windows 8, just press window + C and search Configure Java option.

It will open the "Java Control Panel" as shown below:

Cause of "java.lang.SecurityException: Missing required Permissions manifest attribute in main jar"


From Java 8 onwards, Java has removed the MEDIUM security setting as well. If you are using the JNLP file to launch your Java web start application, make sure you set the same permission level in JNLP file and manifest file e.g. Permissions: sandbox.

That's all about how to deal with "java.lang.SecurityException: Missing required Permissions manifest attribute in the main jar" error. Java has taken some serious steps to tighten the security in the past couple of years and hence you must list necessary permission in your JAR's manifest file to make sure your Java web application runs fine in Java's increased secure environment.



Other Java troubleshooting tutorials and guides
  • How to solve java.sql.BatchUpdateException: String or binary data would be truncated (guide)
  • Solving OutOfMememoryError "Not able to create new thread" in Java? (solution)
  • How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver error? (hint)
  • 5 Reasons of NoClassDefFoundError in Java? (tutorial)
  • How to fix Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger (solution)
  • How to fix "illegal start of expression" compile time error in Java? (tutorial)
  • How to fix "Error: Could not find or load main class" in Eclipse? (guide)
  • 10 common reasons of java.lang.NumberFormatException in Java? (tutorial)
  • java.sql.SQLException: No suitable driver found for 'jdbc:mysql://localhost:3306/mysql [Solution]
  • How to solve "variable might not have initialized" compile time error in Java? (answer)
  • How to fix 'javac' is not recognized as an internal or external command (solution)
  • How to avoid ConcurrentModificationException in Java? (tutorial)
  • How to solve java.lang.OutOfMemoryError: Java Heap Space in Eclipse, Tomcat? (solution)
  • How to solve "could not create the Java virtual machine" error in Java? (solution)
  • Common reasons of java.lang.ArrayIndexOutOfBoundsException in Java? (solution)
  • java.lang.ClassNotFoundException : org.Springframework.Web.Context.ContextLoaderListener (solution)
  • java.sql.SQLServerException: The index 58 is out of range - JDBC (solution)
  • Fixing java.lang.unsupportedclassversionerror unsupported major.minor version 50.0 (solution)
  • java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory error (solution)
  • Cause and solution of "class, interface, or enum expected" compiler error in Java? (fix)
  • How to connect to MySQL database in Java? (tutorial)
  • How to solve java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver? (solution)

Thanks for reading this article. If you find the information given in this article useful then please share it with your friends and colleagues. If you have any questions or feedback then please drop a comment.



No comments:

Post a Comment