1

My Java development done in a windows machine and i run my processes on a centos machine. I have a bash script that build all my Jars and SCP them to my centos machine. i run this bash script in Cygwin (java -version is 1.5.0_12), but when i try to run the process in my centos machine, the jVM can't open the Jars. also, running jar -tf throws:

java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.zip.ZipFile.<init>(ZipFile.java:75)
at sun.tools.jar.Main.list(Main.java:979)
at sun.tools.jar.Main.run(Main.java:224)
at sun.tools.jar.Main.main(Main.java:1149)

so the only way i can deploy is running mvn commands in cmd.exe in order to build my jars and then copy everything using WinSCP (that way i have no problems in the jars).

is there any known problem running mvn in cygwin? (running mvn -version returned Apache Maven 2.2.1 (r801777; 2009-08-06 22:16:01+0300) Java version: 1.6.0_26)

thank you

ryuchtman
  • 176
  • 8
  • Are you sure that the problem doesn't come from the way you `scp` them over? – nwinkler Apr 25 '12 at 07:49
  • 1
    I am running mvn in cygwin everyday without problems. Looks like your jars are not correctly transfered to your remote centOs and get corrupted somehow. – Guillaume Polet Apr 25 '12 at 07:54
  • I tried to use WinSCP to copy a jar that created in cygwin to my cenos macine and got the same problem, so i don't think it's a problem in the SCP – ryuchtman Apr 25 '12 at 09:08
  • Does the jar command work correctly on the window's box? – Jere Apr 26 '12 at 13:28

2 Answers2

3

Solved it. i found the solution in cygwin sets file permission to 000

Edit /etc/fstab and add this line at the end of the file:

none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

Then close all Cygwin processes, open a new terminal and ls -l on your files again.

Community
  • 1
  • 1
ryuchtman
  • 176
  • 8
2

Maven being a Java application runs the same whether launched via Cygwin script or cmd.exe. The Java executable in this case is the same tool.

First, you might want to post the copy command you are using in the bash script. Secondly, have you checked the permissions on the jar files once they are pushed to the CentOS box? Are the files actually readable to the process owner when sent via your bash script and are the owners/permissions the same as when copied using WinSCP?

Jere
  • 581
  • 2
  • 3
  • Hi Jere, Thanks for your reply. I looked at the permissions of the files created by the script and i see that there's no permissions at all on all files. so it seems like a problem with the built in Cygwin and not in the SCP process. (building from eclipse or cmd, i get permissions) – ryuchtman Apr 29 '12 at 08:11
  • Are you able to open/read the Jar file that is created on the Window's machine itself, either under Cygwin's shell or in cmd.exe? Also, can you list the actual jar construction command you are invoking via the Cygwin script? – Jere Apr 30 '12 at 15:01
  • no, the Jar file cannot be opened in windows (it has no permissions at all). i created a bash script that just creating a file and ran it on Cygwin and the file did had permissions. the command creating the Jars is mvn clean install -Dmaven.test.skip=true – ryuchtman May 01 '12 at 07:15
  • A Jar file is just a 'zip' file with some additions that Java knows about. Have you tried opening the file created with WinZip or the windows file manager (which is Zip aware) to see if it gives you any indication of an error? – Jere May 01 '12 at 13:22
  • open the jar file in windows using 7zip succeeded. – ryuchtman May 02 '12 at 07:18