• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Applet to upload files with SCP to

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I create an applet to Upload files using SCP to.
I use the com.jcraft.jsch_0.1.44.jar to do the SCP to Client.
This work in eclipse, but in web a have an error:


java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/jcraft/jsch/UserInfo
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.lang.NoClassDefFoundError: com/jcraft/jsch/UserInfo
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.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(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.lang.ClassNotFoundException: com.jcraft.jsch.UserInfo
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)
... 20 more
Exceção: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/jcraft/jsch/UserInfo

The jar file is include in BuildPath and I export the JAR in File>export menu. What Happen? Please....
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the applet tag and the layout of the files and directories on the server.
 
Luis Martins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the applet tag:

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"
width="130" height="25" mayscript="true">
<param name="type" value="application/x-java-applet;version=1.4">
<param name="code" value="SmartCardSignerApplet">
<param name="archive" value="SmartCardSignerApplet.jar">
<param name="archive" value="itext.jar">
<param name="mayscript" value="true">
<param name="scriptable" value="true">
<param name="fileNameField" value="fileToBeSigned">
<param name="certificationChainField" value="certificationChain">
<param name="signatureField" value="signature">
<param name="signButtonCaption" value="Gerar Assinatura">
<comment>
<embed
type="application/x-java-applet;version=1.4"
pluginspage="http://java.sun.com/products/plugin/index.html#download"
code="SmartCardSignerApplet" archive="SmartCardSignerApplet.jar"
width="130" height="25"
mayscript="true" scriptable="true"
fileNameField="fileToBeSigned"
certificationChainField="certificationChain"
signatureField="signature"
signButtonCaption="Gerar Assinatura">
<noembed>
Sistema de Assinatura de Documentos não pode ser carregado,
Por Favor Instale o Plugin Java mais recente!
</noembed>
</embed>

the archieve is an xml...
 
Tim Moores
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where are the JSch classes - in SmartCardSignerApplet.jar? If they're not, then you need to mention the jar file they're in as part of the archive attribute's value.

At least that's how the applet tag works, I consider object and embed more trouble than they're worth.
 
Luis Martins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see the JSch classes are not included to the jar. How can I include the JSch.jar in the JAR exported from eclipse???
 
Tim Moores
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't do that, those classes have nothing to do with your applet, and you may wish to update (and use) them separately. Just make sure that your archive attribute looks something like: archive="SmartCardSignerApplet.jar, jsch.jar"
 
Luis Martins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:I wouldn't do that, those classes have nothing to do with your applet, and you may wish to update (and use) them separately. Just make sure that your archive attribute looks something like: archive="SmartCardSignerApplet.jar, jsch.jar"



I Tryed, but don't work....

here the code:

private void salvaServer (String fl) throws IOException, JSchException{
JSch jsch=new JSch();
Session session=jsch.getSession("root", "192.168.2.10", 22);

// UserInfo ui= new MyUserInfo();
// session.setUserInfo(ui);

session.setUserInfo(new UserInfo() {
public String getPassphrase() {
return null;
}
public String getPassword() {
return "passString";
}
public boolean promptPassword(String message) {
return true;
}
public boolean promptPassphrase(String message) {
return false;
}
public boolean promptYesNo(String message) {
return true;
}
public void showMessage(String message) {
}
});


session.connect();
String command="scp -p -t "+"arquivo-assinado.xml";
Channel channel=session.openChannel("exec");
((ChannelExec)channel).setCommand(command);

OutputStream out=channel.getOutputStream();
InputStream in=channel.getInputStream();

channel.connect();

if(checkAck(in)!=0){
System.exit(0);
}


long filesize=(new File(fl)).length();
command="C0644 "+filesize+" ";
if(fl.lastIndexOf('/')>0){
command+=fl.substring(fl.lastIndexOf('/')+1);
}
else{
command+=fl;
}
command+="\n";
out.write(command.getBytes()); out.flush();
if(checkAck(in)!=0){
System.exit(0);
}

// envia conteudo do arquivo
FileInputStream fis=new FileInputStream(fl);
byte[] buf=new byte[1024];

int len = buf.length;

out.write(buf, 0, len);

fis.close();
fis=null;

buf[0]=0; out.write(buf, 0, 1); out.flush();
if(checkAck(in)!=0){
System.exit(0);
}
out.close();

channel.disconnect();
session.disconnect();

/*
File dir = new File("C:\\XML");
if(dir.exists()){
for ( File f : dir.listFiles() ) {//apaga arquivos da maquina do usuário

if (f.isFile()) {

f.delete();
}
}//fecha for verifica arquivos na pasta
dir.delete();
}//fecha verifica se diretorio existe
*/

System.exit(0);
}//fecha salva file

I don't know what to do. Thanks for attention....
 
Tim Moores
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you tried? What does the code have to do with how you're deploying it?
 
Luis Martins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried make the archive attribute like this: archive="SmartCardSignerApplet.jar, jsch.jar"
But don't work.

The code do:

- copy a xml archieve from the server to disc - this is ok.

- open this xml, acess a A3 certificate, sign the xml (XMLDSIG RFC 3275) and save the signed xml to disc - this ok too.

- after this, i have to send the signed xml to my server using the SCP protocol.

Its run in an applet. But when I run the applet I have the error message. I can attach the project, and distribuition if you need. Thanks again.

 
Tim Moores
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both jar files must be in the same directory as the HTML file; are they?
 
Luis Martins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Same directory. I had imported other class of com.jcraft.jsch and it loaded, but only the class UserInfo not loaded. I changed the version of JAR file, and had the same error.

to download the files of project: www.ecowebstudio.com.br/Project.zip
to download the files of distribuition: www.ecowebstudio.com.br/Dist.zip

Thanks.
 
Luis Martins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the error.

The JARs files from JSch may be copied to /lib/ext from JRE.
 
Your mother was a hamster and your father was a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic