FilecreateTempFile behaving differently in webMethods

I am creating temporary files using following Java code.

File tmp = File.createTempFile(“ORD” , “.tmp”, new File("/home/adubey"));

When I put this code in a Java file, compile and run it, then its generating temporary files with name “ORD#####.tmp”, where “#####” is a randomly generated number.

However, if I am creating a Java Service in webMethods and using same java code for temporary file generation, then the value of “#####” is always sequential. After every execution the “#####” value is getting an increment of one.

Are there any properties or settings available in webMethods which is a reason for this sequential temporary file generation, and where is this sequence number being persisted?


webMethods is a company, not a product. A point that I will keep hammering until everyone gets it :slight_smile:

Which product are you talking about? I assume Integration Server.

Just a guess here, but because pre-Java 2 didn’t have createTempFile there were some implementations out there that provided similar functionality. You might be picking up a different File class than expected in IS. You might try specifying the fully-qualified class name of to see if that makes a difference.

I have created a java service in webMethods Developer, which is generating sequential temp file names.
But the same code written as Java class outside webMethods Developer is generating random file names.

I tried specifying fully qualified class name (both the places, java file and java service) of, but no change in output.

The Java version and vendor of my IS is:
Java Version: 1.4.2_01 (48.0)
Java Vendor: Sun Microsystems Inc.

This behaviour is strange…


Try creating several temp files within a single run of the stand-alone version. You’ll see the same sequential behavior.

The reason for this is the use of a random number generator to get the initial value. Each time the JVM is started, a new number is used. After the first one is used, subsequent calls to createTempFile simply increment the number until it finds one that is not used by an existing file (see the source of for confirmation).

Thanks a lot Rob. It was a very clear explanation. However it has raised couple of more questions in my mind.

I tried executing the same java service of webMethods Integration Server from different usernames and from different machines but it was giving the same sequential output. I tried reloading the package as well but result was same. However I am getting a new number if I restart the IS. I would be grateful if I get some comments on my questions:

  1. Does webMethods Integration Server initialize the JVM only once in its life cycle?

  2. What mechanism webMethods Integration Server is following in order to initialize and execute a Java service?

  3. Why webMethods Integration Server is not initializing the JVM on every execution of a Java Service, is there any specific reason for this?


  1. The IS runs within a JVM. There is only one JVM and it runs IS, not the other way around. When you shut down IS, it does some clean up and then the JVM stops.

  2. How it manages things specifically I do not know, but an IS Java service is simply a static method within a class. Without getting into too much detail, when a Java service is to be invoked, IS simply calls the method within the appropriate class.

  3. Because there is only one JVM running, and IS is running within it. IS is a Java application.


Thank you very much for your comments.