bsquared
bsquared

Reputation: 137

SmbFileInputStream Throwing Fatal Exception: main

I am trying to read an xml file from a file system using samba. My app crashes with the only error being:

FATAL EXCEPTION: main Process: com.example.imac.chs_pharmacy, PID: 2615 java.lang.ExceptionInInitializerError

It crashes on the line:

SmbFileInputStream fXmlFile = new SmbFileInputStream(sFile);

I have also used this line instead, with the same result:

InputStream fXmlFile = sFile.getInputStream();

Here is the code snippet I am using:

try {
    String user = "user";
    String pass ="pass";

    String url = "smb://ip/public/chs/" + message + ".xml";
    Log.d(TAG, url);

    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, user, pass);

    SmbFile sFile = new SmbFile(url, auth);

    SmbFileInputStream fXmlFile = new SmbFileInputStream(sFile);

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    Document doc = dBuilder.parse(fXmlFile);

    doc.getDocumentElement().normalize();
    }

I am not sure why it's not working, any help would be appreciated

Upvotes: 0

Views: 191

Answers (1)

fabfas
fabfas

Reputation: 2228

The java.lang.ExceptionInInitializerError is used as a wrapper to indicate that an exception arises in the static initializer block or the evaluation of a static variable’s value.

Thus, we have to ensure that the original exception is fixed, in order for the JVM to be able to load class successfully.

Upvotes: 1

Related Questions