[jcifs] RE: JCFIS java.lang.NullPointerException
Daniel Rychlik
drychlik at securustech.net
Mon Nov 6 22:37:32 GMT 2006
I really need some help...
-----Original Message-----
From: Daniel Rychlik
Sent: Monday, November 06, 2006 4:29 PM
To: Daniel Rychlik; 'jcifs at lists.samba.org'
Subject: RE: JCFIS java.lang.NullPointerException
Does anyone have any idea about this? This is the stacktrace given back from my compiled jar file.
SMB FILE EXITS EXCEPTION java.lang.NullPointerException
java.lang.NullPointerException
at jcifs.smb.SmbComSessionSetupAndX.writeParameterWordsWireFormat(SmbComSessionSetupAndX.
a:58)
at jcifs.smb.AndXServerMessageBlock.writeAndXWireFormat(AndXServerMessageBlock.java:94)
at jcifs.smb.AndXServerMessageBlock.encode(AndXServerMessageBlock.java:65)
at jcifs.smb.SmbTransport.doSend(SmbTransport.java:402)
at jcifs.util.transport.Transport.sendrecv(Transport.java:70)
at jcifs.smb.SmbTransport.send(SmbTransport.java:602)
at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:269)
at jcifs.smb.SmbSession.send(SmbSession.java:225)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:147)
at jcifs.smb.SmbFile.connect(SmbFile.java:791)
at jcifs.smb.SmbFile.connect0(SmbFile.java:761)
at jcifs.smb.SmbFile.queryPath(SmbFile.java:1167)
at jcifs.smb.SmbFile.exists(SmbFile.java:1253)
at vlicMaster.smbFileHandler.smbFileExists(smbFileHandler.java:83)
at vlicMaster.smbFileHandler.smbFileManager(smbFileHandler.java:41)
at vlicMaster.vlic_master.exodus_packageDelivery(vlic_master.java:192)
at vlicMaster.vlic_master.exodus_Director(vlic_master.java:240)
at vlicMaster.vlic_master.main(vlic_master.java:429)
-----Original Message-----
From: Daniel Rychlik
Sent: Saturday, November 04, 2006 10:14 AM
To: 'jcifs at lists.samba.org'
Subject: JCFIS java.lang.NullPointerException
Hello,
I am having an issue that doesn$B!G(Jt make sense to me. I have gotten this code to work exceptionally well under my netbeans IDE environment but after I build my project, with the JCIFS jar, I get a java.lang.NullPointerException. Works fine in editor when testing, but fails when I put in production$B!D(J
Here is a simple class that I use to check a directory structure and if it doesn$B!G(Jt exists it creates it, and then it copies a list of files which are stored in a LinkedList. I do a lot of automation and have hundreds of NT, 2K, XP systems in the field. Some of which are dialup$B!D(J $B"+(J fun.
Never the less I tried to put this in production last night and ran across this very annoying problem with the null pointer exception. Has anyone run into this before?
Here is class I coded. I basically took the examples and expanded up on those to fit my needs. My servers are windows 2003, my build machine is XP. Like I said it works like a champ in the Netbeans IDE environment when I am building and testing, but when its all wrapped in a Jar it fails$B!D(J
public class smbFileHandler {
private LinkedList<String> smbHandlerLog = new LinkedList<String>();
// Getter for the log
public LinkedList getSmbHandlerLog()
{
return smbHandlerLog;
}
/** Creates a new instance of smbFileHandler */
public smbFileHandler()
{
}
// SMB File handler Manager
public void smbFileManager(String smbConn,String[] directories,LinkedList files) throws Exception
{
System.out.println("(SMB FILE MANAGER) " + smbConn);
try
{
// Check the remote directory structure
for (int i = 0; i < directories.length; i++)
{
if (!smbFileExists(smbConn + directories[i]))
{
new SmbFile(smbConn + directories[i]).mkdir();
}
}
// Process the files in the programs List
String[] data = new String[3];
for (Object s: files)
{
data = s.toString().split(",");
if (data[2].equals("check"))
{
if (!smbFileExists(data[1]))
{
smbFileWrite(data[0],data[1]);
}
}
else
{
smbFileWrite(data[0],data[1]);
}
}
} catch (Exception e)
{
System.out.println("SMB EXCEPTION " + e.toString());
throw new Exception("93" + e.toString());
}
}
// SMB File Exists
private boolean smbFileExists(String file) throws Exception
{
System.out.println("Exists ? " + file);
try
{
SmbFile f = new SmbFile(file);
if( f.exists() ) {
System.out.println( file + " exists" );
return true;
} else {
System.out.println( file + " does not exist" );
return false;
}
} catch (Exception e)
{
System.out.println("SMB FILE EXITS EXCEPTION " + e.toString());
throw new Exception("93" + e.toString());
}
}
// Write the file using smb protocol
private void smbFileWrite(String sourceFile, String destinationFile) throws Exception
{
try
{
System.out.println("Source File " + sourceFile);
System.out.println("Destination File " + destinationFile);
SmbFile f = new SmbFile(destinationFile);
FileInputStream in = new FileInputStream(sourceFile);
SmbFileOutputStream out = new SmbFileOutputStream( f );
long t0 = System.currentTimeMillis();
byte[] b = new byte[512];
int n, tot = 0;
while(( n = in.read( b )) > 0 ) {
out.write( b, 0, n );
tot += n;
}
long t = System.currentTimeMillis() - t0;
System.out.println();
System.out.println( tot + " bytes transfered in " + ( t / 1000 ) + " seconds at " + (( tot / 1000 ) / Math.max( 1, ( t / 1000 ))) + "Kbytes/sec" );
in.close();
out.close();
} catch (Exception e)
{
throw new Exception("93" + e.toString());
}
}
}
More information about the jcifs
mailing list