abuerki / gwtai

Automatically exported from code.google.com/p/gwtai
3 stars 2 forks source link

Difficulty getting a test applet started #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Make a test project
2. implement a interface class and an impl as the Getting started suggests
3. Add inherit to the gwt.xml file
4. start the app in hosted mode
5. compile browse and get an error

What is the expected output? What do you see instead?
Expected the browser to load up with the applet. Instead get two errors:
"[ERROR] Errors in
'file:/home/izaak/workspace/GXTScrollBarTest/src/test/client/GXTScrollBarTest.ja
va'"
"[ERROR] Line 26:  Rebind result 'test.client.AppletTestImpl' could not be
found"

(My AppletTestImpl is defined in test.impl, not in client)

and a pretty large stack trace after that (truncated):
ERROR]  Missing message: compilation_internalError in:
org.eclipse.jdt.internal.compiler.messages
java.lang.StackOverflowError
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getCachedType(LookupE
nvironment.java:860)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromCompoundNa
me(LookupEnvironment.java:986)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromConstantPo
olName(LookupEnvironment.java:1012)
    at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.<init>(BinaryTypeBind
ing.java:180)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(
LookupEnvironment.java:591)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(
LookupEnvironment.java:588)
    at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:276)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvi
ronment.java:102)
    at
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(Unre
solvedReferenceBinding.java:49)
    at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTyp
eBinding.java:97)
    at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.enclosingType(BinaryT
ypeBinding.java:628)
    at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.<init>(BinaryTypeBind
ing.java:183)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(
LookupEnvironment.java:591)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(
LookupEnvironment.java:588)
    at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:276)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvi
ronment.java:102)
    at
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(Unre
solvedReferenceBinding.java:49)
    at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTyp
eBinding.java:97)
    at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.enclosingType(BinaryT
ypeBinding.java:628)
    at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.<init>(BinaryTypeBind
ing.java:183)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(
LookupEnvironment.java:591)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(
LookupEnvironment.java:588)
    at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:276)
    at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvi
ronment.java:102)
    at
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(Unre
solvedReferenceBinding.java:49).....

What version of the product are you using? On what operating system?
This is in GWT1.5, Occurs on both Windows XP and Linux (Ubuntu 8.04)

Please provide any additional information below.
This is the definition of my AppletTest Class:

package test.client;

import com.google.gwt.gwtai.applet.client.Applet;
import com.google.gwt.gwtai.applet.client.Archive;
import com.google.gwt.gwtai.applet.client.Height;
import com.google.gwt.gwtai.applet.client.ImplementingClass;
import com.google.gwt.gwtai.applet.client.Width;

@ImplementingClass(test.impl.AppletTestImpl.class)
@Height("60")
@Width("350")
@Archive("GwtAI-Core.jar")
public interface AppletTest extends Applet {

    public void increment();

    public void decrement();

    public Object getCurrentValue();

}

This is the definition of my AppletTestImpl:

package test.impl;

import java.applet.Applet;
import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import test.client.AppletTest;

public class AppletTestImpl extends JApplet implements AppletTest {
    private JTextField _tfCounter;

    public void init() {
        JPanel panelMain = new JPanel();

        _tfCounter = new JTextField(20);
        _tfCounter.setHorizontalAlignment(JTextField.CENTER);
        _tfCounter.setText("0");
        _tfCounter.setEditable(false);

        panelMain.add(new JLabel("Current count : "));
        panelMain.add(_tfCounter);

        panelMain.setBorder(BorderFactory.createTitledBorder("CounterApplet"));
        panelMain.setBackground(Color.WHITE);

        getContentPane().add(panelMain);
    }

    public void increment() {
        int currentCount = Integer.parseInt(_tfCounter.getText());
        currentCount++;

        _tfCounter.setText(currentCount + "");
    }

    public void decrement() {
        int currentCount = Integer.parseInt(_tfCounter.getText());
        currentCount--;

        _tfCounter.setText(currentCount + "");
    }

    public Object getCurrentValue() {
        return _tfCounter.getText();
    }

}

Original issue reported on code.google.com by ialp...@gmail.com on 10 Oct 2008 at 8:16

GoogleCodeExporter commented 9 years ago
You are right, integration an Applet is not a trivial task. The place where the 
jar
files go and all the settings that are necessary to load an Applet in the 
browser
have to be correct. Alas GwtAI can not help much with these things. What GwtAI 
can do
for you is save you from writing tedious JavaScript code to finally integrate 
the
Applet into your GWT application.

I had to choose between two approaches. Either by coding some helper class to
construct the necessary elements at runtime or by providing a generator that 
creates
the stuff at compile-time. The form would probably have been easy for the user, 
but
the later is way more powerful. Generator can create different code for 
different
browser, which is something that will be useful later on. Handling Applet does 
not
work the same in all browsers. I have not taken advantage of this yet, but that 
will
happen in the future. Especially once passing object between the Applet and the 
GWT
application will become more sophisticated, a browser dependent solution is 
inevitable.

Alas you can not use the GWT Shell to test your application. The GWT Shell can 
not
handle embedded things like Flash or Applets. This is not an issue of GwtAI but 
one
of GWT, see issue 283 in the GWT issue tracker. The moral of it is that you 
have to
compile your code and run it in a browser in order to test your Applet.

I have taken the code from above and made a simple demo project using the two
classes. All I had to change was one line in the 'AppletTest.java' file; the 
archive
annotation has to look like this:

@Archive("AppletDemo.jar,GwtAI-Client.jar")

Have a look at the attached zip file, the 'build.xml' is probably the most
interesting thing in there...

Original comment by a.bue...@gmail.com on 21 Oct 2008 at 3:15

Attachments:

GoogleCodeExporter commented 9 years ago
I have exactly the same problem! 

First I got the error with a personal test, then I downloaded the 
TestProject.zip and
tried to compile it using Ant but noway :(

Original comment by julialo...@gmail.com on 30 Oct 2008 at 11:13

GoogleCodeExporter commented 9 years ago
We wound up just rolling our own html widget, this was a spike, so maby we'll 
get
back to this in the future. julialopez what was the error you got compiling it 
with ant?

Original comment by ialp...@gmail.com on 31 Oct 2008 at 3:56

GoogleCodeExporter commented 9 years ago
ialpert, yes I got the error compiling with ant. Also, I've tried to compile 
using
GWTCompiler and I got the same problem.

Original comment by julialo...@gmail.com on 3 Nov 2008 at 8:18

GoogleCodeExporter commented 9 years ago
Hi guys

Can you give me some more information about your environment? What OS, what JVM 
are
you using (GWT does not play well with Java 1.6)?

Regards, Adrian

Original comment by a.bue...@gmail.com on 4 Nov 2008 at 7:40

GoogleCodeExporter commented 9 years ago
Hello
We are having exactly the same problem mentioned in this thread.

Rebind result 'com.google.gwt.gwtai.client.CounterAppletImpl' could not be 
found,
StackOverflow and everything exactly the same with ialpert.

After failing to deploy our own test applet we tried downloading your source 
from the
svn and compiling it to see if it could run. It cannot compile.

Your compiled demo works well, however it seems there seems to be no way we can
compile it ourselves.

We're using Linux openSUSE 11.0 and jre 1.6._07 but it seems you can't compile 
it on
windows xp either.

Perhaps you should give us some information about your environment? Or any
environment that has proven its ability to compile gwtai for that matter.
Please help, we've been trying for the last 4 days and we can't get any more
frustrated. We're trying to roll our own now but I would rather use gwtai which 
I
guess has been more thoroughly tested for cross-browser support.

If only it would compile...

thanks in advance

Original comment by anesti...@gmail.com on 4 Nov 2008 at 10:17

GoogleCodeExporter commented 9 years ago
Hi!
I've tried to compile using Java 1.5 and Java 1.6. My OS is windows XP.

I've just extracted your TestProject, added the gwt libraries (version 1.5.3 and
1.5.2) in the lib directory and used ant, then I got the error :(

Original comment by julialo...@gmail.com on 4 Nov 2008 at 10:39

GoogleCodeExporter commented 9 years ago
On my machine - Ubuntu 8.04
Were using 1.6
izaak@izaak-desktop:~$ java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)
izaak@izaak-desktop:~$ uname -a
Linux izaak-desktop 2.6.24-21-generic #1 SMP Tue Oct 21 23:43:45 UTC 2008 i686 
GNU/Linux

We also have a windows xp  machine that it failed to compile on.

Original comment by ialp...@gmail.com on 4 Nov 2008 at 2:10

GoogleCodeExporter commented 9 years ago
Hi guys!

First of all make sure you use a 32bit JDK, even on a 64bit platform you have 
to fall
back on a 32bit JDK. This is not a GwtAI but a GWT problem. See the GWT Google
groupe:
http://groups.google.com/group/Google-Web-Toolkit/search?group=Google-Web-Toolki
t&q=64-bit+linux&qt_g=Search+this+group

Secondly the StackOverflowError seems to occure only on a 1.6 JDK version. I 
use XP
and Linux to test my code, using a 1.5 JDK to compile things. You can try to 
increase
the heap size with some JVM arguments (e.g. -XX:PermSize=64M and
-XX:MaxPermSize=256M). Although I tried several combination on a 1.6.0_10 JDK 
and
could not get it to work.

Any help and ideas with this issue are very much appreciated!

Regards, Adrian

Original comment by a.bue...@gmail.com on 4 Nov 2008 at 3:56

GoogleCodeExporter commented 9 years ago
That's it! We've gone back to jdk 1.5.0.16 and gwtai was compiled and deployed 
on
glassfish like a breeze!
StackOverflow was never seen again. Thank you all guys for your help.

note of minor importance:
I get this message during compilation although it doesn't seem to have serious
effects (i mean the applet still works):
libxcb: WARNING! Program tries to unlock a connection without having acquired
        a lock first, which indicates a programming error.
        There will be no further warnings about this issue.
libxcb: WARNING! Program tries to lock an already locked connection,
        which indicates a programming error.
        There will be no further warnings about this issue.

more important note regarding the: "Rebind result
'com.google.gwt.gwtai.client.CounterAppletImpl' could not be found" error we 
get:
After spending so much time trying to force gwtai to compile I have noticed 
that I
only got that when i was trying to compile through GWT hosted mode development 
shell.
I don't get this error when I compile and run straight away on glassfish 
Server. Ok,
applets don't work in hosted mode but why shouldn't it compile the application
normally? I don't really understand why, but I found a way for the hosted mode
development shell to overcome this problem. I modified 
AppletProxyGenerator.java just
a little bit and now i can use the hosted mode shell to compile as well. Hosted 
mode
is supposed to be useful so why stop using it?
It's not a big deal what I did but i can hand it over to you if you wish.

I'm off to write some code while jre 1.5 is still around...
(it is supposed to reach End Of Life next year according to sun)

Thank you so much!

Original comment by anesti...@gmail.com on 4 Nov 2008 at 8:12

GoogleCodeExporter commented 9 years ago
With Java 1.5 it compiles okey! Thank you!
(I said before I tried to compile with 1.5 but I did not configure correctly 
the path)

Now it's working :)

Original comment by julialo...@gmail.com on 5 Nov 2008 at 9:53

GoogleCodeExporter commented 9 years ago
Hi anestis7k

Yes, please let me know what you had to change in the AppletProxyGenerator 
class. I'm
grateful for any help.

Thank you very much!
Adrian

Original comment by a.bue...@gmail.com on 6 Nov 2008 at 3:24

GoogleCodeExporter commented 9 years ago
Hi Adrian!
Sorry it took me so long to answer...
What i did was simply comment out line 60 'if (null == createdClassName){' and 
insert
a new line after line 88 containing:'if(printWriter!=null){'
this is right before the SourceWriter creation.

I have also modified AppletJSUtil in order to generate Object Tag based applet 
code
for use with ie. I don't like this either, but ie plays dirty tricks to applet 
tags
with jre's after 1.6.0_04 (sometimes it calls init() twice sometimes it calls 
start()
four times etc).
Let me know if you're interested for this piece of code as well.

cheers

Original comment by anesti...@gmail.com on 12 Nov 2008 at 7:21

GoogleCodeExporter commented 9 years ago
Hi anestis7k

Thanks for the hint! There is something mentioned in the GWT documentation 
about the
GeneratorContext returning null for the PrintWriter. I'll have a look into 
that. 

About the Object Tag code, can you please contact me by email, so we can figure 
out
how to integrate your changes into GwtAi...

Regards, Adrian

Original comment by a.bue...@gmail.com on 13 Nov 2008 at 12:59

GoogleCodeExporter commented 9 years ago
hello, I have downloaded the testProject. but it is not running...
It is showing class file is missing...  "java.lang.ClassNotFoundException:
test.impl.AppletTestImpl.class"

I want to know.. how to compile project out side the eclips ?

Original comment by mcasanke...@gmail.com on 5 May 2009 at 11:40

GoogleCodeExporter commented 9 years ago
hello,

i am using testproject.zip and it is not showing any errors but while opening 
it , i am seeing the below error.

load: class test.impl.AppletTestImpl.class not found.
java.lang.ClassNotFoundException: test.impl.AppletTestImpl.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection 
failed:http://127.0.0.1:8888/test.AppletDemo/test/impl/AppletTestImpl/class.clas
s
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 9 more
Exception: java.lang.ClassNotFoundException: test.impl.AppletTestImpl.class

any help will be appreciated..

thanks
Sandeep 

Original comment by sandeepb...@gmail.com on 17 Dec 2010 at 5:48

GoogleCodeExporter commented 9 years ago
Hi, please can someone answer the two last posts ?

What is the workaround to prevent this "ClassNotFoundException" exception ? 
More precisely, can someone explain the 4 steps of the FAQ's last question ?

And I'm in the depths of despair, because your showcase shows exactly the same 
problem ?!

http://gwtai.traceurl.com/GwtAI.html

Thanks.

Original comment by Makaveli...@gmail.com on 1 Mar 2011 at 2:18