[jcifs] Re: tomcat url unknown protocol: smb
Andreas Panagiotidis
andrepan at ethz.ch
Wed Apr 16 18:55:45 GMT 2008
Dear Mike Allen,
thank you for the great FAQ (more a quick manual).
I somehow knew that contains the solution to my problem, somewhere.
I've just added in the Tomcat catalina.sh in the CLASSPATH the jar (I
put it in the CATALINA_HOME/lib)
That solved the problem. so , simple... and it was in the manual in
first place.
FAQ Answer to URL unknown protocol:
The jCIFS jar file is not in a suitable location. Even if the
java.protocol.handler.pkgs property is set successfully, the
java.net.URL class must then access the jcifs.smb.Handler class. But
if the jCIFS classes are loaded by a different class loader this
handler will not be found and again, you will get the "unknown
protocol: smb" exception. It is very common for servlet containers to
load classes from a class loader other than the System class loader.
Like the first scenario, the solution is to add the jCIFS jar file to
the container's CLASSPATH and not the WEB-INF/lib directory of the web
app.
I was missing to add it to the classpath.
http://jcifs.samba.org/src/docs/faq.html
Enjoy,
cheers!
Andreas Panagiotidis
On 16 Apr, 2008, at 6:49 PM, Andreas Panagiotidis wrote:
>
> Hello all,
>
> I try to access a samba server using tomcat and I get to popular(?)
> exception of unknown protocol:
>
> java.net.MalformedURLException: unknown protocol: smb
> at java.net.URL.<init>(URL.java:574)
> at java.net.URL.<init>(URL.java:464)
> at java.net.URL.<init>(URL.java:413)
> at movieadmin.user.Console.connectToNas(Console.java:204)
>
>
> I've already tried to access the smb server with jcifs from a stand-
> alone class and it works perfect.
> my system is OSX, Java 6, Tomcat 6.0.16, JCifs 1.2.19
>
> I 've tried using the jcifs.jar in the web-inf/lib, it wasn't working.
> Then I've placed it , in $TOMCAT_HOME/lib and remove the jar from
> the "war -> web-inf/lib"
>
> I had the Config.registerSmbURLHandler(); in my code, then I've put
> java.protocol.handler.pkgs=jcifs at the catalina.sh script
> I can't figure out the problem, since I see in the output, that the
> property "java.protocol.handler.pkgs" has value jcifs.
>
>
> Please help!
>
> Andreas Panagiotidis
>
>
>
>
> my code is as follows:
>
> //jcifs.Config.registerSmbURLHandler();
>
> Properties prop = System.getProperties();
> System.out.println(prop);
>
> String value = prop.getProperty("java.protocol.handler.pkgs");
> System.out.println("pkg property value:" + value);
>
> String location = "smb://nas-biol-ibt-1/share-1-$/biol/";
>
>
> NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",
> "andreas", "password");
>
> try {
>
> java.net.URL url = new URL(location);
>
> SmbFile file = new SmbFile(url, auth);
> ...
> }
>
-------------- next part --------------
HTML attachment scrubbed and removed
More information about the jcifs
mailing list