JME and xCode 3

hi crowd,



i understand that most here use Eclipse. I have become very familiar with xCode especially since version 3 came out, so i would really like to stay with the tools that i know. i have come quite far in a few sleepless days but i am running into a strange issue that is a showstopper for me at this point. i suspect it it something really stupid that i am doing.



i have managed to put together an xCode project that implements the lwjgl library and i can call objects that load the library and largely do what i ask of them. i not yet manage to run spaceinvaders properly, but that is a different issue.



so, i am now starting to add jme on top of lwjgl and right away i am bashing my head into a brick wall. the problem emerges when i add even any single jme*.jar library to my project. i am not yet calling anything in it and i get a clean compile but upon running it i get the following exception:



Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:221)

at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176)

at java.util.jar.JarVerifier.processEntry(JarVerifier.java:233)

at java.util.jar.JarVerifier.update(JarVerifier.java:188)

at java.util.jar.JarFile.initializeVerifier(JarFile.java:325)

at java.util.jar.JarFile.getInputStream(JarFile.java:390)

at sun.misc.URLClassPath$JarLoader$1.getInputStream(URLClassPath.java:620)

at sun.misc.Resource.cachedInputStream(Resource.java:58)

at sun.misc.Resource.getByteBuffer(Resource.java:113)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:249)

at java.net.URLClassLoader.access$100(URLClassLoader.java:56)

at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:316)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:242)

at apple.launcher.LaunchRunner.loadMainMethod(LaunchRunner.java:55)

at apple.launcher.LaunchRunner.run(LaunchRunner.java:111)

at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)

at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)



The Debugger has exited with status 0.



Is it obvious to somebody what idiotic thing i am doing - aside from using xCode :)? i will gladly summarize what i have figured out in this forum so others will save themselves some frustration.



thanks and all the best,

Reading the stack trace, it seems that the Exception is thrown before any LWJGL or jME class is actually called. To be more precise, the only reference to something related to your application is the line "apple.launcher.LaunchRunner.loadMainMethod(LaunchRunner.java:55)".



It could be helpfull to see the code of the class containing "main()" your tried to run.



It could be also helpfull to know which Xcode template you used to create the project.

hi ender and others,



i used the the ant-based swing application xCode template



the main method is as follows



import javax.swing.*; // this is line 13 in the code



import org.lwjgl.opengl.ARBShadow;

import org.lwjgl.util.glu.Cylinder;

import org.lwjgl.Sys;



public class DragonFly extends JFrame {



public DragonFly() {

super("");

setSize(310, 150);

setVisible(true);

}



public static void main(String args[]) {

ARBShadow theShadow = null; // stuff from playing with lwjgl

Cylinder theObject = new Cylinder(); // stuff from playing with lwjgl

System.out.println(Sys.getVersion()); // stuff from playing with lwjgl

new DragonFly();

}



} // this is line 34 in the code



this section compiles and runs until i move any jme *.jar file into the lib folder of the project.



i tried using the java web start application template but even the simple, precanned program fails to run. the web start template fails with …



com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://localhost/~rhuber/test.jnlp

at com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:961)

at com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:1059)

at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:1134)

at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:1068)

at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:142)

at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:127)

at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:227)

at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:125)

at com.sun.javaws.Launcher.launch(Launcher.java:95)

at com.sun.javaws.Main.launchApp(Main.java:302)

at com.sun.javaws.Main.continueInSecureThread(Main.java:212)

at com.sun.javaws.Main$1.run(Main.java:107)

at java.lang.Thread.run(Thread.java:637)



maybe all of this is connected to something weird in my system. thanks a stack and all the best, any help would be greatly appreciated. thanks and ciao,


I think that you need first to read some LWJGL or jME tutorial.



This not the way to create a jME or LWJGL window. Your application opens a SWING JFrame and try to inizialize a GLU Cylinder using LWJGL GLU implementation. But I think it is not possible use GLU objects, without first inizialize correctly a OpenGL Graphic Context.



About the *.jar files you try to move. If your application is setted to search for JAR files in your JME installation directory you should leave them there. To change those files position in the HD you also have to set correctly the -classpath option.

hi ender,



i am working on getting the basics of my project working rather than have it do anything specific. the only purpose of the main class i posted was to check whether i had a project in which lwjgl libraries were found and used. i picked any random object from the javadoc with no particular goal beyond that. using the Sys class loaded the lib and ran fine as it reported the current version. i just needed to make sure lwjgl was working before i added jme on top - which is where i am stuck now … i am adding any jme.jar to this project and i get the security exception reported above, even if i am not using anything in it. i am fine with handling jar files in my projects, i know where they are, and i can merge them in without sweat.



i would not mind starting with a working java web start template in xCode 3 but even the empty project that xCode creates from its template fails to run, see above. has anybody managed to work a basic java web start app in xCode?



thanks, ciao

Ciao (are you Italian?)



Uhm. If the application you are trying to run is a Java Web Start application, the error you posted in the first post is more understandable. It is a security error, I guess you need a certificate to run your application. I do not know how Web Start security works exactly, though the current security check revealed something wrong.



I suggest to try first a standard Java application, if your goal is to check LWJGL and jME.



The second error is simply an error with some path. The absent resource is http://localhost/~rhuber/test.jnlp . Considering JavaWS purpose, it is probable that it searches the file to load in a Web URL resource. Then I guess that, to test Java Web Start applications, you probably need a HTTP server running. Is your Apache server running? Mac OS X has one preinstalled.

Happy to have been useful for you.



If you upload those Xcode example project files to your server let us know the address link so that we can see them. Also, I would like to ask you a little favour, could you remember to save them in Xcode 2.5 format so that also Tiger users can open them?

hi ender,



first thanks a major stack for pointing me towards the fix of the issue i described above.



no, actually, i am not italian, but i spent one of my most enjoyable months ever hitchhiking around northern italy - 30 years ago  :D



you were perfectly right. i kept looking in my compiler/jme/lwjgl combination for the problem, but it actually turned out to be in my apache setup. permissions were all screwy from something else. i would have never thought to look there. thanks. i got web start apps working. i got lwjgl working within my java web start app and jme is next - i will place little xCode projects on my server to illustrate the basic setup for all of the above …



thanks again and all the best, ciao,

hi ender and others,



i am painfully aware that i have little understanding of what i got myself into with games programming in java. i knew that this would be an uphill struggle given that my background is in quicktime for java, robotics, video-processing, and statistics http://caspar.bgsu.edu/~software/java/. it has been a steep learning curve to date as this came with a whole host of new technologies. i appreciate greatly the help i got here and i promise i require much less maintenance once i got the basics working. i am on top of web apps, i can play with lwjgl (maybe not as comfortably as i would like but good enough), but here is the basic jME showstopper that i am running into.



i have my simple lwjgl project called jME and it runs fine as a webstart app - actually simply opens a jOptionPane and reports the version of the lwjgl



JOptionPane.showMessageDialog(null, Sys.getVersion(), “”, 0);





then i do nothing other than adding a single jme.jar to my libs folder, any of the jme jars, i don’t call anything in it, no change to main whatsoever, i just add the .jar to the project and merge it into the final build. i get a clean compile but when i run it i get the following exception



com.sun.deploy.net.JARSigningException: Could not verify signing in resource: http://localhost/~huber/jME_signed.jar

at com.sun.deploy.cache.CacheEntry.writeManifest(CacheEntry.java:1119)

at com.sun.deploy.cache.CacheEntry.writeFileToDisk(CacheEntry.java:797)

at com.sun.deploy.cache.Cache.downloadResourceToCache(Cache.java:524)

at com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:947)

<schnipp …>



a price of austrian chocolates for whoever can get me past this hurdle …



thanks and all the best,

I think this error is caused by a security issue. WebStart applications should be signed with a trusted sign to run.

jME sources include a Ant script (the build.xml file at the root of jME sources). Ant is a build manager similar to Make, except it is written in Java and its scripts are written in XML. The jME Ant script, build.xml, should have one of its targets whit a name containing "webstart" word.

Ant, in my opinion is the recommended way to build jME and also LWJGL. To build jME with Ant, in Xcode, you should add a new Script Phase in the Xcode target. Browse Xcode documentation for more informations.



To deploy your application (based on jME) as a WebStart application, I think you have to apply a trusted signature to the application. Though, I am not sure of it.



I suggest you to open another thread with a title referring to WebStart, because I think this is not anymore a problem with Xcode configuration. It is a Java generic issue. In this forum there are not many Mac Users (I am one, for example, but I use Eclipse for Java development), and with this title, this thread is ignored by most of the jME community, simply because most of them cannot help you.

visit also the wiki : jme webstart tutorial

hi all,



thanks for the input, your input clarifies a couple of things but i am not yet in control of the projec. i'll do a post here and then start the new thread for a more global issue "basic security issue in webstart" as suggested.



i can run my webstart app successfully before i add any jme*.jar. to do this my build.xml first compiles and builds the jar.



    <target name="compile" depends="init" description="Compile code">

        <javac srcdir="${src}" destdir="${bin}"

            source="1.5" target="1.5"

            includeAntRuntime="no"

            classpathref="lib.path"

            debug="${compile.debug}">

        </javac>

    </target>



    <target name="build-jar" depends="compile" description="Build jar">

        <jar jarfile="${jarfile}"

            basedir="${bin}"

            manifest="${resources}/Manifest">

            <!-- Merge library jars into final jar file -->

            <zipgroupfileset refid="lib.jars"/>

        </jar>

    </target>



i then check for a private key



<!-- See if we already have a private key for this user in ~/.keystore.  -->

        <!-- Note: This tests for an output string of "does not exist", this

            assumes the locale is set to English and will not work for Spanish

            or other languages. -->

<target name="checkforkey" depends="build-jar" description="Generate private key">

<exec executable="/usr/bin/keytool" resultproperty="keytool.result" failonerror="false">

<redirector outputproperty="keytool.output" logError="false"/>

<arg value="-list"/>

<arg value="-alias"/>

<arg value="${user.name}"/>

<arg value="-storepass"/>

<arg value="changeit"/>

</exec>

<!-- Set the property createPrivateKey, used in genkey below, if there is no key -->

<condition property="createPrivateKey">

<not>

<equals arg1="${keytool.result}" arg2="0"/>

</not>

</condition>

</target>





i then generate a key if there isn't one already



<!-- If createPrivateKey is set we need to call genkey.  -->

<target name="genkey" depends="checkforkey" if="createPrivateKey">

<echo message="Creating a new key because keytool returned: ${keytool.output}"/>

<genkey alias="${user.name}" storepass="changeit" >

<dname>

<param name="CN" value="${user.name}"/>

<param name="OU" value="Kids Fun Zone"/>

<param name="O"  value="SugarRidgePrairie"/>

<param name="C"  value="US"/>

  </dname>

</genkey>

</target>



i then sign the .jar file with



<!-- Sign the JAR with the key generated above. -->

    <target name="sign-jar" depends="genkey" description="Sign JAR file">

        <!-- Note that the storepass is cleartext, and the keystore is assumed to be

          ~/.keystore. You may wish to just use .SF or .DSA files directly  -->

        <signjar jar="${jarfile}"

            alias="${user.name}"

            storepass="changeit"

keystore="${user.home}/.keystore"

            signedjar="${signed.jarfile}"/>

</target>



i then put the package together and run



  <target name="package" depends="sign-jar" description="Put all the pieces together in the dist directory">

<mkdir dir="${dist}"/>

<!-- Copy jar -->

<copy toDir="${dist}">

<fileset dir="${jars}">

<include name="*_signed.jar"/>

</fileset>

</copy>

        <!-- Copy the JNLP -->

        <copy file="${jnlp.file}" todir="${dist}"/>

        <!-- Copy the HTML -->

        <copy file="${html.file}" todir="${dist}"/>

    </target>



<!-- Install onto your local machine for testing: You will need to turn on Web Sharing in System Preferences. -->

    <target name="install" depends="package" description="Put all the pieces together in the dist directory">

<!-- Copy to your home directory's Sites folder -->

<copy todir="${user.home}/Sites">

<fileset refid="installed.files"/>

</copy>

    </target>



so all of that works fine, then i add any of the jme.jar files to the project and i get the security exception. is it possible that the jme jars come signed with a key already and that my method of assigning a key to the merged package fails?



thanks a stack and all help much appreciated.

lobsterman said:
is it possible that the jme jars come signed with a key already and that my method of assigning a key to the merged package fails?


I am not able to answer you this one because of my lack of knowledge in this field. I think that with the more generic thread you will get more help.

I am sorry.