Erreur lors de l'execution d'une applet avec un browser
nadimunam
Messages postés6Date d'inscriptionmercredi 7 juin 2006StatutMembreDernière intervention19 juin 2006
-
15 juin 2006 à 17:22
Twinuts
Messages postés5375Date d'inscriptiondimanche 4 mai 2003StatutModérateurDernière intervention14 juin 2023
-
15 juin 2006 à 22:52
Bonjour tout le monde, dans le cadre de mon projet informatique, je dois programmer un Qcm en ligne. Quand j'execute mon programme a l'aide de l'Applet viewer d'eclipse, il marche nickel, puis quand j'essaie de l'executer au travers d'un browser, j'obtiens les erreurs suivantes :
java.lang.SecurityException: class "CheckBoxFrame"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-55" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-Affichage3.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
J'ai bien crée un certificat car mon .class accede à un fichier .xml. Merci de votre future aide, car je dois rendre mon projet dans une semaine !!!
A voir également:
Erreur lors de l'execution d'une applet avec un browser
nadimunam
Messages postés6Date d'inscriptionmercredi 7 juin 2006StatutMembreDernière intervention19 juin 2006 15 juin 2006 à 21:10
Voici le code de ma classe Affichage
La classe CheckBoxFrame étend JPanel (Pas JFrame car on m'a dit que cela ne marchait pas avec un browser)
J'affiche dans un objet CheckBoxFrame un paneau faisaint appel a une méthode qui affiche les énonces et les propositions des questions.
Le 2è code correspond a ma classe Xml qui récupère a partir d'un fichier .xml toute l'arborescence du qcm
public class Affichage3 extends JApplet
{
public void init() //throws ParserConfigurationException, SAXException, IOException
{
CheckBoxFrame frame = new CheckBoxFrame();
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(frame);
frame.setVisible(true);
}
}
class CheckBoxFrame extends JPanel
{
public CheckBoxFrame()
{
i=0;
qcm = new Xml();
tabQuestion = qcm.gettabQuestion();
//System.out.println("Balise je suis ici");
//setTitle("Qcm Version Beta3");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
panel = new JPanel();
//On crée le panneau contenant les propositions avec leur checkbox
panelCheckBox = new JPanel();
tabJCheckBox = new ArrayList<JCheckBox>(tabQuestion.get(i).getTabReponse().size());
for(int j=0; j<tabQuestion.get(i).getTabReponse().size(); j++)
{
//System.out.println(j);
tabJCheckBox.add(new JCheckBox(tabQuestion.get(i).getTabReponse().get(j).getProposition()));
panelCheckBox.add(tabJCheckBox.get(j));
}
//On affiche l'enonce de l'exercice
jlabel = new JLabel(tabQuestion.get(i).getEnonce(), JLabel.LEFT);
panel.add(jlabel);
//On cree le bouton Suivant
JButton suivantButton = new JButton("Suivant");
panel.add(suivantButton, BorderLayout.EAST);
suivantButton.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
//On execute setReponse 1 qd la checkbox est coché
for (int j=0; j<tabQuestion.get(i).getTabReponse().size(); j++)
{
if(tabJCheckBox.get(j).isSelected())
{
tabQuestion.get(i).getTabReponse().get(j).setReponseEleve1();
}
}
System.out.println("Voici le note de la question : " + tabQuestion.get(i).getNote());
if(i==tabQuestion.size()-1)
{
int noteQcm = 0;
remove(panelCheckBox);
jlabel.setText("Voici le résultat du Qcm : " + qcm.getNoteQcm() + "/" +tabQuestion.size());
panel.repaint();
}
else if(i<tabQuestion.size()-1)
{
i+=1;
//System.out.println("Tu entre dans actionPerfomed");
jlabel.setText(tabQuestion.get(i).getEnonce());
panel.repaint();
remove(panelCheckBox);
panelCheckBox = new JPanel();
tabJCheckBox = new ArrayList<JCheckBox>(tabQuestion.get(i).getTabReponse().size());
for(int j=0; j<tabQuestion.get(i).getTabReponse().size(); j++)
{
tabJCheckBox.add(new JCheckBox(tabQuestion.get(i).getTabReponse().get(j).getProposition()));
panelCheckBox.add(tabJCheckBox.get(j));
}
add(panelCheckBox, BorderLayout.SOUTH);
}
public class Xml
{
public Xml() //throws ParserConfigurationException, SAXException, IOException
{
//System.out.println("Balise d'entrée dans la méthode");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); // On crée un Objet DocumentBuilder
//On traite les exeptions qui peuvent etre générées lors de la création du document xml
DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // le ficher .xml
String f = "C:\Documents and Settings\Steph\Bureau\blabla2"; // On choisit le fichier qcm à analyser
Document doc = null;
try {
doc = builder.parse(f);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Element root = doc.getDocumentElement(); // On definit la racine du .xml
NodeList children = root.getChildNodes(); // On crée un arbre de node comprenant tout les successeurs immédiat de la racine
//test du Xml avec un keyHandler
Scanner in = new Scanner(System.in);
for (int i=0; i < children.getLength(); i++)
{
Node child = children.item(i);
if (child instanceof Element) // On entre que dans le node NbQuestions
{
Element childElement = (Element) child; // Convertit le child en classe Element
if (childElement.getTagName().equals("Question"))
{
String enonce = "";
//int NbReponses = 0;
ArrayList<Reponse> tabReponse = new ArrayList<Reponse>();//On crée un tableau d'objet Reponse
NodeList NodeQuestion = child.getChildNodes(); // On crée un arbre de node comprenant tout les successeurs immédiat de l'Element Question
for (int j=0; j < NodeQuestion.getLength(); j++)
{
Node childNodeQuestion = NodeQuestion.item(j);
if (childNodeQuestion instanceof Element)
{
Element ElementQuestion = (Element) childNodeQuestion; // On recupère l'Element Enonce
if (ElementQuestion.getTagName().equals("Enonce"))
{
Text textNode = (Text) ElementQuestion.getFirstChild();
enonce = textNode.getData().trim();
}
else if (ElementQuestion.getTagName().equals("Reponse")) // On recupère l'Element Reponse
{
String proposition = ""; // On initialise les variables proposition et solution de chaque objet Reponse
int solution = 0;
NodeList NodeReponse = childNodeQuestion.getChildNodes();
for (int k=0; k < NodeReponse.getLength(); k++)
{
Node childNodeReponse = NodeReponse.item(k);
if (childNodeReponse instanceof Element)
{
Element ElementReponse = (Element) childNodeReponse;
if (ElementReponse.getTagName().equals("Proposition"))
{
//String proposition;
Text textNode = (Text) ElementReponse.getFirstChild();
proposition = textNode.getData().trim();
//System.out.println("proposition : " +proposition);
}
else if (ElementReponse.getTagName().equals("Solution"))
{
//int solution;
Text textNode = (Text) ElementReponse.getFirstChild();
String text = textNode.getData().trim();
solution = Integer.parseInt(text);
//System.out.println("solution : " +solution);
}
}
}
tabReponse.add(new Reponse(proposition, solution)); // On ajoute un objet Reponse au tableau tabReponse
}
}
}
tabQuestion.add(new Question(enonce,tabReponse));
}
}
}
}
//Retourne la note du Qcm
public int getNoteQcm()
{
int noteQcm = 0;
for (Question q : tabQuestion)
if(q.getNote()==true) noteQcm += 1;
return noteQcm;
}
//Retourne le tableau de questions
public ArrayList<Question> gettabQuestion()
{
return tabQuestion;
}
private ArrayList<Question>tabQuestion = new ArrayList<Question>();
}
Vous n’avez pas trouvé la réponse que vous recherchez ?
nadimunam
Messages postés6Date d'inscriptionmercredi 7 juin 2006StatutMembreDernière intervention19 juin 2006 15 juin 2006 à 21:34
Bon j'vais oublié d'inclure toute les classes quand j'avais crée mon .jar
J'ai réessayer de relancer l'applet a partir du browser mais j'obtient toujours des erreurs :
java.lang.SecurityException: class "Affichage$1"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at Affichage.init(Affichage.java:50)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-Affichage.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
nadimunam
Messages postés6Date d'inscriptionmercredi 7 juin 2006StatutMembreDernière intervention19 juin 2006 15 juin 2006 à 22:38
Bon merci de ton aide Twinuts, apres moult essais j'trouve la source de mon erreur. Je pense que cela pourra aider d'autres personne car jai vu bcp de post qui trainer a ce sujet.
Un applet ne peut pas avoir acces a des fichiers meme si ils sont en local. Il fallait donc signé mon applet en créant une archive . jar
La mannip est tres bien expliquer ici : http://www.javafr.com/tutoriaux/APPLET-CONTOURNER-SECURITYMANAGER_439.aspx Pensez juste à mettre un jar cvf Archive.jar *.class dans le shell pour inclure toute vos .class dans l'archive.
J'avais juste inclue mon Affichage.class dans un premier temps comme dans l'exemple et je me suis retrouver avec plein d'erreur mais en incluant tout les fichier .class dans l'archive en tapper *.class ca marche nickel !!
Allez tchao tout le monde !