Create Functional (Signed) Applet (19 posts)

  • Profile picture of joaocartaxo joaocartaxo said 7 months, 2 weeks ago:

    Hello!

    I’m having trouble setting my game Applet to work. I keep getting java.security exceptions:

    java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)

    That are thrown when I try to attach my loadled .obj model to the rootNode.

    I’ve tried to sign my jars (data.jar, code.jar, lwjgl_util_applet.jar, lzma.jar) using keytool and jarsign (I used this example: Link) but it didn’t solve my problem.

    What am I doing wrong?

    Thanks!

  • Profile picture of normen normen1290p said 7 months, 2 weeks ago:

    When you attach the model to the rootNode? There is no reason why jme3 should try and access the user directory then. If the applet starts then jme3 works and extracted everything it needs to. You sure its not your code doing something with temp files or so?

  • Profile picture of joaocartaxo joaocartaxo said 7 months, 2 weeks ago:

    You’re right, I didn’t saw a line in the stack trace.

    The problem is here:

    			File xmlFile = new File("assetsConfigurationsceneLoader.xml");
    			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    			DocumentBuilder db = dbf.newDocumentBuilder();
    			Document doc = db.parse(xmlFile);
    

    when I try to parse the XML file.

  • Profile picture of normen normen1290p said 7 months, 2 weeks ago:

    Yeah, you used a File instead of the AssetManager or class path to load that data. Generally this can only work in the SDK, accessing the assets folder directly like that (and only on windows for that matter) — there is no assets folder later in the game, its compressed into the assets.jar and added to the class path. Use this.getClass().getClassLoader().getResource(“Configuration/sceneLoader.xml”); (with proper forward slashes for the folder :P ) to get an URL to the file. You could also register a text file loader with the AssetManager.

  • Profile picture of joaocartaxo joaocartaxo said 7 months, 2 weeks ago:

    Ok, I’ve used the URL like:

    URL fileURL = app.getClass().getClassLoader().getResource("Configuration/sceneLoader.xml");
    Document doc = db.parse(fileURL.openStream());
    

    And although some Info is read, the final model gets all scrambled

  • Profile picture of normen normen1290p said 7 months, 2 weeks ago:

    So you probably have bugs in your software, the initial issue seems to be resolved.

  • Profile picture of joaocartaxo joaocartaxo said 7 months, 1 week ago:

    Yes it is, thank you for the fast support!

  • Profile picture of joaocartaxo joaocartaxo said 7 months, 1 week ago:

    Ok, so I replaced the loader code for:

    Node currentObject = (Node) assetManager.loadModel("Models/Test2/Test2.obj");
    

    And generated the applet. When running I get the following error:

    Exception in thread "LWJGL Renderer Thread" java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
    	at java.security.AccessControlContext.checkPermission(Unknown Source)
    	at java.security.AccessController.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkPermission(Unknown Source)
    	at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    	at java.lang.System.getProperty(Unknown Source)
    	at java.io.Win32FileSystem.getUserPath(Unknown Source)
    	at java.io.Win32FileSystem.resolve(Unknown Source)
    	at java.io.File.getCanonicalPath(Unknown Source)
    	at java.io.File.getCanonicalFile(Unknown Source)
    	at com.jme3.asset.plugins.FileLocator.setRootPath(FileLocator.java:61)
    	at com.jme3.asset.ImplHandler.tryLocate(ImplHandler.java:120)
    	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:237)
    	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:376)
    	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:386)
    	at com.xxxSoft.residencetour.application.ResidenceTourApp.loadScene(ResidenceTourApp.java:80)
    	at com.xxxSoft.residencetour.application.ResidenceTourApp.simpleInitApp(ResidenceTourApp.java:224)
    	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:230)
    	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
    	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
    	at java.lang.Thread.run(Unknown Source)
    

    Can someone please help me to solve this?

  • Profile picture of normen normen1290p said 7 months, 1 week ago:

    Since you have “at com.jme3.asset.plugins.FileLocator.setRootPath(FileLocator.java:61)” in that you still seem to register a FileLocator with the assets folder. As said, the assets from the assets folder are on the class path, no need to register a locator.

  • Profile picture of joaocartaxo joaocartaxo said 7 months, 1 week ago:

    I was having trouble signing the generated code.jar but I’ve passed that problem, wich solved that exception. But now I have a different one:

    Exception in thread "LWJGL Renderer Thread" java.lang.IllegalArgumentException: Given root path "C:UsersjoaoAppDataLocalGoogleChromeApplication14.0.835.187assets" not a directory
    	at com.jme3.asset.plugins.FileLocator.setRootPath(FileLocator.java:63)
    	at com.jme3.asset.ImplHandler.tryLocate(ImplHandler.java:120)
    	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:237)
    	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:376)
    	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:386)
    	at com.xxxSoft.residencetour.application.ResidenceTourApp.loadScene(ResidenceTourApp.java:80)
    	at com.xxxSoft.residencetour.application.ResidenceTourApp.simpleInitApp(ResidenceTourApp.java:224)
    	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:230)
    	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
    	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
    	at java.lang.Thread.run(Unknown Source)
    
  • Profile picture of normen normen1290p said 7 months, 1 week ago:

    lalalalalalalalalalalalalalalalala
    ^— to me it feels I could have posted this as well, you don’t seem to read my posts.

  • Profile picture of joaocartaxo joaocartaxo said 7 months, 1 week ago:

    Ok, you are right, at the first glance I miss interpret what you wrote. Please forgive me but I’m tired from a long working journey…

  • Profile picture of joaocartaxo joaocartaxo said 7 months ago:

    Ok I’m going to revive this thread…

    I’ve been able to setup my applet correctly, so that if i tried to run it from a double-click on the index.html file, the applet is loaded in the browser.

    My problem is when I put it into the www folder of my server and try to access it via IP. When I do this, all the jars are loaded and at the end I get this error:

    This occurred while 'Extracting downloaded packages'
    Unable to validate certificate chain. Chain differs in length [1 vs 4]
    java.lang.Exception: Unable to validate certificate chain. Chain differs in length [1 vs 4]
    	at org.lwjgl.util.applet.AppletLoader.validateCertificateChain(AppletLoader.java:1439)
    	at org.lwjgl.util.applet.AppletLoader.extractNatives(AppletLoader.java:1414)
    	at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:748)
    	at java.lang.Thread.run(Unknown Source)
    

    I have all my jars signed with the same certificate that I’ve created with:
    Create the keystore:

    keytool -genkey -keystore myKeyStore -alias mycert

    Create the certificate:

     keytool -selfcert -keystore myKeyStore -alias mycert

    And then, for all my jars, I use jarsigner to sign them:

    jarsigner -keystore myKeyStore jarfile.jar mycert

    What am i doing wrong?

  • Profile picture of normen normen1290p said 7 months ago:

    Why do you want to sign it with your own key? The current nightly is using the latest version of the lwjgl applet which comes with a valid key that reads “lwjgl”. Anyway, applets are not meant to write stuff to the users disk. You simply should not do that from an applet. You can use the new SaveGame class or java.util.Preferences to save data. Also, you have to sign the jars in the “dist/Applet” directory, not the normal application jar files.

  • Profile picture of joaocartaxo joaocartaxo said 7 months ago:

    If I just build my project and get on the Applet contents inside dist folder, and place them into my server, the problem remains the same.

    The signing part was an attempt to solve the problem.

    I’m using an out of the box WAMP server, can the problem be in the server configs?