If you have trouble tracking down the problem when using classpath resource, try first to configure jproxyloader by means of local file configuration or system properties configuration. This is because classpath configuration is loaded when the first connection is made, so if you encounter a problem before the first connection you may not see the real reason of the problem. This situation is explained in more details below - see issue with "UnknownHostException: some.host.com" to understand this better.
If you get startup error - ClassNotFoundException like the one below it means that jproxyloader.jar was not properly placed on classpath and therefore custom classloader net.sf.jproxyloader.JProxyLoader could not have been found.
Error occurred during initialization of VM java.lang.Error: java.lang.ClassNotFoundException: net.sf.jproxyloader.JProxyLoader at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1463) at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1430) Caused by: java.lang.ClassNotFoundException: net.sf.jproxyloader.JProxyLoader
To solve this use correct way of placing jar on classpath. The easiest way is to add "-cp jproxyloader-X.X.jar" (replace X.X with the version of jProxyLoader you are using) to java params of your application.
If you get UnknownHostException: some.host.com it means that application which you are trying to proxify trys to resolve ip address of the host before opening the connection to another url. Normally this is not a problem since local dns should be able to resolve the ip of the host. However in certain situations where only the DNS behind proxy is aware how to resolve certain domain name you may run into exception presented below. To solve this you can provide ip of the host (instead of domain name) if your application allows this (for example it has configuration file where you can replace the domain name of the host with its ip) - this is however seldom possible. Another workaround is to configure localdns to resolve unknown domain name to static ip. If all of this is not an option than you can instruct jProxyLoader to use extra dns server which is able to resolve this "unknown domain name". The dns might be behind proxy. In this case you may also need to pass the ip of dns server to jProxyLoader configuration so that connection to this dns server also goes via proxy (so in other words instruct jProxyLoader that any request to ip of your custom dns server should go via proxy). See documentation how to set up custom dns servers via jProxyLoader.
IMPORTANT: If you use configuration basing on classpath and you get this error on startup, try first to configure jProxyLoader basing on file or system properties. This will allow to set up custom dns servers as early as possible. This prevents following situation: you set up custom dns servers using classpath configuration. Before jProxyLoader reloads the configuration from classpath (classpath resources uses "late initialization) your application trys to resolve unknown domain name. This domain name can be resolved by your DNS server (defined on classpath resource) but this DNS server was not yet setup. Therefore you should use system properties or file based config to initialize DNS servers in such situation.
The issue usually results in following exception:
Caused by: java.net.UnknownHostException: some.host.com at java.net.InetAddress.getAllByName0(InetAddress.java:1259) at java.net.InetAddress.getAllByName(InetAddress.java:1171) at java.net.InetAddress.getAllByName(InetAddress.java:1105) (...)
When the proxy is down you may receive misleading exception. Currently jProxyLoader does not verify that proxy is actually responding. If you get exception like "java.net.SocketException: Unknown proxy type : HTTP" make sure that proxy is up and running. This issue will be addressed in future versions of jProxyLoader to detect proxies which are down. Below you can find example of such "misleading" stacktrace.
Exception in thread "main" java.net.SocketException: Unknown proxy type : HTTP at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at MyApp.printResponseLength(MyApp.java:21) at MyApp.main(MyApp.java:13)