jyeary
Joined: 21 Oct 2008 Posts: 612 Location: Simpsonville, SC
|
Posted: Sat Feb 05, 2011 7:32 pm Post subject: Re: Exception displaying a JApplet on a JSF 2.0 webapp |
|
|
The error message is very specific about not finding the class. Have you put the class files in the WEB-INF/classes or WEB-INF/lib directories?
On Sun, Jan 30, 2011 at 6:13 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
|
| Back to top |
|
 |
pepelara
Joined: 29 Nov 2008 Posts: 115
|
Posted: Sun Feb 06, 2011 12:08 pm Post subject: Re: Exception displaying a JApplet on a JSF 2.0 webapp |
|
|
Hi John,
I did not verify if the class was there. I got to get tired about this issue and now
I am trying another chat with socket. Here I have got to admit that it is turning me a little crazy
because the port. I do not find a free port to use.
I am going to try with 4848 (the glassfish admin console port). If you have any suggestion
I should appreciate. My system is WinXP SP3.
Thank you,
Jose
From: John Yeary ([email]address-removed[/email])
Sent: Saturday, February 05, 2011 8:30 PM
To: address-removed ([email]address-removed[/email])
Subject: [nbj2ee] Re: Exception displaying a JApplet on a JSF 2.0 webapp
The error message is very specific about not finding the class. Have you put the class files in the WEB-INF/classes or WEB-INF/lib directories?
On Sun, Jan 30, 2011 at 6:13 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi I have been studying the NB tutorial about Applets at,
http://netbeans.org/kb/docs/web/applets.html#embed
But this is not my case. What I have is a package chat with the Japplet Chat.java.
I call the JApplet to be displayed in a JSP file chatTR.jsp as follows,
<%@page ([email]%25@page[/email]) contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String path = request.getContextPath();
%>
<applet code="chat.Chat"
codebase="<%= path %>"
height="400" width="300">
<param name="user" value="TR">
</applet>
</body>
</html>
The JApplet Chat.java is as follows,
package chat;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Chat extends JApplet {
JTextArea jTA;
JTextField jTF;
JButton jB;
JCheckBox jcbTR;
JCheckBox jcbET;
JCheckBox jcbPP;
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// TODO start asynchronous download of heavy resources
String user = getParameter("user");
Container contentPane = getContentPane();
BorderLayout blMain = new BorderLayout();
JPanel jpMain = new JPanel();
jpMain.setLayout(new FlowLayout());
jTA = new JTextArea(10, 5);
jpMain.add(jTA);
blMain.addLayoutComponent(jpMain, BorderLayout.CENTER);
JPanel jpControls = new JPanel();
BorderLayout blControls = new BorderLayout();
JPanel jpTextField = new JPanel();
jpTextField.setLayout(new FlowLayout());
jTF = new JTextField(5);
jpTextField.add(jTF);
jB = new JButton("Send");
jpTextField.add(jB);
blControls.addLayoutComponent(jpTextField, BorderLayout.CENTER);
JPanel jpCheckBox = new JPanel();
jpCheckBox.setLayout(new FlowLayout());
jcbTR = new JCheckBox();
jcbTR.setText("TR");
jcbET = new JCheckBox();
jcbET.setText("ET");
jcbPP = new JCheckBox();
jcbPP.setText("PP");
jpCheckBox.add(jcbTR);
jpCheckBox.add(jcbET);
jpCheckBox.add(jcbPP);
if(user.equals("TR")){
jcbTR.setSelected(true);
jcbTR.setEnabled(false);
}
if(user.equals("ET")){
jcbET.setSelected(true);
jcbET.setEnabled(false);
}
if(user.equals("PP")){
jcbPP.setSelected(true);
jcbPP.setEnabled(false);
}
blControls.addLayoutComponent(jpCheckBox, BorderLayout.SOUTH);
blMain.addLayoutComponent(jpControls, BorderLayout.SOUTH);
contentPane.setLayout(blMain);
}
// TODO overwrite start(), stop() and destroy() methods
@Override
public void start() {
}
@Override
public void stop() {
}
@Override
public void destroy() {
}
}
But I get the following exception,
load: class chat.Chat not found.
java.lang.ClassNotFoundException: chat.Chat
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.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://localhost:8081/Workflow/chat/Chat.class
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)
... 7 more
Excepci |
|
| Back to top |
|
 |
jyeary
Joined: 21 Oct 2008 Posts: 612 Location: Simpsonville, SC
|
Posted: Sun Feb 06, 2011 2:08 pm Post subject: Re: Exception displaying a JApplet on a JSF 2.0 webapp |
|
|
There are 65635 ports available. Anything below 1024 requires root or administrative privileges. Some ports may be occupied by currently running services. You can check them using the netstat command to see which are in service. Pick one which is not being used. If GlassFish is running you can't use 4848. It will be occupied.
Check to make sure your applet is in the classpath, or it will not work as noted previously.
John
On Sun, Feb 6, 2011 at 7:06 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
|
| Back to top |
|
 |
pepelara
Joined: 29 Nov 2008 Posts: 115
|
Posted: Tue Feb 08, 2011 3:13 am Post subject: Re: Exception displaying a JApplet on a JSF 2.0 webapp |
|
|
At the end I am using the port 9999 and my app works fine. Thanks a lot for the supplied information.
On the other hand I will try a JApplet with JMS that is the part that I have gotten out of my project.
Regards,
Jose
From: John Yeary ([email]address-removed[/email])
Sent: Sunday, February 06, 2011 3:06 PM
To: address-removed ([email]address-removed[/email])
Subject: [nbj2ee] Re: Exception displaying a JApplet on a JSF 2.0 webapp
There are 65635 ports available. Anything below 1024 requires root or administrative privileges. Some ports may be occupied by currently running services. You can check them using the netstat command to see which are in service. Pick one which is not being used. If GlassFish is running you can't use 4848. It will be occupied.
Check to make sure your applet is in the classpath, or it will not work as noted previously.
John
On Sun, Feb 6, 2011 at 7:06 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi John,
I did not verify if the class was there. I got to get tired about this issue and now
I am trying another chat with socket. Here I have got to admit that it is turning me a little crazy
because the port. I do not find a free port to use.
I am going to try with 4848 (the glassfish admin console port). If you have any suggestion
I should appreciate. My system is WinXP SP3.
Thank you,
Jose
From: John Yeary ([email]address-removed[/email])
Sent: Saturday, February 05, 2011 8:30 PM
To: address-removed ([email]address-removed[/email])
Subject: [nbj2ee] Re: Exception displaying a JApplet on a JSF 2.0 webapp
The error message is very specific about not finding the class. Have you put the class files in the WEB-INF/classes or WEB-INF/lib directories?
On Sun, Jan 30, 2011 at 6:13 AM, Jose Alvarez de Lara <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi I have been studying the NB tutorial about Applets at,
http://netbeans.org/kb/docs/web/applets.html#embed
But this is not my case. What I have is a package chat with the Japplet Chat.java.
I call the JApplet to be displayed in a JSP file chatTR.jsp as follows,
<%@page ([email]%25@page[/email]) contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String path = request.getContextPath();
%>
<applet code="chat.Chat"
codebase="<%= path %>"
height="400" width="300">
<param name="user" value="TR">
</applet>
</body>
</html>
The JApplet Chat.java is as follows,
package chat;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Chat extends JApplet {
JTextArea jTA;
JTextField jTF;
JButton jB;
JCheckBox jcbTR;
JCheckBox jcbET;
JCheckBox jcbPP;
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// TODO start asynchronous download of heavy resources
String user = getParameter("user");
Container contentPane = getContentPane();
BorderLayout blMain = new BorderLayout();
JPanel jpMain = new JPanel();
jpMain.setLayout(new FlowLayout());
jTA = new JTextArea(10, 5);
jpMain.add(jTA);
blMain.addLayoutComponent(jpMain, BorderLayout.CENTER);
JPanel jpControls = new JPanel();
BorderLayout blControls = new BorderLayout();
JPanel jpTextField = new JPanel();
jpTextField.setLayout(new FlowLayout());
jTF = new JTextField(5);
jpTextField.add(jTF);
jB = new JButton("Send");
jpTextField.add(jB);
blControls.addLayoutComponent(jpTextField, BorderLayout.CENTER);
JPanel jpCheckBox = new JPanel();
jpCheckBox.setLayout(new FlowLayout());
jcbTR = new JCheckBox();
jcbTR.setText("TR");
jcbET = new JCheckBox();
jcbET.setText("ET");
jcbPP = new JCheckBox();
jcbPP.setText("PP");
jpCheckBox.add(jcbTR);
jpCheckBox.add(jcbET);
jpCheckBox.add(jcbPP);
if(user.equals("TR")){
jcbTR.setSelected(true);
jcbTR.setEnabled(false);
}
if(user.equals("ET")){
jcbET.setSelected(true);
jcbET.setEnabled(false);
}
if(user.equals("PP")){
jcbPP.setSelected(true);
jcbPP.setEnabled(false);
}
blControls.addLayoutComponent(jpCheckBox, BorderLayout.SOUTH);
blMain.addLayoutComponent(jpControls, BorderLayout.SOUTH);
contentPane.setLayout(blMain);
}
// TODO overwrite start(), stop() and destroy() methods
@Override
public void start() {
}
@Override
public void stop() {
}
@Override
public void destroy() {
}
}
But I get the following exception,
load: class chat.Chat not found.
java.lang.ClassNotFoundException: chat.Chat
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.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://localhost:8081/Workflow/chat/Chat.class
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)
... 7 more
Excepci |
|
| 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
|
|
|
| | |