NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
GrantB
Joined: 12 May 2009 Posts: 10 Location: Chicago, IL
|
Posted: Wed Jan 13, 2010 12:13 am Post subject: Sign jars works in IDE, not from Ant command line? |
|
|
This is driving me up the wall.
When I build my Web Start app in NetBeans, the jars get signed (self-signed, I suppose). I see the build output signing 6 or 7 jars and everything works smoothly after deployment.
However, when I do it from the command line with ant, the signing step is skipped and my deployment fails (the app can't access the system properties as programmed and throws out of execution).
As best as I can tell, NetBeans is using "ant clean jar", and that's the command I'm calling.
I've also tried ant targets "jnlp" and "jnlp-init-generate-master" which precede the signing in the NB build output, but again, the signing step is skipped.
So what the expletive is NetBeans doing that it's hiding from Ant? How can I access this hidden magic for my command-line script?
(I'm using NB 6.7) |
|
| Back to top |
|
 |
GrantB
Joined: 12 May 2009 Posts: 10 Location: Chicago, IL
|
Posted: Wed Jan 13, 2010 1:29 am Post subject: |
|
|
I've made a little headway. I've found this in my buildlog:
| Code: | -unavailable-task-warning:
[echo] Signtask is not available, jar files will not be signed. Task is available only when running inside NetBeans IDE.
[echo] You can fix the problem by adding following jar file to Ant classpath: [NetBeans install dir]/java2/ant/nblib/org-netbeans-modules-javawebstart-signtask.jar
|
Sounds easy, right? Except I can't freaking find this jar! It's not in any of my Netbeans installs, whether Windows (3 versions) or Mac (2 versions).
Is it supposed to be downloadable? In which module?
At present, I guess I'll just try downloading from a random Maven repo I found via Google. I'm not using Maven, but a jar's a jar, right? Especially when the app that needs it gives no indication on where to find the bloody thing. |
|
| Back to top |
|
 |
GrantB
Joined: 12 May 2009 Posts: 10 Location: Chicago, IL
|
Posted: Wed Jan 13, 2010 2:22 am Post subject: |
|
|
Still stumped. I did end up finding a version of the jar in an old Netbeans 6.1 install. I copied it to my ant lib dir, and the "jar" build target still gives me the same error message.
I confirmed with "ant -diagnostics" that ant can see the lib.
I'd greatly appreciate any help that anyone can give. |
|
| Back to top |
|
 |
GrantB
Joined: 12 May 2009 Posts: 10 Location: Chicago, IL
|
Posted: Wed Jan 13, 2010 2:23 am Post subject: |
|
|
| One more comment: I did install NB 6.8. Still no difference. |
|
| Back to top |
|
 |
MadHatter
Joined: 13 Jan 2010 Posts: 1
|
Posted: Wed Jan 13, 2010 12:08 pm Post subject: |
|
|
Hey there sir,
What a coincidence that we're having the same problem!
I can duplicate the problem you see on a machine that doesn't have netbeans. But using the same scripts on a machine with netbeans shows no issue. The question is what's the missing dependency.
So here's some links I found for a manual solution:
These two links are the closest I can find to a solution. Each does a similar manual work around:
* http://www.pikopong.com/blog/2008/04/14/automatically-sign-jars-using-ant-and-bash/
* http://www.arminsadeghi.com/signing_jars
However, I just want to find the missing dependency and hopefully do it the easy way. So down the rabbit hole we go...
I too have old versions of NetBeans and I only have the requested jar in the following location:
./Applications/NetBeans/NetBeans 6.1.app/Contents/Resources/NetBeans/java2/ant/nblib/org-netbeans-modules-javawebstart-signtask.jar
./Applications/NetBeans/NetBeans 6.1.app/Contents/Resources/NetBeans/java2/modules/org-netbeans-modules-javawebstart-signtask.jar
Which made me think that maybe the error is an artifact of a project created in an earlier version of netbeans which was upgraded. So I then created a simple webstart app in NetBeans 6.7.1. And for good measure I deleted the old versions of NetBeans. Still the error occurred, but this time the message was a bit improved:
-unavailable-signjars-task:
[echo] Task required to sign JAR file is missing, probably the library 'JWS Ant Tasks' is missing either from shared folder or from IDE installation. JAR files will not be signed.
Looking through the build files for where this error occurs, I found the following:
<target name="-test-signjars-task-available">
<available property="signjars.task.available"
classname="org.netbeans.modules.javawebstart.anttasks.SignJarsTask"
classpath="${libs.JWSAntTasks.classpath}"/>
</target>
Of course I couldn't find where JWSAntTasks.classpath was coming from, that would be too easy... So I figured it might be stored in the NetBeans application somewhere.
The following search showed me that I may have found where the target is defined:
Machine:NetBeans 6.7.1.app dude$ cd /Applications/NetBeans/NetBeans 6.7.1.app
Machine:NetBeans 6.7.1.app dude$ grep -H -r JWSAntTasks *
Binary file Contents/Resources/NetBeans/java2/modules/org-netbeans-modules-javawebstart.jar matches
The next step seemed to be to somehow get ant to load the jar:
/Applications/NetBeans/NetBeans 6.7.1.app/Contents/Resources/NetBeans/java2/modules/org-netbeans-modules-javawebstart.jar
So I accomplished that with the following line in build-impl.xml:
<target name="-pre-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
<property name="libs.JWSAntTasks.classpath" value="../lib/org-netbeans-modules-javawebstart.jar" />
</target>
And I know that part is working because I put the following inside the target that generates the error message:
<echo message="libs.JWSAntTasks.classpath=${libs.JWSAntTasks.classpath}"/>
So the build output now contains:
-test-signjars-task-available:
[echo] libs.JWSAntTasks.classpath=../lib/org-netbeans-modules-javawebstart.jar
-unavailable-signjars-task:
[echo] Task required to sign JAR file is missing, probably the library 'JWS Ant Tasks' is missing either from shared folder or from IDE installation. JAR files will not be signed.
The second error here is a result of the following:
<target name="-unavailable-signjars-task" depends="-test-signjars-task-available" unless="signjars.task.available">
<echo message="Task required to sign JAR file is missing, probably the library 'JWS Ant Tasks' is missing either from shared folder or from IDE installation. JAR files will not be signed."/>
</target>
So apparently signjars.task.available is false. So I did a "jar xvf <filename>" on the jar to see what was inside. I found the following which seems to be a relative path of some kind.
<resource>jar:nbinst://org.netbeans.modules.javawebstart/ant/extra/org-netbeans-modules-javawebstart-anttasks.jar!/</resource>
This link talks about the relative path but seems to somehow not actually say anything:
http://wiki.netbeans.org/DevFaqUriVsUrl
Well done I must say. But some more searching suggests that it's a file path of some kind.
Machine:NetBeans dude$ cd /Applications/NetBeans/NetBeans 6.7.1.app/Contents/Resources/NetBeans/
Machine:NetBeans dude$ find . -type f -name *.jar | grep ant | grep web
./java2/ant/extra/org-netbeans-modules-javawebstart-anttasks.jar AHA!!!!!
./java2/ant/lib/ant-weblogic.jar
./java2/ant/nblib/org-netbeans-modules-javawebstart.jar
So I copy that jar out of the application to somewhere more portable and update the property:
<property name="libs.JWSAntTasks.classpath" value="../lib/org-netbeans-modules-javawebstart-anttasks.jar" />
So the build now displays:
sign-jars:
[signjar] Signing JAR: /root/ccxme-build/TestWebstart/dist/TestWebstart.jar to /root/ccxme-build/TestWebstart/dist/TestWebstart.jar as nb-jws
Voila!
“ I relieve and release your hurt that you may be set free. ”
-Jason Aubrey |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|