LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: cianfuzz on March 20, 2013, 05:16:07

Title: SecurityException: sealing violation
Post by: cianfuzz on March 20, 2013, 05:16:07
I don't know much about JAR files being sealed. I know how to create class paths for my program.
Right now my program is as follows:

Engine -> uses LWJGL

My Program -> uses Engine as a library, therefore LWJGL also must be a library.

The problem is when ever I try to run My Program, I get the following exception.

How can I fix the problem??

java.lang.SecurityException: sealing violation: package org.lwjgl.opengl is sealed
at java.net.URLClassLoader.getAndVerifyPackage(URLClassLoader.java:388)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:417)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.lwjgl.util.Display.getAvailableDisplayModes(Display.java:71)
at EasyClip2D.core.ECEngine.setDisplayMode(ECEngine.java:112)
at EasyClip2D.core.ECEngine.<init>(ECEngine.java:76)
at EasyClip2D.core.ECEngine.<init>(ECEngine.java:44)
at easycliptest.EasyClipTest.<init>(EasyClipTest.java:18)
at easycliptest.EasyClipTest.main(EasyClipTest.java:57)
Title: Re: SecurityException: sealing violation
Post by: quew8 on March 20, 2013, 16:16:54
A jar file is sealed from the manifest file, it should begin with "Sealed: true" http://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html (http://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html)

As far as I can see, this is caused by the engine using classes from the opengl package and then you trying to use the same classes in your own code. Since the lwjgl jars are sealed this creates an error. Only solution I see is to open up every lwjgl jar you use and edit the Manifest file, removing the "Sealed: true" line. WARNING this feature is about version control. Remove at your own peril. (what I mean is for God's sake make sure you use the correct jars only.)
Title: Re: SecurityException: sealing violation
Post by: cianfuzz on March 20, 2013, 16:49:10
hmm. That sounds strange to do. I know other engines use lwjgl with out much editing. The idea is the engine just performs tasks on the lwjgl for you and you are also able to use the lwjgl if needed.
Title: Re: SecurityException: sealing violation
Post by: quew8 on March 21, 2013, 17:20:36
But it is working now? I could be wrong, this is just something I remember reading ages back. And do you know for sure (as in have working examples of) that this works normally?
Title: Re: SecurityException: sealing violation
Post by: cianfuzz on March 21, 2013, 18:32:29
No I haven't tried because it's not something I would want people doing when they want to use my engine and in order to work the engine you need the libraries included in your project as well. I dunno, maybe I need to get the source of LWJGL and use it along side my engine. What do you think?
Title: Re: SecurityException: sealing violation
Post by: abcdef on March 22, 2013, 10:12:23
I had this exact same problem, sealing jars is a pain in my opinion (when you use GUI developer tools). I use netbeans and have multiple projects, some doing graphics some doing sound and video etc. The way I got around this project was to just remove the line in the Manifest file of the jar.

The alternative is to run the project from the command line to test it but this prevents you from doing nice things like visual debugging. The sealing makes sense for deployment but the jvm doesn't seem clever enough to realise that two jar files are the same even though they were included from two different directories.

Title: Re: SecurityException: sealing violation
Post by: quew8 on March 22, 2013, 16:55:49
It would seem Java is not perfect, but it is the language we have all chosen. Perhaps this is something you should be taking to the developers in the RFE section. In terms of solving your problem, I would say it would be better to provide downloads for "your own version" of the lwjgl jars with the modified manifest, alongside your engine's jars. You could include the source or wrap the methods but that would just seem like a hassle to me. But it is of coarse up to you. Oh the joys of developing. 
Title: Re: SecurityException: sealing violation
Post by: dangerdoc on April 25, 2013, 00:30:25
In my projects, I just distribute the LWJGL jar files with the program in the libs directory, so the person always gets a working LWJGL jar file.