Jak ustawić parametr -XX:+HeapDumpOnOutOfMemoryError w serwerze WildFly

Należy w pliku „%JBOSS_HOME%\bin\standalone.conf.bat” ustawić parametry -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<hprof-dump-dir zamieniając linię
set „JAVA_OPTS=-Xms64M -Xmx512M -XX:MaxPermSize=256M”set „JAVA_OPTS=-Xms64M -Xmx512M -XX:MaxPermSize=256M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=F:\memory-dumps”

Alternatywnym sposobem jest ustawienie zmiennej środowiskowej JAVA_OPTS – skrypt uruchamiający serwer standalone.bat ją uwzględnia.

Można to zrobić na działającym systemie korzystając z JConsole i operacji setVMOption mbeana com.sun.management:type=HotSpotDiagnostic lub korzystając z programu jinfo z JDK.

JavaScript Webapps with Gradle

Shine Solutions Group

Duke_the_Ripper IAP4377

Gradle is a build tool on the JVM platform that’s been gaining prominence over the last few years. Gradle’s reach doesn’t stop with JVM languages though.  The most recent releases, 1.10 and 1.11, have improved support for compiling native code (C / C++ / Objective C) and introduced support for the .NET platform. For Android projects, Google have made Gradle the de facto build tool. It’s getting a name for its flexibility, so when the opportunity came to build a single page Javascript webapp we decided to put the latest addition to the polyglot build tool arsenal through its paces.

View original post 4 290 słów więcej

Adding Features to an existing Product

...code is the easy part...

Normally when building an eclipse product using Tycho, you specify all the features you require in the .product file. This creates a single root level IU. There are various situations where this is not desirable. For example you may have a core product with add-ons features – much like Eclipse itself – but only maintain a single .product file. You may also wish to be able to update some features without needing to rebuild the whole product. There is an open bug for Tycho to help with this in the future.

In this post we will concentrate on the former case. We will assume there is a prebuilt product published to a p2 repository – here we will use the Eclipse RCP product. It is possible to use these steps are part of an eclipse-repository build but you will need to adapt the default Tycho configuration to delay the product…

View original post 804 słowa więcej

Xperf Basics: Recording a Trace (the ultimate easy way)

Random ASCII - tech blog of Bruce Dawson

imageIf your Windows computer is running slowly – if a program takes a long time to launch, if a game has a poor frame rate, or if an idle application uses too much CPU time – the best way to investigate is to record an Event Tracing for Windows (ETW) trace. An ETW trace records a wealth of information (CPU sampling, context switches, disk I/O, custom data, and much more) that allows most performance problems to be understood by a trained expert. If you’re not a trained expert then you can still record an ETW trace, and then share it with somebody who is.

If a particular program is being slow or inefficient then you may be able to record an ETW trace and share it with the authors of that program. Quite often they can figure out what is going wrong, whether it is a bug on their side

View original post 1 048 słów więcej

Eclipse/JVM fails to start due to lack of memory

Eclipsed

Lately, when starting Eclipse, the JVM has failed to start.  A reboot of the system usually fixed the problem.  Until yesterday.  So I had to dig in and solve this problem.

I wanted to share my experiences with debugging this issue.

Added Note: This is not the bug by which Eclipse running under java 1.6u21 fails to pass the permgen size on to the JVM.  If you are running java 1.6u21 with Eclipse, don’t.

Determine why eclipse.exe is crashing with „-debug”

I edited my eclipse.ini and added the -debug option:


-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
-debug
-vmargs
-Xms100m
-Xmx752m

Then I ran eclipse.exe from the command-line, hoping to get a bit more information:

$ ./eclipse.exe
Error occurred during initialization of VM
Could not reserve enough space for object heap

Now that’s a clear error message!

I need lots of memory

You may have noticed some pretty…

View original post 450 słów więcej

My favorite features of Scala – part I

During the last few months I’ve spent substantial amount of free time learning Scala and consider it time well spent. This article is first part describing my favorite features of Scala

Extractor Objects

Whenever you define a val or var, what comes after the keyword is not simply an identifier but rather a pattern.

val regex = "(\\d+)/(\\d+)/(\\d+)".r
val regex(year, month, day) = "2015/7/29"

The val regex is an instance of Regex, and when you use it in a pattern, you’re implicitly calling regex.unapplySeq , which extracts the match groups into a Seq[String], the elements of which are assigned in order to the variables year, month, and day.

Detecting missing and unnecessarily imported packages in OSGi bundles

When developing OSGi based application in Eclipse adding required import package declaration is assisted by PDE. In practice, it means that import package declarations are never missing – otherwise Eclipse project won’t comile and run. What programmers almost never do is to remove unnecessary declarations. Why would they if it works? In practice bundle manifests polluted with unnecessary imported packages can cause performance issues during bundle resolution and classloading and sometimes confuse Eclipse PDE during development.

To mitigate this problem I’ve created a small application leveraging the power of excellent BND library. I was really surprised when I run this tool against bundles from application I’m currently working on – some had literally hundreds of unnecessarily imported packages.

oipv 1.x
Usage: oipv [options]

  -j <jar1>,<jar2>... | --jars <jar1>,<jar2>...
        jars or folders to include
  -e <package1>,<package2> | --exclude-package <package1>,<package2>
        Package prefixes to exclude from analysis. You may want to
        excluded packages exported by JRE - javax.swing, javax.sql, etc.
        to avoid false positives
  --help
        print usage text

Application code available at GitHub (github.com) – https://github.com/jarek-przygodzki/osgi-import-package-verifier. The app itself is available here: oipv-1.0-master-f6c5c79.zip

Delete all disabled branches of a Bamboo build plan

Recently I found myself doing some Bamboo maintenance. Namely, I had to delete all disabled branches of build plan related to already deleted feature branches that Bamboo failed to automatically remove. At first, I tried this shell script, but it didn’t work for me with Bamboo 5.6.2 and I ended writing my own version. I’m posting it here hoping it will be useful for others too

#!/usr/bin/env groovy
/*
* Deletes all disabled branches of a Bamboo build plan
*
* Usage
* -----
* groovy bamboo_delete_disabled_branches.groovy \
* --bamboo-url <BAMBOO_URL, i.e. http://mycompany/bamboo&gt; \
* --plan-key <PLAN_KEY> \
* --user <USER> --password <PASSWORD>
*
* Author: Jarek Przygódzki <jarek.przygodzki@gmail.com>
*/
def MAX_BRANCH_RESULT = 500
@Grapes(
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
)
import groovyx.net.http.*
def cli = new CliBuilder(usage:'groovy bamboo_delete_disabled_branches.groovy')
cli.with {
h longOpt: 'help', args: 0, 'Usage information', required: false
_ longOpt: 'dry-run', args: 0, "Don't delete anything"
_ longOpt: 'bamboo-url', args: 1, argName:'Bamboo URL', 'URL of the Bamboo instance, i.e. https://bamboo.mycompany.com', required:true
_ longOpt: 'plan-key', args: 1, argName:'plan key', 'Bamboo plan key', required:true
_ longOpt: 'user', args: 1, argName: 'user', "User name", required: true
_ longOpt: 'password', args: 1, argName: 'pass', "Password", required: true
}
def options = cli.parse(args)
if(!options) {
return
}
def bambooUrl = options.'bamboo-url'
def dryRun = options.'dry-run'
def user = options.'user'
def pass = options.'password'
def planKey = options.'plan-key'
def bambooGetPlanUrl = "$bambooUrl/rest/api/latest/plan/$planKey/branch"
def bambooDeletePlanUrl = "$bambooUrl/chain/admin/deleteChain!doDelete.action"
def http = new RESTClient(bambooUrl)
//http.auth.basic(user, pass) doesn't work with GET
http.headers['Authorization'] = 'Basic '+"$user:$pass".getBytes('iso-8859-1').encodeBase64()
http.headers["X-Atlassian-Token"] = "no-check"
http.contentType = ContentType.JSON
def deleteBranch
if(!dryRun)
deleteBranch = { buildKey -> http.post(path: bambooDeletePlanUrl, query: ['os_authType':'basic', 'buildKey' : buildKey]) }
else
deleteBranch = { buildKey -> }
def deleteBranches = { branches -> branches.each {
def buildKey = it.key
println "Deleting $buildKey ..."
deleteBranch(buildKey)
}
}
def getAllBranches = {
http.get(path: bambooGetPlanUrl, query: ['expand':'branches', 'max-results': MAX_BRANCH_RESULT])
}
println "Deleting disabled branches from $planKey ($bambooUrl)"
def resp = getAllBranches()
def branches = resp.data.branches.branch
def isBranchDisabled = { branch -> !branch.enabled }
def disabledBranches = branches.findAll isBranchDisabled
println "Found (${disabledBranches.size()}) disabled branch plans"
println "Deleting branch plans" + (dryRun ? " [dry run]" : "")
deleteBranches(disabledBranches)
println 'Done'

Usage is very simple

groovy bamboo_delete_disabled_branches.groovy \
      --bamboo-url <BAMBOO_URL, i.e. http://mycompany/bamboo> \
      --plan-key <PLAN_KEY> \
      --user <USER> --password <PASSWORD>

You can also perform a simulation without actually deleting anything with „–dry-run” option.

Sprawdzanie wersji plików JAR

Niedawno znalazłem się w sytuacji, gdy musiałem sprawdzić wersje plików JAR by zapewnić zgodność tworzonego release-a z Javą 6. Nie udało mi się znaleźć gotowego narzędzia, więc napisałem coś własnego: github.com/jarek-przygodzki/jarversion.

Program jest napisany w Scali, ale dla użytkownika nie ma to znaczenia. Po zbudowanie projektu użycia jest bardzo proste

$ jarversion

jarversion 1.x
Usage: jarversion [options]

  -j <jar1>,<jar2>... | --jars <jar1>,<jar2>...
        jars to include
  --verbose
        be verbose
  --help
        print usage text
Print jar file version number defined as the maximum version of all classes contained within jar file

$ jarversion --jars  "/apps/dev/eclipse-jee-mars-R/eclipse/plugins/com.ibm.icu_54.1.1.v201501272100.jar,/apps/dev/eclipse-jee-mars-R/eclipse/plugins/com.sun.el_2.2.0.v201303151357.jar"

/apps/dev/eclipse-jee-mars-R/eclipse/plugins/com.ibm.icu_54.1.1.v201501272100.jar = ClassVersion(49,0)
/apps/dev/eclipse-jee-mars-R/eclipse/plugins/com.sun.el_2.2.0.v201303151357.jar = ClassVersion(50,0)

Można oczywiście poprawić kilka rzeczy, w szczególności format wyjścia i prezentować informacje, że np. 45.0 to JDK 1.1 a 52.0 to J2SE 8 ale nawet w obecnej postaci aplikacja spełnia swoje zadanie

Bundle-NativeCode: Using platform-specific DLLs from OSGi

holistic tendencies

I’m currently doing some development on a large RCP application. One recent task required using a Windows DLL to open an email message through MAPI, which is made pretty easy with OSGi. But I encountered a few issues that I’m sure will bite other people.

Bundle-NativeCode

OSGi now provides some support for resolving and loading shared libraries/DLLs in Java applications. A bundle declaratively specifies its DLLs and associated platform requirements in their bundle manifest using the Bundle-NativeCode header. This header value is then used when loading a DLL through System.loadLibrary().

TheBundle-NativeCode header specifies a number of comma-delimited clauses. For example:

Bundle-NativeCode: lib/win32/x86/http.dll; lib/win/zlib.dll;
    processor=x86; osname=win32, 
  lib/macosx/libhttp.dylib; lib/macosx/libzlib.jnilib;
    osname=macosx; processor=x86; processor=x86_64,
  *

A clause specifies one or more DLLs. A clause is matched to the current platform using a set of parameters (e.g., processor and osname, but also osversion, language, or a selection-filter). Parameters of…

View original post 408 słów więcej