-1

I am experimenting with tomcat7 and I have project for web application and project for applet, I wrote applet and when I right click on applet and click run in menu it pops up applet without any problems, but when I compile my web application, which includes that applet and I run it in web browser it pops this error. I already tried to compile it manually with jar and fastjar (my OS is Ubuntu), but same problem.

And in localhost_access.log file is this:

"GET /Money/account/org/symphaty/money/applet/LineGraphApplet.class HTTP/1.1" 302 -

Edit:

This is content of .class file extracted from jar file

0000000: c38a c3be c2ba c2be 0000 0033 001e 0a00  ...........3....
0000010: 0600 1307 0014 0a00 0200 150a 0016 0017  ................
0000020: 0700 1807 0019 0100 0001 000c 496e 6e65  ............Inne
0000030: 7243 6c61 7373 6573 0100 063c 696e 6974  rClasses...<init
0000040: 3e01 0003 2829 5601 0004 436f 6465 0100  >...()V...Code..

This is output from od -tx1:

0000000 ca fe ba be 00 00 00 33 00 1e 0a 00 06 00 13 07
0000020 00 14 0a 00 02 00 15 0a 00 16 00 17 07 00 18 07
0000040 00 19 01 00 00 01 00 0c 49 6e 6e 65 72 43 6c 61
0000060 73 73 65 73 01 00 06 3c 69 6e 69 74 3e 01 00 03
0000100 28 29 56 01 00 04 43 6f 64 65 01 00 0f 4c 69 6e
0000120 65 4e 75 6d 62 65 72 54 61 62 6c 65 01 00 12 4c
0000140 6f 63 61 6c 56 61 72 69 61 62 6c 65 54 61 62 6c
0000160 65 01 00 04 74 68 69 73 01 00 2b 4c 6f 72 67 2f
0000200 73 79 6d 70 68 61 74 79 2f 6d 6f 6e 65 79 2f 61
0000220 70 70 6c 65 74 2f 4c 69 6e 65 47 72 61 70 68 41

This is output from jsp page, MoneyApplets.jar is located in WEB-INF/lib:

<%@ include file="basehead.jsp" %>

<body>

    <div class="container" style="height: 100%; width: 100%">

        <div class="row">
            <%@ include file="header.jsp" %>
        </div>

        <div class="row maincontent">

            <%@ include file="menu.jsp" %>

            <div class="col-md-7 graphing">
                <applet code="org.symphaty.money.applet.LineGraphApplet" archive="MoneyApplets.jar">
                </applet>
            </div>

            <%@ include file="filter.jsp" %>

        </div>

    </div>

</body>

I moved the jar file to public folder resources and changed it to this, but still getting error, when i add the address to the browser, it offers download of jar file:

                    <applet code="org.symphaty.money.applet.LineGraphApplet" archive="http://localhost:8080/Money/resources/jar/MoneyApplets.jar"></applet>
anjalis
  • 397
  • 2
  • 19

2 Answers2

0

There's not enough information in the question to tell exactly what is causing the message, but 1347093766 (PK\005\006) is the magic number for an empty zip file.

In other words, one of your jar files is empty, or one of your class files is really not a class file but an empty zip file.

Martin Wilson
  • 3,386
  • 1
  • 24
  • 29
Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • I don't know what info should i provide, because i don't know where to look, probably it is not coding error, but some configuration problem, i don't know in which direction should i look. Yes i know that it is magic number for empty zip file, i already opened jar file with archive manager and there is class file several hundred bytes big – anjalis Jan 03 '14 at 13:25
  • i extracted that .class file and viewed it in vi hex mode – anjalis Jan 03 '14 at 13:29
  • @anjalis Your dump seems to show an UTF-8 encoded class file. It should most definitely not look like that. Could you just dump it using `od -tx1 | head` instead so your editor isn't doing anything weird. – Joachim Isaksson Jan 03 '14 at 13:37
  • @anjalis Also, you may want to try dumping `LineGraphApplet.class` that is apparently fetched separately from your jar file. – Joachim Isaksson Jan 03 '14 at 13:39
  • Is LineGraphApplet.class in a jar file? If so, why is your code trying to get it directly? (Money/account/org/symphaty/money/applet/LineGraphApplet.class). My guess is that Java in the browser is trying to interpret your 302 redirect response as a class file. Could you post the HTML code you're using to show the applet? – Martin Wilson Jan 03 '14 at 13:40
  • @JoachimIsaksson That is output from LineGraphApplet.class – anjalis Jan 03 '14 at 13:59
  • @anjalis It seems you're missing the [codebase attribute](http://stackoverflow.com/questions/5947063/how-to-specify-correctly-codebase-and-archive-in-java-applet) on your applet tag. – Joachim Isaksson Jan 03 '14 at 14:10
  • Or, the jar file needs to be on the same path as the URL of the page showing the applet (codebase is a better option though) – Martin Wilson Jan 03 '14 at 14:16
  • BTW, you'll probably want to move the jar file out of WEB-INF/lib as it needs to be available to the browser and in general files in WEB-INF/lib aren't – Martin Wilson Jan 03 '14 at 14:18
  • interesting, so i don't understand why netbeans placed it there..., and that codebase attribute is required, isn't enough to have relative path in archive? – anjalis Jan 03 '14 at 14:23
0

ok so the resolution is:

you can use just archive attribute with relative path, but you need to set privacy settings of tomcat or you can use archive and codebase attribute, where codebase attribute is path of the dir where archive resides. Very "nice" that it spits this cumbersome error message...

anjalis
  • 397
  • 2
  • 19