| HttpUrlConnection caching ip |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- where is the maximize button in JDialog?Anybody knows how to get a JDialog to display a maximize
button like a JFrame does? The default JDialog does not come with
maximize or minimize button? I checked out the API for JDialog and
could not find the answer. Can anybody help me out?
- 2
- I am having trouble with OJB and locking when adding things that have cascading relationshipsHi all, I am using OJB and I can't seem to add a record to the
database if that object contains another object that is a) mapped in
the mapping and b) not already in the mapping. The error I get is:
OJB works reliably in all the other test suits:
-- adding any object and not imposing any connections, ie, they have
no elements that need to cascade
-- retreiving results (either with a criteria or alll records)
I dont know whats going on and would appreciate som ehelp - thanks in
advance
Josh
Time: 2.674
There was 1 error:
1) testAddProjectWithExistingEmployer(com.joshlong.portfolio.bos.tests.PortfolioTest)com.joshlong.portfolio.PortfolioException:
org.odmg.LockNotGrantedException: Can not lock ID:0Finished:Mon Nov 10
04:02:34 PST 2003
Started:Mon Nov 10 04:02:34 PST 2003
Title:Foo Bar
Employer:
------------------------
public void testAddProjectWithNewEmployer()
throws Exception {
// the pk for the Employer class is id and I didnt
//set it -- I want OJB to add it as well as add the Employer
//which also doesnt have the pk set which I presume makes it
// add it as opposed to updating it ...
Employer employer = new Employer();
employer.setContactInfo("this is the contact info");
employer.setName("le nom - " + new Date());
employer.setDuties("a;b;c;d");
portfolio.addEmployer(employer); // see below fo rthe code
behind addEmployer ( Employer);
Employer e = portfolio.getEmployerByName(name);
Project project = new Project();
project.setEmployer(employer);
project.setDescription("This is a description of the
things.");
project.setFinished(new Date());
project.setStarted(new Date());
project.setName("Joshua Long");
portfolio.addProject(project);
}
addEmployer is basically just a more specific method that in turn
calls:
void addRecord ( Object record )
throws PortfolioException
{
Implementation i = OJB.getInstance();
Database db = i.newDatabase();
db.open("default", Database.OPEN_READ_WRITE);
Transaction txc = i.newTransaction();
txc.begin();
txc.lock(record, Transaction.WRITE);
txc.commit();
db.close() ;
}
- 3
- JCE - load key from stringHi All,
We're trying to use JCE to encrypt some data. The issue is key storage.
We want to store it in some database, so the question is how to
re-create the key for decryption from varchar2 column?
The key in string form looks like this:
cryptix.jce.provider.key.RawSecretKey@3bfce353
This can be stored in the database easily. But how to load this into
KeyStore back?
TIA
Michael
- 3
- XPathAPI(node, xpathStr) & XPathContext.getDTMHandleFromNode(node) slowHello,
I am using xalan 2.7.0: http://xml.apache.org/xalan-j/
As I run XPathAPI.eval(node, xpathStr) over and over again on several
nodes, it gets slower and slower.
This is documented in the XPathAPI documentation, and it suggests to
use the low-level XPath API:
http://xml.apache.org/xalan-j/apidocs/org/apache/xpath/XPathAPI.html
I am now using the low-level XPath API as follows:
XPathContext xpathSupport = new XPathContext();
PrefixResolverDefault prefixResolver = new
PrefixResolverDefault(document);
XPath xpath = new XPath(xpathStr, null, prefixResolver,
XPath.SELECT, null);
and then, for each node:
int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);
XObject object = xpath.execute(xpathSupport, node,
prefixResolver);
It gets a bit better, but still, after using over and over again on
several nodes, it gets slower and slower.
I think that the problem is that
XPathContext.getDTMHandleFromNode(child) does not free memory.
Test this simplistic example yourself:
++++++++++++++++++++++++++++++++++++++++++++
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import org.apache.xpath.*;
import org.apache.xml.utils.*;
public class Test {
public static void main(String[] argv) throws Exception {
int numChilds = 100000+1;
System.out.println("Building a document with " + numChilds + "
childs");
Document doc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = doc.createElement("root");
doc.appendChild(root);
for (int i = 0; i < numChilds; i ++) {
Element child = doc.createElement("child");
root.appendChild(child);
Element subChild = doc.createElement("sub-child");
child.appendChild(subChild);
Element subSubChild = doc.createElement("sub-sub-child");
subChild.appendChild(subSubChild);
subSubChild.setAttribute("title", "title" + i);
}
XPathContext xpathSupport = new XPathContext();
PrefixResolverDefault prefixResolver = new
PrefixResolverDefault(doc);
XPath titleXpath = new XPath("sub-child/sub-sub-child/@title",
null, prefixResolver, XPath.SELECT, null);
Runtime r = Runtime.getRuntime();
System.out.println("Evaluating XPath for each " + numChilds +
" childs");
NodeList nodeList = root.getChildNodes();
int size = nodeList.getLength();
for (int i = 0; i < size; i++) {
long start = System.currentTimeMillis();
Element child = (Element) nodeList.item(i);
int ctxtNode = xpathSupport.getDTMHandleFromNode(child);
//String title = titleXpath.execute(xpathSupport,
ctxtNode, prefixResolver).toString();
long duration = System.currentTimeMillis() - start;
if (i < 10 || (i % (numChilds/10)) == 0)
System.out.println("child #" + i + "\t took " +
duration + " ms." +
"\tfreeMemory: " + r.freeMemory() +
"\ttotalMemory: "+r.totalMemory());
else if (i == 10)
System.out.println("printing some selected childs only
from now on...");
}
}
}
++++++++++++++++++++++++++++++++++++++++++++
Here you can see an example of the result:
$ java Test
Building a document with 100001 childs
Evaluating XPath for each 100001 childs
child #0 took 77 ms. freeMemory: 10642840 totalMemory:
45129728
child #1 took 1 ms. freeMemory: 10583848 totalMemory:
45129728
child #2 took 0 ms. freeMemory: 10583848 totalMemory:
45129728
child #3 took 0 ms. freeMemory: 10583848 totalMemory:
45129728
child #4 took 0 ms. freeMemory: 10583848 totalMemory:
45129728
child #5 took 0 ms. freeMemory: 10583848 totalMemory:
45129728
child #6 took 0 ms. freeMemory: 10583848 totalMemory:
45129728
child #7 took 1 ms. freeMemory: 10583848 totalMemory:
45129728
child #8 took 0 ms. freeMemory: 10583848 totalMemory:
45129728
child #9 took 0 ms. freeMemory: 10583848 totalMemory:
45129728
printing some selected childs only from now on...
child #10000 took 3 ms. freeMemory: 10980392 totalMemory:
45129728
child #20000 took 5 ms. freeMemory: 9976808 totalMemory:
45129728
child #30000 took 7 ms. freeMemory: 6332656 totalMemory:
45129728
child #40000 took 9 ms. freeMemory: 5112168 totalMemory:
45129728
child #50000 took 12 ms. freeMemory: 1373472 totalMemory:
45129728
child #60000 took 14 ms. freeMemory: 19851264 totalMemory:
66650112
child #70000 took 16 ms. freeMemory: 16515832 totalMemory:
66650112
child #80000 took 19 ms. freeMemory: 15040280 totalMemory:
66650112
child #90000 took 21 ms. freeMemory: 7435744 totalMemory:
66650112
child #100000 took 24 ms. freeMemory: 17416944 totalMemory:
66650112
++++++++++++++++++++++++++++++++++++++++++++
each time I call xpathSupport.getDTMHandleFromNode(child) it does not
free the memory,
and so it gets slower and slower.
How to solve this problem?
Some people has suggested to use the DOM4J package instead of Xalan.
However, we already have quite a lot of software using Xalan and
changing the code would have some cost.
Is it possible to solve this problem without discarding xalan?
Regards,
DAvid
- 3
- tomcat/applet question...this is really weird, in tomcat/webapps/<appName>I have a jsp AND an
applet.. I'm using a package called smack for writing jabber clients
(http://www.jivesoftware.org/smack/), so:
in jsp:
<%@ page import="org.jivesoftware.smack.*"%>
no problems...
in applet:
import org.jivesoftware.smack.*;
when try to compile get told this package doesn't exist...
package is where all packages are supposed to be in Tomcat
(C:\tomcat\common\lib) and, again, the jsp has no problems with it, but
the applet, which is in exact same location as jsp, for some reason
can't find it..
(in applet am even getting en error (identifier expected) on
system.out.println()... don't know what to make of this..
this is line: System.out.println("test");...)
weird thing is, if I hide System.out.println() line get told package
smack doesn't exist.. if I don't hide System.out.println() line get
ONLY identifier-expected error on System.out.println() line..
would appreciate any help... thank you.. Frances
- 3
- Quick help needed. Code runs, but one problem cannot be solvedHey, guys. I designed this code for guessing numbers.
The program should pick a random number between 1 and 10, inclusive
both. Then repeatedly prompt the user to guess the number. On each
guess report to the user that he or she is correct or that the guess is
high or low. Continue accepting guesses until the user guesses
correctly or choose to quit. Count the number of guesses and report
that value when the user guesses correctly. At the end of each game,
prompt to determine whether the user wants to play again. Continue
playing games until the user chooses to stop
Here is the problem, I let the random number print, so I know what
number is it. But when I input that number, instead of showing up
"Congratulations...", it shows up the correct number I entered is too
high. Please let me know what is going on. Thank you
//Code started!
import java.util.Random;
import java.util.Scanner;
public class HighLow
{
//
// Plays the Hi-Lo guessing game with the user
//
public static void main(String[] args)
{
boolean done = false;
boolean playAgain = true;
Random numberGenerator = new Random();
int randomNumber, numberOfGuesses, userNumber;
Scanner scan = new Scanner(System.in);
//
// Constants for messages to the user
//
final String guessMessage = "Enter your guess (-1 to quit): ";
final String tooHigh = "Sorry, the number you entered is higher than
my number.";
final String tooLow = "Sorry, the number you entered is lower than my
number.";
final String justRight = "Congratulations! You guessed my number!";
final String playAgainMessage = "Play again?";
while (playAgain) {
//
// Pick a random number
//
randomNumber = numberGenerator.nextInt(10) + 1;
System.out.println("The correct number is " +randomNumber);
//
// Start the guessing game
//
System.out.print(guessMessage);
userNumber = scan.nextInt();
numberOfGuesses = 1;
if (userNumber > randomNumber)
{
System.out.println(tooHigh);
numberOfGuesses += 1;
}
if (userNumber <0 && userNumber!=-1)
{
System.out.println("1-10 only");
}
if (userNumber < randomNumber && userNumber > 0)
{
System.out.println(tooLow);
numberOfGuesses += 1;
}
if (userNumber == randomNumber)
{
System.out.println(justRight);
numberOfGuesses += 1;
System.out.println("It taks you " +numberOfGuesses+ " times to
guess right");
}
//
// Check to see if the user wants to stop guessing
//
if (userNumber == -1)
done = true;
//
// Check to see if the user wants to play again
//
System.out.print("Would you like to play again? (y/n)? ");
if (scan.next().equals("n"))
playAgain = false;
else
done = false;
} // while loop
System.out.println("Thanks for playing! Bye!" );
} //method main
} //class HiLoGame
- 4
- JTable and optimal column width.Hi!
I have a JTable which has to columns filled over an 'String[][]'. Is it
possible, to set the cell width to the longest value in an column?
I found a solution with String.lengt() over Google, but this doesn't work
correctly because the value of String.length() doesn't fit exactly. I think
this is because the proportional fonts.
Greetings,
Christian.
- 4
- problem with xercesImpl.jarI'm deploying a simple XML parsing servlet using the latest
2.5.0 xerces jars in it's lib directory.
This servlet runs fine on my local machine, but when I deploy it
to the production server, the JRE throws a java.lang.NoSuchMethodError
for the method
method parse(Ljava/io/InputStream;Lorg/xml/sax/helpers/DefaultHandler;)V not found
This method is definitely in the latest xerces jar, so I'm guessing
it's picking up an obsolete jar file somewhere before the current
jar in the classpath.
Unfortunately I have little control over the production server, so
can anyone suggest how I can force xerces to use the actual
latest library?
Thanks,
Sean
- 6
- menu drawn behind canvasHi,
I have a JFrame with a menu bar and inside the the frame a canvas. When I
click on a menu item
the menu is always (partly) drawn behind the canvas. How do you set the
options that will draw the menu(bar) to be visible ?
thanks
Johan
- 8
- Problem with Session Beans stateHi, I'm currently making a session bean, which will eventually act as
a Shopping Basket.
I have implemented the bean so that it just accepts a string (which
will eventually be an object reference), and the user can add and
remove strings.
Unfortunately, if I access the same bean from another machine and
create an instance of the session bean, they are shown the same
contents as from the other machine.
The session bean type is set to stateful (and I have tried stateless).
Can anyone point me in the direction of the problem please?
Cheers,
David
- 12
- ServerSocket & multiple clientsNeed help please.
I am trying to write a small client-server application that uses a
ServerSocket that allows connection of two clients via two ports (one on each
port, say 3000 & 4000).
I've tried different techniques, but always get the first client working but
the second client waiting until after the first client has ended (see code
snippet below).
How should I approach this (without the use of threads)?
(I am using the loopback address of "127.0.0.1" as both clients are on the
same PC)
private ServerSocket ss1;
private ServerSocket ss2;
private Socket socket1;
private Socket socket2;
try
{
ss1 = new ServerSocket(3000);
ss2 = new ServerSocket(4000);
}
and then
socket1 = ss1.accept();
socket2 = ss2.accept();
- 13
- Form doesn't submit onUnload in NetscapeDear Netscape/Javascript/Java gurus,
I am trying to submit a form onUnLoad when the user accidentally
closes the browser before clicking on a link to complete the
transaction.
On IE, this works fine.
But on Netscape or Mozzilla browsers, the form would simply not submit
when
the browser is closed.
here is the code.
<script language="JavaScript">
function CheckWindowClosed() {
document.MyForm.submit();
}
</script>
<body onLoad="FunctionHandler();" onUnload="CheckWindowClosed();">
Kindly let me know if there is any workaround or fix where I can get
this working on Netscape.
Thanks and Regards,
Yash
- 13
- Secret LaunchJoin now to make money
http://www.secretlaunch.com/?codelion
- 13
- Rollover button problemI'm building a site in Dreamweaver MX where I have a set of rollover
buttons. These buttons go dim when the mouse is over them. When clicked,
another image appears on a different part of the page (I built this using
the Set Nav Bar image function). This all works fine on my Mac, using my
browser safari and Internet Explorer. But on a PC using Internet Explorer
the rollovers dim but when clicked nothing happens. Does anybody know why?
I can paste the code if that helps anybody . I'm not too good at
understanding Java script code so let me know what bits might help
Thanks
Kate
- 14
- Sessionhandling with Apache AxisHello Group,
i 've already written a littlr webservice with Apache Axis.
My Service starts a thread to process some data. The Client may
Access the output via different functions.
Everything very fine.
But if i kick the Client and the Session times out after 30
minutes, the thread is still running... and running... and running...
I want to tell the Service to kick the Thread after a timeout,
maybe this should possible via a Session.
How can i find out if a Session is timed out?
Thanks for your help and a happy x-mas (ok ok, some days to early :-) )
Greetings,
Steffen
|
| Author |
Message |
Christophe Darville

|
Posted: 2004-7-19 21:57:00 |
Top |
java-programmer, HttpUrlConnection caching ip
Hello,
I got an ip caching problem when using HttpUrlConnection class.
When using the code :
URL url = new URL("http://a.domain");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
The VM seems to cache the ip address associated with the domain "a.domain".
If the ip associated with this domain change, the VM still connect to the
old ip. The only way to connect to the new ip, is to restart the VM.
I have tried
java.security.Security.setProperty("networkaddress.cache.ttl", "0");
but it does not work with HttpUrlConnection (it works fine with InetAddress
class for instance).
Any idea ?
Thank you,
Christophe
|
| |
|
| |
 |
Murray

|
Posted: 2004-7-19 22:08:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Christophe Darville" <email***@***.com> wrote in message
news:40fbd33f$0$1237$email***@***.com...
> Hello,
>
> I got an ip caching problem when using HttpUrlConnection class.
>
> When using the code :
>
> URL url = new URL("http://a.domain");
> HttpURLConnection connection = (HttpURLConnection) url.openConnection();
>
> The VM seems to cache the ip address associated with the domain
"a.domain".
> If the ip associated with this domain change, the VM still connect to the
> old ip. The only way to connect to the new ip, is to restart the VM.
>
> I have tried
> java.security.Security.setProperty("networkaddress.cache.ttl", "0");
> but it does not work with HttpUrlConnection (it works fine with
InetAddress
> class for instance).
>
> Any idea ?
>
> Thank you,
> Christophe
>
>
Which JDK are you using? If it's 1.3 then I think the property is
sun.net.inetaddr.ttl
Also try setting the property from the command line when starting the JVM.
It might be too late by the time you set it in your code if the
configuration is done statically (no idea of Sun's implementation ...)
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-19 22:13:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
Hi Murray,
I am using JDK 1.4.2
I have also tried the "sun.net.inetaddr.ttl" parameter without success.
What I fear, is that HttpUrlConnection does not use this parameter at all
because the parameter works fine when using the InetAddress class.
I will try passing the parameter when starting the VM
Thank you,
Christophe
"Murray" <email***@***.com> wrote in message
news:40fbd5ca$0$25461$email***@***.com...
>
> "Christophe Darville" <email***@***.com> wrote in message
> news:40fbd33f$0$1237$email***@***.com...
> > Hello,
> >
> > I got an ip caching problem when using HttpUrlConnection class.
> >
> > When using the code :
> >
> > URL url = new URL("http://a.domain");
> > HttpURLConnection connection = (HttpURLConnection) url.openConnection();
> >
> > The VM seems to cache the ip address associated with the domain
> "a.domain".
> > If the ip associated with this domain change, the VM still connect to
the
> > old ip. The only way to connect to the new ip, is to restart the VM.
> >
> > I have tried
> > java.security.Security.setProperty("networkaddress.cache.ttl", "0");
> > but it does not work with HttpUrlConnection (it works fine with
> InetAddress
> > class for instance).
> >
> > Any idea ?
> >
> > Thank you,
> > Christophe
> >
> >
>
> Which JDK are you using? If it's 1.3 then I think the property is
> sun.net.inetaddr.ttl
>
> Also try setting the property from the command line when starting the JVM.
> It might be too late by the time you set it in your code if the
> configuration is done statically (no idea of Sun's implementation ...)
>
>
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-19 22:23:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
Passing the parameter when starting JVM does not solve the problem :-(
"Christophe Darville" <email***@***.com> wrote in message
news:40fbd6ed$0$1249$email***@***.com...
> Hi Murray,
>
> I am using JDK 1.4.2
>
> I have also tried the "sun.net.inetaddr.ttl" parameter without success.
>
> What I fear, is that HttpUrlConnection does not use this parameter at all
> because the parameter works fine when using the InetAddress class.
>
> I will try passing the parameter when starting the VM
>
> Thank you,
> Christophe
>
>
> "Murray" <email***@***.com> wrote in message
> news:40fbd5ca$0$25461$email***@***.com...
> >
> > "Christophe Darville" <email***@***.com> wrote in message
> > news:40fbd33f$0$1237$email***@***.com...
> > > Hello,
> > >
> > > I got an ip caching problem when using HttpUrlConnection class.
> > >
> > > When using the code :
> > >
> > > URL url = new URL("http://a.domain");
> > > HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
> > >
> > > The VM seems to cache the ip address associated with the domain
> > "a.domain".
> > > If the ip associated with this domain change, the VM still connect to
> the
> > > old ip. The only way to connect to the new ip, is to restart the VM.
> > >
> > > I have tried
> > > java.security.Security.setProperty("networkaddress.cache.ttl", "0");
> > > but it does not work with HttpUrlConnection (it works fine with
> > InetAddress
> > > class for instance).
> > >
> > > Any idea ?
> > >
> > > Thank you,
> > > Christophe
> > >
> > >
> >
> > Which JDK are you using? If it's 1.3 then I think the property is
> > sun.net.inetaddr.ttl
> >
> > Also try setting the property from the command line when starting the
JVM.
> > It might be too late by the time you set it in your code if the
> > configuration is done statically (no idea of Sun's implementation ...)
> >
> >
>
>
|
| |
|
| |
 |
Murray

|
Posted: 2004-7-19 22:32:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Christophe Darville" <email***@***.com> wrote in message
news:40fbd94c$0$3983$email***@***.com...
> Passing the parameter when starting JVM does not solve the problem :-(
>
Bugger :(
|
| |
|
| |
 |
iksrazal

|
Posted: 2004-7-20 2:27:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Christophe Darville" <email***@***.com> wrote in message news:<40fbd33f$0$1237$email***@***.com>...
> Hello,
>
> I got an ip caching problem when using HttpUrlConnection class.
>
I don't know about your problem specifically, but I've generally had
much better luck with org.apache.commons.httpclient.HttpClient as a
drop in replacement for HttpUrlConnection .
HTH
iksrazal
|
| |
|
| |
 |
samhunt90

|
Posted: 2004-7-20 8:01:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Christophe Darville" <email***@***.com> wrote in message news:<40fbd33f$0$1237$email***@***.com>...
> Hello,
>
> I got an ip caching problem when using HttpUrlConnection class.
>
> When using the code :
>
> URL url = new URL("http://a.domain");
> HttpURLConnection connection = (HttpURLConnection) url.openConnection();
>
> The VM seems to cache the ip address associated with the domain "a.domain".
> If the ip associated with this domain change, the VM still connect to the
> old ip. The only way to connect to the new ip, is to restart the VM.
>
> I have tried
> java.security.Security.setProperty("networkaddress.cache.ttl", "0");
> but it does not work with HttpUrlConnection (it works fine with InetAddress
> class for instance).
>
> Any idea ?
>
> Thank you,
> Christophe
Christope,
There is a chance the is a DNS caching problem. When you look up the
IP address corresponding to a url, DNS looks inside it's local cache,
and if found DNS will use that cached IP address instead of going out
to the internet to look it up on a remote database. DNS records have
some kind of timeout paramter where they eventually expire. But
typically ip addresses for a static domain don't change rapidly, so it
could take a while.
On some windows systems, you can use "nslookup" to see what ip address
is beeing returned. I think it works on unix too. You could play
around with that, maybe clear the cache or set a timeout.
Good luck,
Sam90
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-20 16:57:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Sam" <email***@***.com> wrote in message
news:email***@***.com...
> "Christophe Darville" <email***@***.com> wrote in message
news:<40fbd33f$0$1237$email***@***.com>...
> > Hello,
> >
> > I got an ip caching problem when using HttpUrlConnection class.
> >
> > When using the code :
> >
> > URL url = new URL("http://a.domain");
> > HttpURLConnection connection = (HttpURLConnection) url.openConnection();
> >
> > The VM seems to cache the ip address associated with the domain
"a.domain".
> > If the ip associated with this domain change, the VM still connect to
the
> > old ip. The only way to connect to the new ip, is to restart the VM.
> >
> > I have tried
> > java.security.Security.setProperty("networkaddress.cache.ttl", "0");
> > but it does not work with HttpUrlConnection (it works fine with
InetAddress
> > class for instance).
> >
> > Any idea ?
> >
> > Thank you,
> > Christophe
>
> Christope,
>
> There is a chance the is a DNS caching problem. When you look up the
> IP address corresponding to a url, DNS looks inside it's local cache,
> and if found DNS will use that cached IP address instead of going out
> to the internet to look it up on a remote database. DNS records have
> some kind of timeout paramter where they eventually expire. But
> typically ip addresses for a static domain don't change rapidly, so it
> could take a while.
>
> On some windows systems, you can use "nslookup" to see what ip address
> is beeing returned. I think it works on unix too. You could play
> around with that, maybe clear the cache or set a timeout.
>
> Good luck,
> Sam90
Sam,
Unfortunately, this is not DNS caching problem. When I ping (on the same
machine where my java application is running) the domain, the new ip address
is exact (after a few seconds, of course) but it is never exact in the java
application. The only way to use the new ip, is to restart the java
application.
So it is a DNS caching problem, but at the java level
Christophe
|
| |
|
| |
 |
samhunt90

|
Posted: 2004-7-20 22:23:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Christophe Darville" <email***@***.com> wrote in message news:<40fcde79$0$6400$email***@***.com>...
> "Sam" <email***@***.com> wrote in message
> news:email***@***.com...
> > "Christophe Darville" <email***@***.com> wrote in message
> news:<40fbd33f$0$1237$email***@***.com>...
> > > Hello,
> > >
> > > I got an ip caching problem when using HttpUrlConnection class.
> > >
> > > When using the code :
> > >
> > > URL url = new URL("http://a.domain");
> > > HttpURLConnection connection = (HttpURLConnection) url.openConnection();
> > >
> > > The VM seems to cache the ip address associated with the domain
> "a.domain".
> > > If the ip associated with this domain change, the VM still connect to
> the
> > > old ip. The only way to connect to the new ip, is to restart the VM.
> > >
> > > I have tried
> > > java.security.Security.setProperty("networkaddress.cache.ttl", "0");
> > > but it does not work with HttpUrlConnection (it works fine with
> InetAddress
> > > class for instance).
> > >
> > > Any idea ?
> > >
> > > Thank you,
> > > Christophe
> >
> > Christope,
> >
> > There is a chance the is a DNS caching problem. When you look up the
> > IP address corresponding to a url, DNS looks inside it's local cache,
> > and if found DNS will use that cached IP address instead of going out
> > to the internet to look it up on a remote database. DNS records have
> > some kind of timeout paramter where they eventually expire. But
> > typically ip addresses for a static domain don't change rapidly, so it
> > could take a while.
> >
> > On some windows systems, you can use "nslookup" to see what ip address
> > is beeing returned. I think it works on unix too. You could play
> > around with that, maybe clear the cache or set a timeout.
> >
> > Good luck,
> > Sam90
>
> Sam,
>
> Unfortunately, this is not DNS caching problem. When I ping (on the same
> machine where my java application is running) the domain, the new ip address
> is exact (after a few seconds, of course) but it is never exact in the java
> application. The only way to use the new ip, is to restart the java
> application.
> So it is a DNS caching problem, but at the java level
>
> Christophe
Uhf. I had high hopes. It's the jvm that's caching it, not the URL nor
the connection class - in other words, you are running this code
before and after the ip address change?
>>URL url = new URL("http://a.domain");
>>HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
And this code reflects the change?
>>String dottedQuad = InetAddress.getByName( "mindprod.com"
).getHostAddress();
This fact that this code even exists:
>> java.security.Security.setProperty("networkaddress.cache.ttl",
"0");
indicates that Java security is caching DNS address.
The more I look at it, the more it appears that for whatever reason,
the URL or HTTPURLConnection is ignoring the java security setting and
using the default, which is to keep the same address it found
"forever". This is presumably some static behavior of the command, and
could be a bug. You could probably find the source code and isolate
the problem if you were motivated, but otherwise you may need to find
an alternative the class in question. Sorry I couldn't figure it out.
Below is a relevant post I found on usenet which you've probably seen,
but I'm filing for prosperity:
InetAddress Caching
The InetAddress class has a cache to store successful as well as
unsuccessful host name resolutions. The positive caching is there to
guard
against DNS spoofing attacks; while the negative caching is used to
improve
performance.
By default, the result of positive host name resolutions are cached
forever, because there is no general rule to decide when it is safe to
remove cache entries. The result of unsuccessful host name resolution
is
cached for a very short period of time (10 seconds) to improve
performance.
Under certain circumstances where it can be determined that DNS
spoofing
attacks are not possible, a Java security property can be set to a
different Time-to-live (TTL) value for positive caching. Likewise, a
system
admin can configure a different negative caching TTL value when
needed.
Two Java security properties control the TTL values used for positive
and
negative host name resolution caching:
* networkaddress.cache.ttl (default: -1)
Indicates the caching policy for successful name lookups from the name
service. The value is specified as as integer to indicate the number
of
seconds to cache the successful lookup.
A value of -1 indicates "cache forever".
* networkaddress.cache.negative.ttl (default: 10)
Indicates the caching policy for un-successful name lookups from the
name s
ervice. The value is specified as as integer to indicate the number of
seconds to cache the failure for un-successful lookups.
A value of 0 indicates "never cache". A value of -1 indicates "cache
forever".
Regards,
Sam90
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-21 2:15:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Sam" <email***@***.com> wrote in message
news:email***@***.com...
> "Christophe Darville" <email***@***.com> wrote in message
news:<40fcde79$0$6400$email***@***.com>...
> > "Sam" <email***@***.com> wrote in message
> > news:email***@***.com...
> > > "Christophe Darville" <email***@***.com> wrote in message
> > news:<40fbd33f$0$1237$email***@***.com>...
> > > > Hello,
> > > >
> > > > I got an ip caching problem when using HttpUrlConnection class.
> > > >
> > > > When using the code :
> > > >
> > > > URL url = new URL("http://a.domain");
> > > > HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
> > > >
> > > > The VM seems to cache the ip address associated with the domain
> > "a.domain".
> > > > If the ip associated with this domain change, the VM still connect
to
> > the
> > > > old ip. The only way to connect to the new ip, is to restart the VM.
> > > >
> > > > I have tried
> > > > java.security.Security.setProperty("networkaddress.cache.ttl", "0");
> > > > but it does not work with HttpUrlConnection (it works fine with
> > InetAddress
> > > > class for instance).
> > > >
> > > > Any idea ?
> > > >
> > > > Thank you,
> > > > Christophe
> > >
> > > Christope,
> > >
> > > There is a chance the is a DNS caching problem. When you look up the
> > > IP address corresponding to a url, DNS looks inside it's local cache,
> > > and if found DNS will use that cached IP address instead of going out
> > > to the internet to look it up on a remote database. DNS records have
> > > some kind of timeout paramter where they eventually expire. But
> > > typically ip addresses for a static domain don't change rapidly, so it
> > > could take a while.
> > >
> > > On some windows systems, you can use "nslookup" to see what ip address
> > > is beeing returned. I think it works on unix too. You could play
> > > around with that, maybe clear the cache or set a timeout.
> > >
> > > Good luck,
> > > Sam90
> >
> > Sam,
> >
> > Unfortunately, this is not DNS caching problem. When I ping (on the same
> > machine where my java application is running) the domain, the new ip
address
> > is exact (after a few seconds, of course) but it is never exact in the
java
> > application. The only way to use the new ip, is to restart the java
> > application.
> > So it is a DNS caching problem, but at the java level
> >
> > Christophe
>
> Uhf. I had high hopes. It's the jvm that's caching it, not the URL nor
> the connection class - in other words, you are running this code
> before and after the ip address change?
>
> >>URL url = new URL("http://a.domain");
> >>HttpURLConnection connection = (HttpURLConnection)
> url.openConnection();
>
> And this code reflects the change?
>
> >>String dottedQuad = InetAddress.getByName( "mindprod.com"
> ).getHostAddress();
>
> This fact that this code even exists:
>
> >> java.security.Security.setProperty("networkaddress.cache.ttl",
> "0");
>
> indicates that Java security is caching DNS address.
>
> The more I look at it, the more it appears that for whatever reason,
> the URL or HTTPURLConnection is ignoring the java security setting and
> using the default, which is to keep the same address it found
> "forever". This is presumably some static behavior of the command, and
> could be a bug. You could probably find the source code and isolate
> the problem if you were motivated, but otherwise you may need to find
> an alternative the class in question. Sorry I couldn't figure it out.
>
> Below is a relevant post I found on usenet which you've probably seen,
> but I'm filing for prosperity:
>
> InetAddress Caching
>
> The InetAddress class has a cache to store successful as well as
> unsuccessful host name resolutions. The positive caching is there to
> guard
> against DNS spoofing attacks; while the negative caching is used to
> improve
> performance.
> By default, the result of positive host name resolutions are cached
> forever, because there is no general rule to decide when it is safe to
> remove cache entries. The result of unsuccessful host name resolution
> is
> cached for a very short period of time (10 seconds) to improve
> performance.
>
> Under certain circumstances where it can be determined that DNS
> spoofing
> attacks are not possible, a Java security property can be set to a
> different Time-to-live (TTL) value for positive caching. Likewise, a
> system
> admin can configure a different negative caching TTL value when
> needed.
>
> Two Java security properties control the TTL values used for positive
> and
> negative host name resolution caching:
>
> * networkaddress.cache.ttl (default: -1)
> Indicates the caching policy for successful name lookups from the name
> service. The value is specified as as integer to indicate the number
> of
> seconds to cache the successful lookup.
> A value of -1 indicates "cache forever".
>
> * networkaddress.cache.negative.ttl (default: 10)
> Indicates the caching policy for un-successful name lookups from the
> name s
> ervice. The value is specified as as integer to indicate the number of
> seconds to cache the failure for un-successful lookups.
> A value of 0 indicates "never cache". A value of -1 indicates "cache
> forever".
>
>
> Regards,
> Sam90
Sam,
Thank you very much for all the time you spent on my problem.
I think I have red somewhere that InetAddress is keeping a static variable
with ip caching (not so sure now that I have red a lot of things about that
subject) and that this static variable is managed accordingly the
networkaddress.cache.ttl parameter. At least, caching (or no caching)
facility is working fine for the InetAddress class.
What I suspect, is that the URL or UrlConnection or HttpURLConnection or ...
is using the same mechanism but does not care about the
networkaddress.cache.ttl property.
It's just, of course, a suposition.
If only I was able to unload a class, I could try to unload URL for instance
just to see if I am right.
Do you know a way to "reset" all static attributes for a certain class ?
Anyway, this is really a big problem for me and I have no idea how to tackle
it. I hope I will find a solution ....
Best Regards,
Christophe
|
| |
|
| |
 |
Roedy Green

|
Posted: 2004-7-21 6:05:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
On Tue, 20 Jul 2004 20:15:02 +0200, "Christophe Darville"
<email***@***.com> wrote or quoted :
>Anyway, this is really a big problem for me and I have no idea how to tackle
>it. I hope I will find a solution ....
you may need to work with IPs inside, and use some separate mechanism
to warn your app when they have to change.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
|
| |
|
| |
 |
marcus

|
Posted: 2004-7-21 8:20:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
didn't you say InetAddress was working? just use URLConnection(new
InetAddress("dot.com").getHostAddress()) or some variation. If you can
get the known good IP address your problem is not insurmountable.
Roedy Green wrote:
> On Tue, 20 Jul 2004 20:15:02 +0200, "Christophe Darville"
> <email***@***.com> wrote or quoted :
>
>
>>Anyway, this is really a big problem for me and I have no idea how to tackle
>>it. I hope I will find a solution ....
>
>
> you may need to work with IPs inside, and use some separate mechanism
> to warn your app when they have to change.
>
|
| |
|
| |
 |
samhunt90

|
Posted: 2004-7-21 8:48:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Christophe Darville" <email***@***.com> wrote in message
> Sam,
>
> Thank you very much for all the time you spent on my problem.
>
> I think I have red somewhere that InetAddress is keeping a static variable
> with ip caching (not so sure now that I have red a lot of things about that
> subject) and that this static variable is managed accordingly the
> networkaddress.cache.ttl parameter. At least, caching (or no caching)
> facility is working fine for the InetAddress class.
> What I suspect, is that the URL or UrlConnection or HttpURLConnection or ...
> is using the same mechanism but does not care about the
> networkaddress.cache.ttl property.
> It's just, of course, a suposition.
> If only I was able to unload a class, I could try to unload URL for instance
> just to see if I am right.
> Do you know a way to "reset" all static attributes for a certain class ?
>
> Anyway, this is really a big problem for me and I have no idea how to tackle
> it. I hope I will find a solution ....
>
> Best Regards,
> Christophe
Christope,
It may be the URL class that's caching, because that's where you
specify the name, so it must do the lookup.
You still have some options. What happens if you give the IP address
instead of the domain name? Does it do the lookup correctly? If so,
you're problem's solved because you could use InetAddress to
pre-process the domain name and give the correct IP address to the URL
constructor.
If not, I would poke through the source code and the API's for the
classes. You can do this by expanding the java source zip file that
comes with the java download from sun. One possibility is to some how
disable the security manager for the duration of the lookup (ugly).
Another thing might be to subclass and override something. You could
also try disconnect and close methods that are specified in the source
code and API's. There is a URI class that might help.
Good luck,
Sam90
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-21 16:44:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Sam" <email***@***.com> wrote in message
news:email***@***.com...
> "Christophe Darville" <email***@***.com> wrote in message
> > Sam,
> >
> > Thank you very much for all the time you spent on my problem.
> >
> > I think I have red somewhere that InetAddress is keeping a static
variable
> > with ip caching (not so sure now that I have red a lot of things about
that
> > subject) and that this static variable is managed accordingly the
> > networkaddress.cache.ttl parameter. At least, caching (or no caching)
> > facility is working fine for the InetAddress class.
> > What I suspect, is that the URL or UrlConnection or HttpURLConnection or
...
> > is using the same mechanism but does not care about the
> > networkaddress.cache.ttl property.
> > It's just, of course, a suposition.
> > If only I was able to unload a class, I could try to unload URL for
instance
> > just to see if I am right.
> > Do you know a way to "reset" all static attributes for a certain class ?
> >
> > Anyway, this is really a big problem for me and I have no idea how to
tackle
> > it. I hope I will find a solution ....
> >
> > Best Regards,
> > Christophe
>
> Christope,
>
> It may be the URL class that's caching, because that's where you
> specify the name, so it must do the lookup.
>
> You still have some options. What happens if you give the IP address
> instead of the domain name? Does it do the lookup correctly? If so,
> you're problem's solved because you could use InetAddress to
> pre-process the domain name and give the correct IP address to the URL
> constructor.
I have not tried this but I see a problem with HTTP 1.1 specs. Just because
a single ip address can be mapped to more than one domain (virtual hosting),
I cannot afford to transform a url like http://a.certain.domain/index.html
into http://1.2.3.4/index.html. I have no guarantee that the index.html page
content will be the one of the "a.certain.domain" site and not the one of
another domain hosted on the same machine :-(
>
> If not, I would poke through the source code and the API's for the
> classes. You can do this by expanding the java source zip file that
> comes with the java download from sun.
I do not see this zip. Where can I find it ? Not in the standard sdk
download ?
> One possibility is to some how
> disable the security manager for the duration of the lookup (ugly).
> Another thing might be to subclass and override something. You could
> also try disconnect and close methods that are specified in the source
> code and API's. There is a URI class that might help.
Ok, I will investigate those 2 options
>
> Good luck,
> Sam90
A big Thank you,
Christophe
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-21 16:45:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"marcus" <email***@***.com> wrote in message
news:email***@***.com...
> didn't you say InetAddress was working? just use URLConnection(new
> InetAddress("dot.com").getHostAddress()) or some variation. If you can
> get the known good IP address your problem is not insurmountable.
>
> Roedy Green wrote:
> > On Tue, 20 Jul 2004 20:15:02 +0200, "Christophe Darville"
> > <email***@***.com> wrote or quoted :
> >
> >
> >>Anyway, this is really a big problem for me and I have no idea how to
tackle
> >>it. I hope I will find a solution ....
> >
> >
> > you may need to work with IPs inside, and use some separate mechanism
> > to warn your app when they have to change.
> >
>
Hi Marcus,
Unfortunately, I do not think replacing domain name by ip in the URL class
can help.
See my answer to Sam about that proposition.
Thank you,
Christophe
|
| |
|
| |
 |
marcus

|
Posted: 2004-7-22 12:24:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
Now you are being absurd. I assumed when you knew that the DNS ttl was
extremely short you were affiliated with the server folks -- bad
assumption on my part.
What makes you think your situation is so unique it has never occurred
in the history of the internet? DNS caches. Hell, name servers cache
sometimes for inappropriate lengths of time (i used to do tech support
for @Home cable internet -- I know!!), completely ignoring the DNS
record in question. Winsock itself caches. Why is your cacheing
problem the end of the world?
Either get used to the fact that DNS has caches in about a dozen places
and not everywhere on the internet is accessable from everywhere else at
any given time, or explain why your situation os truly different from
what every one else deals with every day.
-- clh
Christophe Darville wrote:
> "marcus" <email***@***.com> wrote in message
> news:email***@***.com...
>
>>didn't you say InetAddress was working? just use URLConnection(new
>>InetAddress("dot.com").getHostAddress()) or some variation. If you can
>>get the known good IP address your problem is not insurmountable.
>>
>>Roedy Green wrote:
>>
>>>On Tue, 20 Jul 2004 20:15:02 +0200, "Christophe Darville"
>>><email***@***.com> wrote or quoted :
>>>
>>>
>>>
>>>>Anyway, this is really a big problem for me and I have no idea how to
>>>
> tackle
>
>>>>it. I hope I will find a solution ....
>>>
>>>
>>>you may need to work with IPs inside, and use some separate mechanism
>>>to warn your app when they have to change.
>>>
>>
> Hi Marcus,
>
> Unfortunately, I do not think replacing domain name by ip in the URL class
> can help.
>
> See my answer to Sam about that proposition.
>
> Thank you,
> Christophe
>
>
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-22 14:48:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"marcus" <email***@***.com> wrote in message
news:email***@***.com...
> Now you are being absurd. I assumed when you knew that the DNS ttl was
> extremely short you were affiliated with the server folks -- bad
> assumption on my part.
>
> What makes you think your situation is so unique it has never occurred
> in the history of the internet? DNS caches. Hell, name servers cache
> sometimes for inappropriate lengths of time (i used to do tech support
> for @Home cable internet -- I know!!), completely ignoring the DNS
> record in question. Winsock itself caches. Why is your cacheing
> problem the end of the world?
>
> Either get used to the fact that DNS has caches in about a dozen places
> and not everywhere on the internet is accessable from everywhere else at
> any given time, or explain why your situation os truly different from
> what every one else deals with every day.
>
> -- clh
I am sorry to be absurd but my problem is not ! And I never said I thought
it was unique in the history of the internet.
The reason is quite simple, I have java applications running nonstop (by non
stop, I mean NON STOP - at least until they crash). Those applications are
using httpUrlConnection to access websites. So, the fact that JVM is caching
DNS until restarting it is a big problem for me, but I am really conscious
it will not prevent the world from running.
My point of view is that a forum is there to submit problem in order to get
answer or turn around or to be sure the problem is not solvable!
Regards,
Christophe
>
> Christophe Darville wrote:
> > "marcus" <email***@***.com> wrote in message
> > news:email***@***.com...
> >
> >>didn't you say InetAddress was working? just use URLConnection(new
> >>InetAddress("dot.com").getHostAddress()) or some variation. If you can
> >>get the known good IP address your problem is not insurmountable.
> >>
> >>Roedy Green wrote:
> >>
> >>>On Tue, 20 Jul 2004 20:15:02 +0200, "Christophe Darville"
> >>><email***@***.com> wrote or quoted :
> >>>
> >>>
> >>>
> >>>>Anyway, this is really a big problem for me and I have no idea how to
> >>>
> > tackle
> >
> >>>>it. I hope I will find a solution ....
> >>>
> >>>
> >>>you may need to work with IPs inside, and use some separate mechanism
> >>>to warn your app when they have to change.
> >>>
> >>
> > Hi Marcus,
> >
> > Unfortunately, I do not think replacing domain name by ip in the URL
class
> > can help.
> >
> > See my answer to Sam about that proposition.
> >
> > Thank you,
> > Christophe
> >
> >
>
|
| |
|
| |
 |
marcus

|
Posted: 2004-7-22 16:45:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
Ok I think I see --
You are saying you might have a JVM working for weeks or months, and the
standard API seems to be cacheing the DNS indefinitely (which if it is
true seems to be an outrageously huge bug), and IP addressing doesn't
work because of virtual servers.
I can see a methodology of comparing the IP the JVM is using against an
IP provided by an external service, either a shell command or on a
machine port, and exiting and restarting the JVM if they mismatch -- ugly!
Consider reducing your connection to a simple socket. Is there anything
about URLConnection you cannot readilly emulate with a socket connected
on port 80? Does a socket have the same caching issues?
-- clh
Christophe Darville wrote:
> "marcus" <email***@***.com> wrote in message
> news:email***@***.com...
>
>>Now you are being absurd. I assumed when you knew that the DNS ttl was
>>extremely short you were affiliated with the server folks -- bad
>>assumption on my part.
>>
>>What makes you think your situation is so unique it has never occurred
>>in the history of the internet? DNS caches. Hell, name servers cache
>>sometimes for inappropriate lengths of time (i used to do tech support
>>for @Home cable internet -- I know!!), completely ignoring the DNS
>>record in question. Winsock itself caches. Why is your cacheing
>>problem the end of the world?
>>
>>Either get used to the fact that DNS has caches in about a dozen places
>>and not everywhere on the internet is accessable from everywhere else at
>>any given time, or explain why your situation os truly different from
>>what every one else deals with every day.
>>
>>-- clh
>
>
>
> I am sorry to be absurd but my problem is not ! And I never said I thought
> it was unique in the history of the internet.
>
> The reason is quite simple, I have java applications running nonstop (by non
> stop, I mean NON STOP - at least until they crash). Those applications are
> using httpUrlConnection to access websites. So, the fact that JVM is caching
> DNS until restarting it is a big problem for me, but I am really conscious
> it will not prevent the world from running.
>
> My point of view is that a forum is there to submit problem in order to get
> answer or turn around or to be sure the problem is not solvable!
>
> Regards,
> Christophe
>
>
>
>
>>Christophe Darville wrote:
>>
>>>"marcus" <email***@***.com> wrote in message
>>>news:email***@***.com...
>>>
>>>
>>>>didn't you say InetAddress was working? just use URLConnection(new
>>>>InetAddress("dot.com").getHostAddress()) or some variation. If you can
>>>>get the known good IP address your problem is not insurmountable.
>>>>
>>>>Roedy Green wrote:
>>>>
>>>>
>>>>>On Tue, 20 Jul 2004 20:15:02 +0200, "Christophe Darville"
>>>>><email***@***.com> wrote or quoted :
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Anyway, this is really a big problem for me and I have no idea how to
>>>>>
>>>tackle
>>>
>>>
>>>>>>it. I hope I will find a solution ....
>>>>>
>>>>>
>>>>>you may need to work with IPs inside, and use some separate mechanism
>>>>>to warn your app when they have to change.
>>>>>
>>>>
>>>Hi Marcus,
>>>
>>>Unfortunately, I do not think replacing domain name by ip in the URL
>>
> class
>
>>>can help.
>>>
>>>See my answer to Sam about that proposition.
>>>
>>>Thank you,
>>>Christophe
>>>
>>>
>>
>
>
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-22 17:39:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"marcus" <email***@***.com> wrote in message
news:email***@***.com...
> Ok I think I see --
> You are saying you might have a JVM working for weeks or months, and the
> standard API seems to be cacheing the DNS indefinitely (which if it is
> true seems to be an outrageously huge bug), and IP addressing doesn't
> work because of virtual servers.
exact ! (just adding that it is only in the case of HttpUrlConnection, so
the standard api works fine in some circumstances like InetAddress for
instance).
>
> I can see a methodology of comparing the IP the JVM is using against an
> IP provided by an external service, either a shell command or on a
> machine port, and exiting and restarting the JVM if they mismatch -- ugly!
>
> Consider reducing your connection to a simple socket. Is there anything
> about URLConnection you cannot readilly emulate with a socket connected
> on port 80? Does a socket have the same caching issues?
Socket will work I guess (InetAddress can be configurated to avoid caching
and I can use InetAddress in cunjunction with socket). But, I will need to
understand in depth HTTP protocol and manage myself what is really done by
HttpUrlConnection (redirect management for instance,...)
Any way, I think I will try the HttpClient from Apache to see if it manage
better caching.
Thank you,
Christophe
>
> -- clh
>
>
> Christophe Darville wrote:
> > "marcus" <email***@***.com> wrote in message
> > news:email***@***.com...
> >
> >>Now you are being absurd. I assumed when you knew that the DNS ttl was
> >>extremely short you were affiliated with the server folks -- bad
> >>assumption on my part.
> >>
> >>What makes you think your situation is so unique it has never occurred
> >>in the history of the internet? DNS caches. Hell, name servers cache
> >>sometimes for inappropriate lengths of time (i used to do tech support
> >>for @Home cable internet -- I know!!), completely ignoring the DNS
> >>record in question. Winsock itself caches. Why is your cacheing
> >>problem the end of the world?
> >>
> >>Either get used to the fact that DNS has caches in about a dozen places
> >>and not everywhere on the internet is accessable from everywhere else at
> >>any given time, or explain why your situation os truly different from
> >>what every one else deals with every day.
> >>
> >>-- clh
> >
> >
> >
> > I am sorry to be absurd but my problem is not ! And I never said I
thought
> > it was unique in the history of the internet.
> >
> > The reason is quite simple, I have java applications running nonstop (by
non
> > stop, I mean NON STOP - at least until they crash). Those applications
are
> > using httpUrlConnection to access websites. So, the fact that JVM is
caching
> > DNS until restarting it is a big problem for me, but I am really
conscious
> > it will not prevent the world from running.
> >
> > My point of view is that a forum is there to submit problem in order to
get
> > answer or turn around or to be sure the problem is not solvable!
> >
> > Regards,
> > Christophe
> >
> >
> >
> >
> >>Christophe Darville wrote:
> >>
> >>>"marcus" <email***@***.com> wrote in message
> >>>news:email***@***.com...
> >>>
> >>>
> >>>>didn't you say InetAddress was working? just use URLConnection(new
> >>>>InetAddress("dot.com").getHostAddress()) or some variation. If you
can
> >>>>get the known good IP address your problem is not insurmountable.
> >>>>
> >>>>Roedy Green wrote:
> >>>>
> >>>>
> >>>>>On Tue, 20 Jul 2004 20:15:02 +0200, "Christophe Darville"
> >>>>><email***@***.com> wrote or quoted :
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>Anyway, this is really a big problem for me and I have no idea how
to
> >>>>>
> >>>tackle
> >>>
> >>>
> >>>>>>it. I hope I will find a solution ....
> >>>>>
> >>>>>
> >>>>>you may need to work with IPs inside, and use some separate mechanism
> >>>>>to warn your app when they have to change.
> >>>>>
> >>>>
> >>>Hi Marcus,
> >>>
> >>>Unfortunately, I do not think replacing domain name by ip in the URL
> >>
> > class
> >
> >>>can help.
> >>>
> >>>See my answer to Sam about that proposition.
> >>>
> >>>Thank you,
> >>>Christophe
> >>>
> >>>
> >>
> >
> >
>
|
| |
|
| |
 |
Christophe Darville

|
Posted: 2004-7-22 22:57:00 |
Top |
java-programmer >> HttpUrlConnection caching ip
"Daniel Hagen" <email***@***.com> wrote in message
news:cdo1qi$nu4$01$email***@***.com...
> Christophe Darville wrote:
> > Sam,
> >
> > Unfortunately, this is not DNS caching problem. When I ping (on the same
> > machine where my java application is running) the domain, the new ip
address
> > is exact (after a few seconds, of course) but it is never exact in the
java
> > application. The only way to use the new ip, is to restart the java
> > application.
> > So it is a DNS caching problem, but at the java level
> >
> > Christophe
>
> Just a thought (not considered very carefully, not tested and a very
> ugly workaround):
>
> Couldn't you use the API of your underlying OS via JNI to get the IP and
> set the HTTP Host Header "manually" for the URLConnection?
>
> Something like:
>
> String formattedIp = someIpFormatMethod(
> someNativeGetHostByNameMethod("a.domain") );
>
> URL url = new URL("http://" + formattedIp);
> HttpURLConnection connection = (HttpURLConnection) url.openConnection();
> connection.setRequestProperty( "Host", "a.domain");
>
> [...]
>
> Daniel
Hi Daniel,
Your workaround works fine !
The connection.setRequestProperty("Host","...") command was the piece of
puzzle that was missing to me to solve the virtual hosting problem !
Thank you very much
Christophe
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Packing Resource-Based App Into a .JARI have an application which uses outside data files. That is, it has
lines of code like this:
DataReader.loadFile("data/MyFile.dat");
Right now the app is just a bunch of .class files and I start it on
the command line from the appropriate directory to ensure that the
data files can be found.
But I want to package the app as a .jar (a .jar which includes the
data files) and be able to run the .jar from any directory. That is,
when it's running, java should search for the data files relative to
the .jar root, rather than relative to the root where the process was
started.
How can I do this?
Thanks,
cpp
- 2
- security-roles: application.xml vs web.xmlHi,
does anybody know how a webmodule behaves when It is assemble in an ear
containing the web module and I include security-roles in both the
application.xml and web.xml? I have been browsing both the j2ee and servlet
specs, but I haven't found any description of mandated behaviour. I have
tested a little with sun one appserver7. This appserver seems to ignore the
security-roles defined in the web.xml. What's more, don't mentioning
security-roles in the application.xml and only use the web.xml for mapping
security-roles breaks the login process.
Does all this mean that security-roles in the web.xml file can only be used
for standalone web applications and not for web modules who are part of an
ear?
Cheers
Jan
- 3
- Singleton QuestionOn 1 Jul 2004 05:10:57 -0700, email***@***.com (Dave Monroe)
wrote or quoted :
>What's GoF?
see http://mindprod.com/jgloss/gof.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
- 4
- read gps bluettoth on applet pda - javacommHi all,
I'm a student..
I wrote an applet for PC that reads GPS data from serial port (using
javacomm)....
I would like to have the same applet on my pda, an IPAQ h1940 with bluetooth
gps receiver ....
I'm using javacomm and driver for pda found on www.teilo.net , I followed
the steps of the site, but it doesn't work... :-(
any questions:
- where have I to put javax.comm.properties, CESerial.jar and comm.jar ???
in which directory?
- how can I add the directory containing the javax.comm.properties, and the
paths to both jar files to my classpath? modifying the registry? which key?
(I searched in the registry but I didn't find none of java, path, classpath
etc...)
- if I want to read bluettoth data, I have to read a virtual serial port
(COM8?), right?
thanks all!
gp
- 5
- translate fitsG0ldmark Industries, Inc ( G D K I )
THIS ST()CK IS E><TREMELY U_NDERVA_LUED
Huge Advert|sing Campaign this week!
Breakout Forecast for July, 2006
Cu_rrent Price: $7.02 (5 days ago was $5)
Sh0rt Term Price Target: $12.00
Rec0mmendati0n: Str0ng Buy
RECENT H0T NEWS released MUST READ ACT NOW
LOS ANGELES & VANCOUVER, British Columbia---(July 5, 2006)
Goldmark Industries, Inc. ( G D K I - News) is excited to announce
that the Company is embarking into a new business direction. The
Company is making an aggressive move into the multi-billion-dollar
Urban Entertainment industry. The Hip-Hop Entertainment industry
generates several billion dollars per year in product sales with
an estimated consumer-based purchasing power well into the hundreds
of billions of dollars and topping over one trillion worldwide.
About Goldmark Industries, Inc ( G D K I ):
Goldmark Industries is preparing to stand at the forefront of
the Hip Hop consumer market, offering a wide range of urban
entertainment services in Music, Feature Films, Television,
Home Video/DVD and Major Events
Compaq Diag. viewing SCSI
fast spelling checks
sda named numbering
FFSYes. include: UDFCDROM NFS
refer
typically
Business Desktop Education
Lite. Winner:
thisswap via vnode
intend soit
extracted multiuser went planned
youwill gathered istime asa
Home Hobby
average meeting passed. realtime:
code Select extended
toavoid incurring working
prepared restoring
/var/swap thatisnumbering figure going /u.
macppc zaurus andcats
Mrpm: qWrite
drop frames
removed code.
wdb thekernel
thefile. creating /var/swap thatis
offset
mountyour above.You procedure plugging
modifying it: wd
feed needed listed above:
probably outside unable fetch
configure
work. clock proven most
shareware
Can access
newone theblocks
unknown j: aswell curious
length.RM missing
BIOSs abilityto
submit
buggy chipsets
Contents. Using OpenBSDs
WatchdogwdEnter Command Show reinitGraph: Creates
gathered istime asa /dev/wdm
numbering figure going
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 6
- String concatenation versus StringBufferCan someone deny or confirm that the latest sdks convert code like
"abc" + "def" + "ghi"
into the appropiate StringBuffer code
new StringBuffer( "abc" ).append( "def" ).append( "ghi" )
automatically? Or is this some dream I had?
Thanks!
- 7
- 8
- Is eclipse broken?
--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
I'v got a 5.1 RELEASE box. plenty of disk space and memory. Recently
rebuildt from a complete cvsup (cvsup, make buildworld, make installworld,
pkgdb, portupgrade)
=3D=3D UNAME =3D=3D
berkeley% uname -a
FreeBSD berkeley.mooseriver.com 5.1-RELEASE-p11 FreeBSD 5.1-RELEASE-p11 #0:=
Sat Dec 13 01:17:51 PST 2003 email***@***.com:/usr/obj/usr=
/src/sys/BERKELEY i386
berkeley%=20
=3D=3D MAKEFILE =3D=3D
New ports collection makefile for: eclipse
# Date created: March 7, 2003
#
# $FreeBSD: ports/java/eclipse/Makefile,v 1.15 2003/12/04 10:26:10 olgeni E=
xp $
#
PORTNAME=3D eclipse
PORTVERSION=3D 2.1.2
so I do the following :
cd /usr/ports/java/eclipse
make install clean
and I get :
<bunch of comple messages> then=20
=3D=3D=3D> Linking eclipse.
/bin/mkdir -p plugins/platform-launcher/bin/freebsd/gtk
/usr/local/bin/ccache g++ -o plugins/platform-launcher/bin/freebsd/gtk/ecli=
pse plugins/platform-launcher/library/gtk/../eclipse.o plugins/platform-lau=
ncher/library/gtk/../eclipseUtil.o plugins/platform-launcher/library/gtk/ec=
lipseGtk.o `pkg-config --libs gtk+-2.0`
/usr/bin/ld: warning: libatk-1.0.so.200, needed by /usr/X11R6/lib/libgtk-x1=
1-2.0.so, may conflict with libatk-1.0.so.400
=3D=3D=3D> Compiling Java sources.
ant -Dos=3Dfreebsd -Dws=3Dgtk -f build.xml compile
/usr/libexec/ld-elf.so.1: /usr/lib/libm.so.2: Undefined symbol "__fpclassif=
yd"
*** Error code 1
Stop in /usr/ports/java/eclipse/work.
*** Error code 1
is anyone else getting this?
Josef
--=20
Josef Grosch | Another day closer to a | FreeBSD 5.1
email***@***.com | Micro$oft free world | Berkeley, Ca.
--xHFwDpU9dbj6ez1V
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
iD8DBQE/2ufUy8prLS1GYSERAvxvAKCYaR1F5IqkE8fzEx5uqdP79BhLtQCg6e8Q
b9/KxeK0nzfbwfFL0Ptwo+o=
=M5R6
-----END PGP SIGNATURE-----
--xHFwDpU9dbj6ez1V--
- 9
- java6 does it address default focus on a modal formIts always been near impossible to dynamically set a field with the
default focus when a form (perhaps previously instantiated) is
setVisible - if the form is a modal dialog.
Does anyone know if Java 6 addresses this?
- 10
- Bug in IE with KB896727Recently we installed the MS05-038 as part of Windows Update. After this we
found out that our Code behind HTML application created in VJ++ is not
loading properly in IE 6 browser. We chekced all the Security settings and
they seem to work fine.
If we uninstall the Hotfix update ( KB896727 ) the application again loads
properly. Is there any work around for this issue. This is very critical.
Thanx
- 11
- View large file
I need to view a large file. If I use class JTextArea will it load
whole file into RAM or load one in portions?
I have read I must use ZoneView for this purpose. How can I use it?
Thanks in advance
- 12
- Help me!! Why java is so popularrad dog58c wrote:
>
> How can it negative? I'm not saying you're wrong, but how can any
> byte-coded language outperform a binary language if they are doing the
> same thing? It can't, because you have to convert the byte code to
> the native binary stream before you can execute it. So I'm thinking
> you mean certain algorithms are more efficiently handled by the JVM?
> Please elucidate -- I heard someone say Java memory management now
> exceeds C and I thought it was an interesting notion and probably
> related to some ingenius optimizations in memory mgt algorithms,
> though I honestly don't know.
Garbage collection can have an advantage in multi threaded applications,
and in Java we can have exact c. The JIT can optimise (and inline) the
code you are actually using today. I have code where part of computation
is represented by an interface and the implementation selected depends
on the data being processed.
In a compiled language you can't optimise across the interface call
whereas with Java you can. Even better you can generate byte code at run
time (e.g. compile an expression typed by the user) and then the JIT can
compile that to machine code and if it is simple enough inline it.
Java can devirtualise a method call if at some point you happen to have
only one implementation in the JVM.
> No doubt, and Java's fine messaging implementation and rich set of
> protocol support, eg, makes it a good vehicle for such things. A
> service I'm fine with -- a utility I need to fire up over and over,
> not so fine with that. I wouldn't write that in Java.
If it is something you fire up manually then the startup time isn't
important (takes you longer to type the command). If it is run from a
script, then it rather depends on the script (i.e. if the script system
maintains a JVM to execute little tasks in, the startup time can again
be negligible).
>
> At one time there was a Java compiler that let you go from Java
> to .EXE. I used it quite a bit, although the .EXEs it generated were
> pretty fat for the functionalit they implemented. Then again Java's
> not about creating .EXEs, so that didn't surprise me.
Such things still exist but have always struggled to match the
performance of regular JVMs.
> How does one get Java to run faster than a compiled language?
Take advantage of its strength, the ability to compile dynamically
loaded (or created) code and optimise the whole without regard for
module boundaries. Also take advantage of garbage collection --- its
performance has dramatically improved in recent years.
Mark Thornton
- 13
- How can I make my applet call another Web page?Hi All,
Would anyone know a way to have an applet call another Web page so
that, after the new page is loaded, if I hit the back button then I go
back to the page where the applet is at?
I don't need to know about button action events or about layout
managers or anything like that, just the URL processing code, or a
good reference.
Thank you,
S.
- 14
- Forged posts (was: Re: operator overloading)Someone impersonating Lew <email***@***.com> writes:
> Those aren't domain goals, those are church programmes, and they
> don't matter a jot to the cheesecake.
[ More dissociated-press text elided. ]
Has anyone else complained to the site where these posts are
being injected or does Lew enjoy having a special fan?
Regards,
Patrick
------------------------------------------------------------------------
S P Engineering, Inc. | Large scale, mission-critical, distributed OO
| systems design and implementation.
email***@***.com | (C++, Java, Common Lisp, Jini, middleware, SOA)
- 15
- Outsourcing to India and ChinaPhillip Lord <email***@***.com> wrote in message news:<email***@***.com>...
> >>>>> "Loco" == Loco Pollo <email***@***.com> writes:
>
> >> >this is anti free trade and ultimately anti freedom.
> >>
> >> Free trade is not necessarily a good thing.
>
> Loco> no but many good can come of it.
>
> >> First it encourages shipping goods all over the planet that could
> >> have been produced locally. This wastes fuel and pollutes the
> >> atmosphere.
>
> Loco> in a truly market economy, it wouldn't happen unless it is
> Loco> cost effective. this would include the cost of pollution.
>
> No it wouldn't. The market economy fails to work for any commodity
> where the cost of charging for that commodity either outweighs the
> value of that commodity, or worse, there is no way to charge for a
> commodity.
>
> For example, I like hill walking. In the UK there are lots of
> hills. Its not possible to charge for them because building a large
> fence around the for example, the 150 miles of the peninnes would cost
> a massive amount. Worse there is a legal "right to roam" which
> effectively stops the land owners from doing this anyway.
imho what your talkin bout has nothin to do with a free market. if
there's no market for it the market wouldn't be there. if there is a
need a market would self create itself. in your example, no company
would try to charge you for the trails you use if there was no way to
make $ off of it(of course there is and they are, hiking boots from
texas, rain jacket made in china, etc..). the destruction of nature
caused by hikers has more to do with govt and user obligations than
with free trade. actually none of that example has to do with free
trade.
> Of course in the US, it would be a different matter, as you would just
> build a gate across the road leading too the hills, which would
> effectively block all access.
actually we got what's called national parks where the govt pays for
its upkeep subsidized by entry fees. i'm guessing our national park
system has 100s of millions of people accessing them per yr and
preserves what would otherwise be developed.
> >> It enables multinationals to exploit workers by threatening to
> >> move to where labour and environmental laws are laxest.
>
> Loco> multinationals are no different than national companies. if a
> Loco> country "can" manage a national company, i see no reason why
> Loco> the world can't manage a multinational.
>
> We don't have a world government. The only "regulatory" bodies for
> multinationals for some reason seem to work in the interest of the
> multinationals, or more accurately the interest of those who own the
> multinationals rather than the population at large.
we do have a world govt. there are people who specialize in
international laws. yes multinationals have way too much power,
however, this isn't because of free trade. its because we as a species
are too greedy and corrupt.
we have everything we need to create a paradise but none of the social
maturity to accomplish it.
|
|
|