Tasked with converting a project to Maven, I needed to find out the version of the dependencies, as not all of them had the version in the name.
Looking Up a Single Jar
If it’s a single jar you want to look up, it’s quite easy. Simply take the sha1 hash of the file, head over to the Maven Central Advanced Search, and put the hash in the “SHA-1 Checksum” field.
Looking Up Many Jars
The above becomes very tedious very quick if you have dozens of jars to lookup. A whole directory of mysterious dependencies.
Maven Central has a search API that I quickly took advantage of to automate the above process in Python. I created a script that will, for every file in a given path, hash the file and search for its version.
You simply run it as >jar_version.py <path>
Feel free to use the script.
with open(file_path, 'rb') as f:
maven_hash_url = "http://search.maven.org/solrsearch/select?q=1:%22" + sha1_hash + "%22&rows=20&wt=json"
response = urllib2.urlopen(maven_hash_url)
results_parsed = json.loads(maven_central_response)
if results_parsed["response"]["numFound"] == 0:
return "Not Found"
specific_results = results_parsed["response"]["docs"]
return specific_results["g"] + " " + specific_results["a"] + " v" + specific_results["v"]
sha1_hash = sha1_of_file(artifact_path)
html = search_maven_central(sha1_hash)
result_value = pull_result_version_from_results(html)
print artifact_path + " -> " + result_value
path = sys.argv
for root, _, files in os.walk(path):
for f in files:
full_path = os.path.join(root, f)
I spent some time myself trying to figure out how to easily install JBoss EAP as a Windows service. I then came across an excellent thread post on developer.jboss.org which let me do what I wanted. My own post will be based on that.
Files You’ll Need
First, you’ll need commons-daemon-1.0.15.jar, which is from Apache and can be downloaded here.
Second, you’ll want prunsrv.exe, also from the Apache commons-daemon library. But this item you’ll need to get from the Windows binary downloads section.
Lastly, you’ll need the batch file that will create the service for you, using the previously acquired jar and exe. This file can be found directly in either the comment I am basing this post on (service.bat.zip), or the bugzilla ticket that post is basing itself on.
Place everything in %JBOSS_HOME%\modules\system\layers\base\native\sbin
Installing the Service
Open up a command prompt in the sbin directory previously mentioned. And run
The parameters you can pass to this batch file are as follows (pulled from the batch file’s usage output):
- /controller <host:port>: The host:port of the management interface
- default: %CONTROLLER% – “localhost:9999”
- /host [<domainhost>]: Indicates that domain mode is to be used with an optional domain controller name
- default: %DC_HOST% – “master”
- Not specifying /host will install JBoss in standalone mode
- /loglevel <level>: The log level for the service: Error, Info, Warn or Debug (Case insensitive)
- default: %LOGLEVEL% – “INFO”
- /name <servicename>: The name of the service – should not contain spaces
- default: %SHORTNAME% – “JBossEAP6”
- /desc <description>: The description of the service, use double quotes to allow spaces
- default: %DESCRIPTION% – “JBoss Enterprise Application Platform 6”
- /serviceuser <username>: Specifies the name of the account under which the service should run.
- Use an account name in the form DomainName\UserName
- default: not used, the service runs as Local System Account
- /servicepass <password>: password for /serviceuser
- /jbossuser <username>: jboss username to use for the shutdown command
- /jbosspass <password>: password for /jbossuser