Eclipse Ant problem after upgrade: Could not find main class for InternalAntRunner

27 10 2012

The error appears after calling ant build command with eclipse and it is known issue after eclipse upgrade.

How to repair

It is enough to ‘Restore Defaults‘ settings of ant Runtime in Eclipse Window -> preferences. As for now it is just a workaround (the eclipse issue is still opened for it):

Restore Ant Defaults

Ensure that you have proper Ant configuration in eclipse

Make sure that eclipse has ant plugin installed. If not – follow instructions at the bottom of this page: Troubleshooting Eclipse Installation.

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!

Advertisements




Remote use of VisualVM with Xming

10 02 2012

Regarding post about problems with remote monitoring here is some more help needed when cases described in this post fails.

This solution will work even if your remote host is hidden behind firewall, NAT etc. Having SSH access to it is enough. You will need Putty and XMing.

Istructions:
1. Put the visualVM files on the remote host (it does not require installation) e.g. in:

/root/visualvm_133/

2. Open putty session to remote server, enabling X11 forwarding:

X11 forwarding in putty

X11 forwarding in putty

3. Run XMing on local machine (standard configuration). It will start listening for X11 connections.
4a. Then, using Putty, from a remote command line, launch visualVM on the server. It will forward X11 connection to local machine, where XMing is listening. Sample command to start XMing:

/root/visualvm_133/bin/visualvm

4b. If simply launching visualVM does not help then try to point the java JDK path in the command line. Mine command looks like this:

/root/visualvm_133/bin/visualvm --jdkhome /usr/java/jdk1.6.0_12/

5. VisualVM should now appear in XMing window and it is ready to be used. Keep putty session opened while using XMing.

This will surely work! Let me know if any comments on this tutorial will appear :)

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!





Java Date Parse Exception

15 01 2012

Post describes maybe a bit niche and low-level problem, however sometimes it happens for me and for others too. The exception is:

java.lang.NumberFormatException: multiple points

and appears during date parsing with SimpleDateFormat:

DateFormat df = new SimpleDateFormat ("yyyy-MM-dd");
Date d1 = df.parse("2011-31-12");

in multi-threaded applications. The problem is that parse method is not thread-safe, although this is a bit surprising, since it is quite often used. It is described in Javadoc, under the Synchronization section:

Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.

So You just have to be aware of this and care about synchronization on Your own. I wasn’t – my glassfish application threw exceptions that were hard to replicate – they appeared only when more than one user used application. Application itself is not multithreaded,  but glassfish sessions causes it to run in separate threads, I suppose (do You have a better clue?).

Simple Solution, I used is overriding DateFormat by my own Thread Safe SimpleDateFormat. It takes few seconds and looks OK!, although I am not using Spring – the problem is connected with Java itself and not caused by Spring (source):

import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ThreadSafeSimpleDateFormat extends DateFormat {
    private String pattern;

    public ThreadSafeSimpleDateFormat(String pattern) {
        this.pattern = pattern;
    }

    @Override
    public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
        return new SimpleDateFormat(pattern).format(date, toAppendTo, fieldPosition);
    }

    @Override
    public Date parse(String source, ParsePosition pos) {
        return new SimpleDateFormat(pattern).parse(source, pos);
    }
}

then just redefine to ThreadSafeSimpleDateFormat instead of SimpleDateFormat in Your code and problem is solved.

Sources: 1 2

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!





Setting up Glassfish Monitoring – handling connection problems

3 01 2012

On a production environment I came across few (mainly connection related) issues while trying to monitor glassfish application remotely with either JConsole or VisualVM. Tools does not differ in a connection method – problems were exactly the same and not caused by tools, but by glassfish setup, application statuses and firewall configuration.

Standard Settings Required

There is not very much of it. Just turn on Glassfish Monitoring using GUI. For HTTP Service and Web Container at least. LOW level is enough. Set it in: Configuration -> Monitoring.

Default configuration in Configuration -> Admin Service -> System is enough. You can take a look also in Application Server -> Monitor, if You like :)

Problem 1

One of the Glassfish applications in VisualVM is visible but its stats are not available (App #1), and the other application is not visible at all
It appears that this is some old app visible in Glassfish admin GUI, but not existing on the file system. Here is how it looks like in VisualVM:

VisualVM showing dead application

VisualVM Showing dead application

App cannot be analyzed and there is some info on the VisualVM troubleshooting page (at the bottom):

No Servlets Displayed In The Runtime Area Of GlassFish Web Application Tab
Description: There are no servlets displayed in the runtime are of GlassFish web application tab (see here)
Resolution: Only servlets with some statistics available are displayed. In order to generate statistics put some load on the web application.

It appeared that App #1 was an older version of an existing App #2 (that is was not visible because of it). Removing App #1 by Glassfish admin GUI helped to resolve this conflict, and App #2 (the current version showed up and was able to be monitored.

Problem 2

Problem connecting to the remote Glassfish instance
After setting up the Glassfish IP address and credentials the connection could not be established. I solved this issue by dedicated RMI configuration. It was necessary because of a NAT, I suppose. The result is that RMI receives packets from VisualVM, and then responses that it is listening on his local IP address (127.0.0.1). Then VisualVM is lost, because following requests are sent to given IP (127.0.0.1).
The solution is to set in a Glassfish his own external IP address, using GF admin GUI. There You have to set the JVM Parameter:

-Djava.rmi.server.hostname=Glassfish_Server_External_IP_Address

And it works! Helpful sources: source 1 and source 2.

(Theoretical) Problem 3

Maybe jstatd or firewall?
This source states that the jstatd (daemon responsible for RMI) has to be running in order to be able to connect to GF using RMI. I have two hosts with similar configuration, and to the one of them I was able to connect, the other one – not. both of them did not have jstatd running. As it turned out later this was not the problem (my problem was RMI IP described in Problem 2).

So info in this source may be outdated or maybe I’ve made some mistake in using it or it was simply not a case for me.

Firewall can surely be a cause of Your problem. If You know that traffic is blocked – nothing will help. Then I advice You to try setting up Monitoring tool locally on Glassfish Server and connect using Xming. This is also a good solution.

Do not hesitate to ask a question if You need more details!

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!








%d bloggers like this: