Windows makes it possible to map drives on network servers to local drive letters so they can be accessed by users as if they were a local drive. This is a very powerful feature of Windows, which many applications take advantage of.
The problem, however, is that Windows is not very consistent about how it handles such mapped drives when accessed from a Windows Service. When the service is started manually, the drives will be available, but when the system is rebooted, the service will no longer be able to access them.
The Java Service Wrapper provides a simple way to tell the service to map network drives itself when they are not available. This means that they can be accessed reliably at any time.
Solution |
The solution is to give the service the ability to map its own drives. The Java Service Wrapper provides a flexible set of properties that make it possible to map network drives as well as printers on startup. By doing so, Java applications will be able to reliably make use of such shares regardless of when the service is started. In Windows, network shares can be mapped to drive letters so they can be accessed as if they were local drives. Many applications make use of this ability to seamlessly access files that are shared across the network. However, when such an application is converted into a service, access to the mapped drives will become unreliable, because the mapping is potentially only done in the session of the user. They are available in some cases but not others, depending on when the service is started, and who was logged in to the machine at the time. |
Technical Overview |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
It is possible to configure a Windows Service to run as a specific account. However, the mapped drives that are setup in that account will not be available when the system first boots up, and will thus not be available to the service. If a user logs on with the same account, then the drives will be setup, but they will still not be available to the service unless it is completely restarted. Traditionally, this has meant that it was necessary to access files on the network using the UNC (Uniform Naming Convention):
This UNC syntax works with some applications, but it is not as convenient or portable as a mapped drive:
Many applications that were originally not designed to be run as a Windows Service, or that access network drives, will fail when they encounter a UNC path in a configuration file. The Java Service Wrapper makes it easy for services to access shared resources. With just a set of "share" properties, you can easily configure mappings to remote locations or printers and make them available to the running account, before the Java application is launched.
|
Reference: wrapper.share.<n>.* Properties |
These properties are used to configure the mapping of Network Resources to local drives.
|