Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden. Du solltest ein Upgrade durchführen oder ein alternativer Browser verwenden.
Applet signiert, aber Browser fragt nicht nach Zertificat
mein Applet soll einfach nur nen JFileChooser aufrufen.
In Eclipse funzt das wunderbar, das Applet wird auch im Browser ausgeführt, nur leider kommt der FileChooser nicht, weil ich ja keine Berechitung habe - TROTZ gültiger Signatur.
Wenn du das Applet änderst und neu hochlädst musst du unbedingt den Java Cache löschen (nicht den Browser Cache!), sonst wird die alte Version aus dem Cache gefischt.
Schau doch mal ins Manifest, da müssen die Schlüssel für die Klassen aufgeführt sein.
Außerdem muss es im META-INF Verzeichnis zwei Dateien geben:
SIGNER.DSA
SIGNER.SF
Sollte das nicht so aussehen, ist das Jar-File definitiv nicht signiert. Dazu auch mal die Ausgaben beim Signieren lesen. Notfalls die .keystore-Datei löschen und noch mal neu signieren. Denn wenn du ein anderes Passwort eingeben willst, wird das bei einer bereits bestehenden .keystore-Datei nicht akzeptiert. Die Folge ist ein unsigniertes Jar-Archiv.
die manifest Datei wird doch wieder gelöscht nachdem die bat fertig durchgelaufen ist ?
Ein Verzeichnis METAINF habe ich leider nicht - .metadata habe ich im ProjektVerzeichnis in eclipse, aber da sind die beiden Dateien auch net drin ... und ne Fehlermeldung bekomme ich eigentlich nicht beim signieren.
Die jar erzeuge ich vorher mit FatJar ... oder gibts vielleicht damit die Probleme ?
So jetzt hat er mich gefragt und ich kann auch annehmen, aber seltsam ist, dass er mich nur 1x fragt, obwohl ich nicht gesagt habe "immer vertrauen" ... also irgendwie ist das hier sehr seltsam
Jetzt bekomme ich ne andere access denied meldung:
Exception in thread "AWT-EventQueue-10" java.security.AccessControlException: access denied (java.io.FilePermission C:\Dokumente und Einstellungen\Administrator\Recent read)
Jetzt nicht "schlagen", aber kann es was damit zu tun haben, dass er bei der SandboxAbfrage schreibt "...kann nicht verifiziert werden" oder hat das nur was damit zu tun, dass ich selber signiert habe ?
Genau, damit hat es was zu tun. Das ist einfach nur ein Hinweis für den Benutzer, dass die Angaben nicht beweisfähig sind, weil sie von dir selbst erzeugt wurden.
Das bedeutet, nicht, dass das ein Problem ist, sondern nur, dass die Quelle weiterhin unsicher ist.
Ok, ich hab jetzt mal das SSL Modul vom Apache rausgeschmissen und schon bekomme ich keine SandboxFrage mehr.
Jetzt weiß ich auch warum er vorhin das zert vom localhost angezeigt hat und nicht das der jar ...
So ... ich hab bis jetzt weitergegoogelt und versucht das Problem zu finden, aber es gelingt mir leider nicht.
Ich werde immernoch nicht gefragt, ob ich den Zugriff zulassen will, obwohl ich jetzt auch schon per Hand versucht habe das Teil zu signieren - also direkt über das KeyTool, auch mit dem PolicyTool hab ich kurz getestet, aber bringt auch nichts.
Jetzt vermute ich mal den Fehler im Code.
Code:
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.DefaultListModel;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
public class fileupload extends JApplet implements ActionListener {
private BorderLayout BL = new BorderLayout();
private JLabel title = new JLabel("FileChooserTest");
private JLabel imagePreviewLabel = new JLabel("Preview");
private JPanel imagePreview = new JPanel();
private JPanel buttonContainer = new JPanel();
private JButton infoButton = new JButton("info");
private JButton fileButton = new JButton("add");
private JButton removeButton = new JButton("remove");
private JScrollPane jsp = new JScrollPane();
private DefaultListModel listModel = new DefaultListModel();
private JList auswahlListe = new JList(listModel);
public fileupload() {
}
public void init() {
try {
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
} catch (Exception e) {
e.printStackTrace();
}
this.setLayout(BL);
title.setAlignmentX(50);
title.setFont(new Font("Helvetica", Font.BOLD, 12));
this.add(BorderLayout.NORTH, title);
this.add(BorderLayout.CENTER, jsp);
jsp.setAutoscrolls(true);
jsp.setVisible(true);
jsp.setViewportView(auswahlListe);
imagePreview.setPreferredSize(new Dimension(300,200));
imagePreviewLabel.setAlignmentX(2);
imagePreviewLabel.setFont(new Font("Helvetica", Font.PLAIN, 10));
imagePreview.add(imagePreviewLabel);
this.add(BorderLayout.EAST, imagePreview);
buttonContainer.setPreferredSize(new Dimension(200,30));
fileButton.setName("add");
fileButton.setPreferredSize(new Dimension(100,25));
fileButton.addActionListener(this);
removeButton.setName("remove");
removeButton.setPreferredSize(new Dimension(100,25));
removeButton.addActionListener(this);
infoButton.setName("info");
infoButton.setPreferredSize(new Dimension(100,25));
infoButton.addActionListener(this);
buttonContainer.add(fileButton);
buttonContainer.add(removeButton);
buttonContainer.add(infoButton);
this.add(BorderLayout.SOUTH, buttonContainer);
}
public void actionPerformed(ActionEvent e) {
if (((JButton)e.getSource()).getName() == "add") {
try {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Choose files");
fc.setName("FileViewer");
fc.setMultiSelectionEnabled(true);
int returnVal = fc.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File[] auswahl = fc.getSelectedFiles();
for (int i = 0; i< auswahl.length; i++) {
listModel.addElement(auswahl[i].toString());
}
}
} catch (Exception mye){
System.out.println(mye.toString());
}
} else if (((JButton)e.getSource()).getName() == "remove") {
listModel.remove(auswahlListe.getSelectedIndex());
}
}
}
Fehlermeldung der Konsole:
ClassLoader-Cache löschen... abgeschlossen.
Exception in thread "AWT-EventQueue-3" java.lang.NoClassDefFoundError: Could not initialize class sun.awt.shell.Win32ShellFolder2$ComTaskExecutor
at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.composePathForCsidl(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.<init>(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.getDesktop(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at javax.swing.filechooser.FileSystemView.getRoots(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at fileupload.actionPerformed(fileupload.java:92)
at java.awt.AWTEventMulticaster.actionPerformed(Unknown Source)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Du solltest Swing und AWT nicht mischen, da kann es auch zu Anzeigeproblemen kommen.
Also schreibe mal noch vor deine Panels, Buttons, Labels etc. noch ein "J" und importiere das Swing-Package.
Die Fehlermeldung könnte schon darauf hinweisen. Liegt vermutlich am setzen LookAndFeel auf AWT-Komponenten.
erstmal DANKE dass du dich überhaupt noch mit dem Thread hier beschäftigst - ich kann mir vorstellen, dass es schon nervt
Code:
Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError
at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.composePathForCsidl(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.<init>(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.getDesktop(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at javax.swing.filechooser.FileSystemView.getRoots(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at fileupload.actionPerformed(fileupload.java:86)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission shutdownHooks)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.Runtime.addShutdownHook(Unknown Source)
at sun.awt.shell.Win32ShellFolder2$ComTaskExecutor.<init>(Unknown Source)
at sun.awt.shell.Win32ShellFolder2$ComTaskExecutor.<clinit>(Unknown Source)
... 29 more
hab ich diesmal ausgespuckt bekommen, bei der selben jar, er kann sich anscheinen nicht entscheiden
Wie schon oben beschrieben, setze ein "J" vor deine Panels, Buttons und Labels. Du kannst nur Swing-Komponenten ein LookAndFeel verpassen. Wenn du das mit AWT-Komponenten versuchst, könnte es sein, dass diese Exceptions geworfen werden.
So ... hab nochmal alles neu installiert .. leider das selbe.
Auch wenn ich das LookAndFeel rausnehme spuckt er noch die Meldung aus.
Es muss anscheinend doch noch was mit der Signierung zu tun haben.
EDIT:
Also was schonmal ein Problem zu sein scheint ist vorher eine jar mit FatJar zu erzeugen.
Habe ich jetzt mal nicht gemacht und nur die bat von dir genutzt - die jar ist nun 100%ig signiert ... vorher hat er bei SHA1 nen Fehler gezeigt ... totzdessen klappt es immernoch nicht.
Also der Hund muss noch woanders begraben sein... hab mir jetzt mehrere Beispiele angeschaut und keines läuft bei mir, auch nicht direkt in Eclipse als Applikation:
Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.awt.shell.Win32ShellFolder2.getFileSystemPath(I)Ljava/lang/String;
at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Native Method)
at sun.awt.shell.Win32ShellFolder2.<init>(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.getDesktop(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at javax.swing.filechooser.FileSystemView.getRoots(Unknown Source)
at javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder(Unknown Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at TestFileChooser_simple.<init>(TestFileChooser_simple.java:13)
at TestFileChooser_simple.main(TestFileChooser_simple.java:20)
Aaaalso .... ich hab rausgefunden, dass es am JFileChooser liegt, den FileDialog kann ich Problemlos aufrufen ... anscheinend findet er irgendwas nicht ... naja, steht ja eigentlich auch in der Fehlerausgabe ... ich weiß nur noch nicht genau was ihm fehlt und wie ich es ändern kann.
So jetzt habe ich noch eine Lösung im Netz gefunden, Problem ist nur, dass ich keinen Zugriff auf java.library.path bekomme:
Code:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.DefaultListModel;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
public class fileupload extends JApplet implements ActionListener {
private BorderLayout BL = new BorderLayout();
private JLabel title = new JLabel("FileChooserTest");
private JLabel imagePreviewLabel = new JLabel("Preview");
private JPanel imagePreview = new JPanel();
private JPanel buttonContainer = new JPanel();
private JButton infoButton = new JButton("info");
private JButton fileButton = new JButton("add");
private JButton removeButton = new JButton("remove");
private JScrollPane jsp = new JScrollPane();
private JScrollPane jspImage = new JScrollPane();
private DefaultListModel listModel = new DefaultListModel();
private JList auswahlListe = new JList(listModel);
public fileupload() {
super();
}
public void init() {
super.init();
try {
Runtime.getRuntime().loadLibrary("swt-win32-3139.dll");
} catch( Throwable e) {
System.out.println("Load Library failed" );
String path = System.getProperty("java.library.path");
String[] paths = path.split(File.pathSeparator);
String targetDir = null;
for (int i = 0; i < paths.length; i++) {
String t = paths[i];
if( testWriteable(t) ) {
targetDir = t;
break;
}
}
if( targetDir != null ) {
download( "swt-win32-3139.dll", targetDir );
download( "swt-awt-win32-3139.dll", targetDir );
} else {
JOptionPane.showMessageDialog(this,"Could not download swt dlls, java.library.path not writeable",
"Error Downloading DLLs", JOptionPane.ERROR_MESSAGE);
}
}
try {
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
} catch (Exception e) {
e.printStackTrace();
}
this.setLayout(BL);
title.setAlignmentX(50);
title.setFont(new Font("Helvetica", Font.BOLD, 12));
this.add(BorderLayout.NORTH, title);
this.add(BorderLayout.CENTER, jsp);
jsp.setAutoscrolls(true);
jsp.setVisible(true);
jsp.setViewportView(auswahlListe);
jspImage.setAutoscrolls(true);
jspImage.setVisible(true);
//jspImage.setViewportView(auswahlListe);
imagePreview.setPreferredSize(new Dimension(300,200));
imagePreviewLabel.setAlignmentX(2);
imagePreviewLabel.setFont(new Font("Helvetica", Font.PLAIN, 10));
imagePreview.add(imagePreviewLabel);
this.add(BorderLayout.EAST, imagePreview);
buttonContainer.setPreferredSize(new Dimension(200,30));
fileButton.setName("add");
fileButton.setPreferredSize(new Dimension(100,25));
fileButton.addActionListener(this);
removeButton.setName("remove");
removeButton.setPreferredSize(new Dimension(100,25));
removeButton.addActionListener(this);
infoButton.setName("info");
infoButton.setPreferredSize(new Dimension(100,25));
infoButton.addActionListener(this);
buttonContainer.add(fileButton);
buttonContainer.add(removeButton);
buttonContainer.add(infoButton);
this.add(BorderLayout.SOUTH, buttonContainer);
}
private boolean testWriteable(String dir) {
try {
FileOutputStream fos = new FileOutputStream( dir + File.pathSeparator + "test" );
fos.write(1);
fos.close();
File f = new File( dir + File.pathSeparator + "test" );
f.delete();
return true;
} catch( Exception e){
}
return false;
}
private void download(String filename, String targetDir) {
try {
URL url = new URL( getCodeBase() + filename );
InputStream is = url.openStream();
File of = new File(targetDir + "/" + filename);
FileOutputStream o = new FileOutputStream( of );
System.out.println("downloading from " + url + "to " + of.getAbsolutePath());
byte[] buffer = new byte[10000];
while( true ) {
int c = is.read(buffer);
if( c == -1 ) break;
o.write(buffer,0,c);
}
o.close();
is.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent e) {
if (((JButton)e.getSource()).getName() == "add") {
try {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Choose files");
fc.setName("FileViewer");
fc.setMultiSelectionEnabled(true);
int returnVal = fc.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File[] auswahl = fc.getSelectedFiles();
for (int i = 0; i< auswahl.length; i++) {
listModel.addElement(auswahl[i].toString());
}
}
auswahlListe.addListSelectionListener(new listListener(auswahlListe, jspImage));
} catch (Exception mye){
System.out.println(mye.toString());
}
} else if (((JButton)e.getSource()).getName() == "remove") {
listModel.remove(auswahlListe.getSelectedIndex());
}
}
}
Load Library failed
java.security.AccessControlException: access denied (java.util.PropertyPermission java.library.path read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at fileupload.init(fileupload.java:57)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)