Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Tuesday, April 3, 2012

NClass - Free UML Class Designer



If you are ever looking for a nice UML class designer look no further than NClass. I used this for a project to port a large code base from .NET to Java. The program was able to reverse engineer UML from compiled .NET code. Love it.

Thursday, February 16, 2012

Java little endian IO gotcha

Java's goal has been to provide developers with a language that is cross platform, write once run everywhere. To do this Java handles many platform details for you. But sometimes those details are important. Here is an example, I needed to output a TIFF using little-endian byte ordering regardless of what platform the Java code was running on.

import java.io.FileOutputStream;

byte[] imgData = //create the image data using JAI;
String filename = "platform-endian.tiff";

FileOutputStream fos = new FileOutputStream(filename);
fos.write(imgData);
fos.close();

My code would work fine on platforms with Intel or x86 architecture which is little-endian byte order, but when I moved my code to a Solaris system running a SPARC processor, my code started outputting in big-endian TIFFs. This is due to the fact that FileOutputStream hides some of the complexity involved with writing data out to disk. Hiding this complexity is fantastic if all you care about are outputting TIFFs that are byte-order-compatible with the environment your Java code is running in; which is what you would want in 99% of the use cases for creating TIFFs programmatically. But this feature of Java is very bad when you always need little-endian TIFFs at all times. I need little-endian because it is a Federal Reserve regulations are that the TIFFs I make be little-endian.

Thankfully there is a way to force Java to use a specific byte ordering. Use ByteBuffer.

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.io.FileOutputStream;

byte[] imgData = //create the image data using JAI;
String filename = "little-endian.tiff";

ByteBuffer buffer = ByteBuffer.allocate(imgData.length);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.put(imgData);
out = new FileOutputStream(filename).getChannel();
out.write(buffer);

This code will output directly in little-endian regardless of the architecture of the system running the code.


Thursday, January 26, 2012

Java static initialization gotcha

If you have a class which has a singleton instance of itself as a static member, and also use a static inititialization block, then you can run into an issue with initialization like I did where static final members are null.
01 import java.util.*;
02
03 class MySingletonClass {
04 private static final instance = new MySingletonClass();
05 private static final List MY_STRINGS;
06 static {
07 MY_STRINGS = new ArrayList();
08 }
09 public MySingletonClass() {
10 System.out.println("MY_STRINGS: "+MYSTRINGS);
11 }
12 }

The above will throw a NullPointer Exception on line 10 because the MySingletonClass constructor is called BEFORE the static initialization block is executed. So change it to this:
01 import java.util.*;
02
03 class MySingletonClass {
04 private static final instance;
05 private static final List MY_STRINGS;
06 static {
07 MY_STRINGS = new ArrayList();
08 instance = new MySingletonClass();
09 }
10 public MySingletonClass() {
11 System.out.println("MY_STRINGS: "+MYSTRINGS);
12 }
13 }

Now the instance static member variable is not created until AFTER the other static member is initialized. So the constructor can correctly execute the print statement.

Tuesday, January 24, 2012

Use package-info.java for all your package level annotation needs

I had a problem, I needed to annotate all the occurrences of java.sql.Timestamp with an XmlJavaTypeAdapter for all classes in a Java package. For example I needed this done in dozens of generated source files:

@XmlJavaTypeAdapter(com.fourgablesguy.dao.hibernate.util.TimestampAdapter.class)
public Timestamp getCreateTs() {
return this.createTs;
}

The TimestampAdapter class is the following:
package com.fourgablesguy.dao.hibernate.util;

import java.sql.Timestamp;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class TimestampAdapter extends XmlAdapter {

@Override
public Date marshal(Timestamp v) throws Exception {
return new Date(v.getTime());
}

@Override
public Timestamp unmarshal(Date v) throws Exception {
return new Timestamp(v.getTime());
}

}


The reason I needed this done is because Timestamp does not have a public no-arg constructor and XStream could not marshall objects containing Timestamp objects. The nice solution to annotating these is to use package-info.java, you place this file in the same folder as the source java files, but it is not a typical source file. Here is the contents of my package-info.java:
@javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
({
@javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(value=com.fourgablesguy.dao.hibernate.util.TimestampAdapter.class,type=java.sql.Timestamp.class)
})
package com.myama.dao.hibernate;

This package-info file is used by Java to annotate all classes in a package, with this single file my problem was resolved. My TimestampAdapter allowed me to marshall Timestamp objects with XStream. I used fully qualified names of classes in the package-info since I was not clear if you could import packages or if you had package access to the enclosing namespace.

Wednesday, November 9, 2011

How to change the Java heap size for WebSphere Application Server 6.1 profiles

How to change the Java heap size for WebSphere Application Server 6.1 profiles

Open the integrated solutions console
https://:9044/ibm/console/
Default login is
system:manager

Navigate to the JVM for the server profile you want to change

Application servers > server1 > Process Definition > Java Virtual Machine
Change these values
Initial Heap Size=512
Maximum Heap Size=512
These correspond to the Xms and Xmx params of the JVM. So make sure you do not set Max lower than Initial, nor set Max higher than available OS RAM. I am not sure if adding a K,M,or G to the number will work, it seems by default the numbers are considered MB. Be aware that your JVM is 32 bit so there is a mathematical limit (and practical limit) to how much memory it can address. 3800 MB is where you will likely top out for max heap space unless your OS limits you to 2GB, which puts your heap max down to 1600MB.

You will have to restart the WAS server profile instance to have this change take effect on the JVM.

Wednesday, October 19, 2011

Adding a datasource to the maven jetty plugin

In your pom.xml
           <plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.21</version>
<configuration>
<!-- <jettyConfig>src/main/resources/devJetty.xml</jettyConfig> -->
<webXml>${basedir}/src/main/resources/jetty-web.xml</webXml>
<jettyEnvXml>${basedir}/src/main/resources/jetty-env.xml</jettyEnvXml>
<contextPath>/OCM</contextPath>
<scanIntervalSeconds>3</scanIntervalSeconds>
<scanTargetPatterns>
<scanTargetPattern>
<directory>src/main/webapp/WEB-INF</directory>
<excludes>
<exclude>**/*.jsp</exclude>
</excludes>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</scanTargetPattern>
</scanTargetPatterns>
<stopKey>foo</stopKey>
<stopPort>9966</stopPort>
</configuration>
</plugin>
Key lines are
<webXml>${basedir}/src/main/resources/jetty-web.xml</webXml>
<jettyEnvXml>${basedir}/src/main/resources/jetty-env.xml</jettyEnvXml>

Define your jetty-env.xml like this:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC -//Mort Bay Consulting//DTD Configure//EN http://jetty.mortbay.org/configure.dtd>

<Configure class="org.mortbay.jetty.webapp.WebAppContext">

<!-- an XADataSource -->
<New id="MAVENJETTYDS" class="org.mortbay.jetty.plus.naming.Resource">
<Arg></Arg>
<Arg>jdbc/datasource</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">[[jdbc driver class]]</Set> <!-- for example, com.ibm.db2.jcc.DB2Driver -->
<Set name="url">[[jdbc url]]</Set> <!-- for example, jdbc:db2://yourdbhostnameorip:[port]/yourdb -->
<Set name="username">[[username]]</Set><!-- for example, yourmom -->
<Set name="password">[[password]]</Set><!-- for example, correcthorsebatterystaple -->
<Set name="defaultCatalog">[[schema, if needed]]</Set>
</New>
</Arg>
</New>
</Configure>

Then add the ref to your web.xml
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_1270163143862">
<pre>
<!-- SNIP -->

<!-- Bug fix for editing locked CSS and JS running in Jetty -->
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>useFileMappedBuffer</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<resource-ref>
<res-ref-name>jdbc/datasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

</web-app>

Friday, October 7, 2011

Understanding Maven dependency scope

You can specify the scope for a dependency in the maven pom file, here are the scope values you can choose and what effect they have:

  • compile: This dependency is needed for compilation of the main source
  • test: This dependency is needed for compiling and running tests. It is not needed for compiling the main source or running the final artifact.
  • runtime: This dependency is needed for running the final artifact. It is not needed for compiling the main source or compiling or running the tests.
  • provided: This dependency is needed for compiling and/or running the artifact but is not necessary to include in the package, because it is provided by the runtime environment - for example, jsp-api.jar is provided by your web application container, so you don't include it in your WEB-INF/lib (for the example of a webapp); or a plugin or optional package that is a prerequisite for your application, but is not bundled with your application.
  • system: don't use this one

source: http://docs.codehaus.org/display/MAVENUSER/Dependency+Scopes

Tuesday, October 4, 2011

JSP debug code

The following can be pasted into a JSP and then used to display (either in HTML source or in the browser window), the JSP Request, Session, Page, and Application settings for the environment and container the JSP is running within.

I have found this to be a quick useful way to get the lay of the land, when joining a project already in development.




<!--
<%@ page import="java.util.*"%>
<%
Object eobj = request.getParameter("error");
if (eobj != null) {
Exception exception = null;
Object obj = request.getAttribute("exception");
if (obj != null && obj instanceof Exception) {
exception = (Exception) obj;
}
if (exception == null) {
obj = request.getAttribute("javax.servlet.error.exception");
if (obj != null && obj instanceof Exception) {
exception = (Exception) obj;
}
}
if (exception != null) {
%><pre>
<%
exception.printStackTrace(new java.io.PrintWriter(out));
%>
</pre>
<%
}
}
out.println("<h3>Request:</h3><ul>");
Enumeration names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
out.println("<li>HEADER " + name + ": "
+ request.getHeader(name));
}

for (Enumeration e = request.getParameterNames(); e
.hasMoreElements();) {
String name = (String) e.nextElement();
out.println("<li>PARAM " + name + "="
+ request.getParameter(name) + "</li>");
}

for (Enumeration e = request.getAttributeNames(); e
.hasMoreElements();) {
String name = (String) e.nextElement();
out.println("<li>ATTRIB " + name + "="
+ request.getAttribute(name) + "</li>");
}
out.println("</ul><h3>Session:</h3><ul>");
for (Enumeration e = session.getAttributeNames(); e
.hasMoreElements();) {
String name = (String) e.nextElement();
out.println("<li>ATTRIB " + name + "="
+ session.getAttribute(name) + "</li>");
}
out.println("</ul><h3>Page Scope Attributes:</h3><ul>");
for (Enumeration e = pageContext
.getAttributeNamesInScope(pageContext.PAGE_SCOPE); e
.hasMoreElements();) {
String name = (String) e.nextElement();
out.println("<li>ATTRIB "
+ name
+ "="
+ pageContext
.getAttribute(name, pageContext.PAGE_SCOPE)
+ "</li>");
}
out.println("</ul><h3>Application Scope Attributes:</h3><ul>");
for (Enumeration e = pageContext
.getAttributeNamesInScope(pageContext.APPLICATION_SCOPE); e
.hasMoreElements();) {
String name = (String) e.nextElement();
if (name.equals("com.sun.jsp.taglibraryCache")) {
out.print("<li>ATTRIB " + name
+ "= <b>NULL POINTER!</b></li>");
continue;
}
out.print("<li>ATTRIB " + name + "=");
out.println(pageContext.getAttribute(name,
pageContext.APPLICATION_SCOPE)
+ "</li>");
}
out.println("</ul>");
%>
-->

Monday, October 3, 2011

JSP for DataSource Connection Pool testing

If you need to test a datasource here is a JSP that will help you do it.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*,javax.naming.*,javax.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test Data Source</title>
</head>
<body>
<h1>Test Data Source</h1>
<p>Hello</p>
<%
DataSource ds = null;
Connection con = null;
Statement stmnt = null;
ResultSet resultSet = null;
try {
InitialContext ctx = new InitialContext();
ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DataSource");
con = ds.getConnection();
stmnt = con.createStatement();
resultSet = stmnt.executeQuery("select * from PERSON");
if (resultSet != null) {
%><table><tr><%
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
int nOfColumns = resultSetMetaData.getColumnCount();
for(int j = 0; j<nOfColumns; j++) {
String columnLabel = resultSetMetaData.getColumnLabel(j+1);
%><th><%=columnLabel %></th><%
}
%></tr><%
if (resultSet.getType() != ResultSet.TYPE_FORWARD_ONLY) {
resultSet.beforeFirst();
}
while (resultSet.next()) {
%><tr><%
for (int i = 1; i <= nOfColumns; ++i) {
%><td><%
Object value = resultSet.getObject(i);
if (resultSet.wasNull()) {
%><b>null</b><%
} else {
%><%=value.toString() %><%
}
%></td><%
}
%></tr><%
}
%></table><%
}
} catch(NamingException e) {
throw e;
} catch(SQLException e) {
throw e;
} finally {
try {
if (resultSet != null) {
resultSet.close();
}
} catch (SQLException e) {
}
resultSet = null;
try {
if (stmnt != null) {
stmnt.close();
}
} catch (SQLException e) {
}
stmnt = null;
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
}
con = null;
ds = null;
}
%>
</body>
</html>

Just change
java:comp/env/jdbc/DataSource

To what the name of your DataSource connection pool is.
Then change
select * from PERSON

To a test query from this table:


Cloudscape

#SQL SELECT 1

#DB2

#SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES

#Informix

#SQL SELECT COUNT(*) FROM SYSTABLES

#Microsoft SQL Server

#SQL SELECT COUNT(*) FROM SYSOBJECTS

#MySQL

#SQL SELECT 1

#Oracle

#SQL SELECT 1 FROM DUAL

#PointBase

#SQL SELECT COUNT(*) FROM SYSTABLES

#PostgreSQL

#SQL SELECT 1

#Progress

#SQL SELECT COUNT(*) FROM SYSTABLES

#Sybase

#SQL SELECT COUNT(*) FROM SYSOBJECTS



Do not use this code to interact with a datasource, this should only be used for figuring out what the name of a datasource you created in the J2ee container is and that it is working.

Monday, September 26, 2011

Database test SQL for each vendor

When I setup a connection pool or database tool with a new database profile I like to test that it works, here are some vendor specific SQL you can use to test your db connection.

Cloudscape

#SQL SELECT 1

#DB2

#SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES

#Informix

#SQL SELECT COUNT(*) FROM SYSTABLES

#Microsoft SQL Server

#SQL SELECT COUNT(*) FROM SYSOBJECTS

#MySQL

#SQL SELECT 1

#Oracle

#SQL SELECT 1 FROM DUAL

#PointBase

#SQL SELECT COUNT(*) FROM SYSTABLES

#PostgreSQL

#SQL SELECT 1

#Progress

#SQL SELECT COUNT(*) FROM SYSTABLES

#Sybase

#SQL SELECT COUNT(*) FROM SYSOBJECTS

This is useful because you don't often know what tables exist in a database to test a query with, you can't assume select * from person would work if no person table was created. These queries are for the builtin system database resource in the specific vendor database types, they should exist even on a freshly installed or blank database server.

Monday, September 19, 2011

How do I insert CR LF in string column of a DB2 insert statement?

The insert syntax for adding new lines or line terminators in varchar columns in DB2 is not straightforward:

INSERT INTO EXAMPLE_TABLE ("ID","LEVEL_ID","VERSION","CONTENT","TYPE","FRAGMENT_ID") VALUES (158781,317339,20110701, 'your line of text' || x'0D' || x'0A' || 'your next line of text','HTML',0); 

The key to the query is to use || operator to concatenate the strings for the content column. The syntax for adding CR LF is :

'your line of text' || x'0D' || x'0A' 'your next line of text' 

DB2 will take the above and combine the strings into a single value for the database. The x'0D' x'0A' is to say hex value OD (carriage return) and hex value 0A (line feed). Windows expects both, for Linux/Unix OS only the 0A character is expected. For some versions of Mac OS you use only 0D, the newest ones use only 0A to end a line. For browsers, 0A is also the only needed character which is often ignored unless surrounded by pre or code tags however having both 0D and 0A will not cause display issues. The newest Windows OS may have support for just 0A as well in some cases.




Friday, August 26, 2011

dynaTrace evaluation

dynaTrace can monitor/profile .NET and Java code but I only worked with evaluation of the Java side.

Download the dynatrace full install for linux x86 and windows x86 here product download page

Obtain a license key for evaluation (file will have a name like dynaTrace_license_201107201015.key)

You must have a dynatrace account to download them (dynatrace-3.5.2.2393.msi, dynatrace-3.5.2.2393-linux-x86.jar, dynaTrace_license_201107201015.key)

page dedicated to installation

Define a dedicated VM for dynatrace server/collector, I put the full install jar on a RedHat VM which acted as my server (make sure it has 4GB of RAM)
Run this to install the jar:
java -jar dynatrace-3.5.2.2393-linux-x86.jar

With this extracted to a folder (I put it in ~\dynatrace..) you can start the dyna collector and server with these commands:

cd dynatrace
nohup ./dtserver &
nohup ./dtanalysisserver &
nohup ./dtcollector &
I then ran the install for dynatrace-3.5.2.2393.msi on my desktop, I only installed the dynatrace client on my desktop.

Now you need to copy the dynatrace/agent/lib folder to the servers you want to profile/monitor (do not copy the folder to a path with a space in it like "program files", I put them in c:\tools\dynatrace\agent\lib)

Now you can change the websphere application server JVM arguments to add the dynatrace agent :
-agentpath:"C:\Tools\dynaTrace\dynaTrace 3.5.2\agent\lib\dtagent.dll"=name=OCMWS,server=192.168.1.122
-agentpath:/root/dynatrace-3.5.2/agent/lib/libdtagent.so=name=OCM,server=192.168.1.122

Note: Edit the line above to match the path to where you copied the dynatrace agent dll/so, also give each JVM you are monitoring a different name, and finaly the IP address is the dynatrace server IP address which may be different for you.

To add this to the JVM startup on WebSphere open the IBM console and go to
Servers | application server | server1 | Java Process and Management | Process Definition | Java Virtual Machine | Generic JVM Arguments
prepent the full -agentpath value to the Generic JVM arguments
Click ok and Save your changes, double check that the save took place by entering the console again and checking the generic jvm argument for the new value.

You will have to restart WebSphere to have the JVM startup with the new startup JVM arguments.

Launch the dynaTrace client after doing the above, tools | settings | dynatrace server | connectivity | put in the host IP address.
default values for login are admin:admin, port 2021, test the connection, it should be a green arrow and say success.

Click License, attach the license .key file for dynatrace evaluation: dynaTrace_license_201107201015.key.

Use online videos to see how to use the client to slice and dice the data from the agents and profile your application.




There is no license for the client so you can export captured data and give it to anyone with the client installed and they can view the details of the session and use the client to troubleshoot and make changes.


Thursday, July 28, 2011

Use OutputStreamWriter not FileWriter

Search your Java code for FileWriter and replace it with OutputStreamWriter... especially if you write UTF-8 encoded documents. You can run into a nasty problem where you develop your Java code on Linux and then when it runs on Windows, character encoding problems crop up. FileWriter uses a OS System setting to determine what encoding to use, so it will change depending on what OS runs the Java code!

Here is an example of how to use OutputStreamWriter for UTF-8 encoded output.
         OutputStreamWriter out = null;
try {
try {
out = new OutputStreamWriter(new FileOutputStream(outputFile),"UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage,e);
}
try {
out.append(yourStringDataToWriteToOutputFile);
out.flush();
} catch (IOException e) {
throw new RuntimeException(e.getMessage,e);
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e.getMessage,e);
} finally {
try {
out.close();
} catch (IOException e) {
throw new RuntimeException(e.getMessage,e);
}
}

Hope this helps you get past file character encoding bugs with Java. Here is a great link on various Java Anti-Patterns which should be avoided when writing enterprise class robust code:

Saturday, June 18, 2011

How do I use my web resource bundle within my Spring controller?



Here is how I did it:



In my controller:




import org.springframework.context.ApplicationContext; ...
@Autowired private ApplicationContext context;



In the resource bundle ApplicationResources.properties


gotocode.error.notfound=Sorry {0} is not recognized as a code. 



Back in the controller




public static final String GOTOCODE_NOTFOUND_KEY = "gotocode.error.notfound";
public
static final String CODE_NOT_FOUND_MESSAGE = "Sorry the entry {0} is not recognized as a code.";
...
public ModelAndView findNextInSeries(String code,..
String errorMessage = context.getMessage(
GOTOCODE_NOTFOUND_KEY, new Object[] { code }, CODE_NOT_FOUND_MESSAGE, Locale.getDefault());   

Previously my ApplicationResources.properties was configured in the web.xml







http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_1270163143862"></web-app>

<display-name>Sample Spring Resource Bundle
<distributable>

<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext
<param-value>ApplicationResources



As well as in the Spring Application context configuration (dispatcher-servlet.xml):

Setting up Eclipse TPTP for performance monitoring of Jetty run from Maven

This is a document to help you setup Eclipse TPTP plugin for performance monitoring of J2EE application deployed to Jetty using the jetty-maven-plugin.

Open MyEclipse Configuration center and search for TPTP, download the newest version of TPTP plugin, restart your IDE after the install finishes.

Next go to the TPTP homepage and download the Agent controller for your architecture (I downloaded windows IA32).

Extract the Agent controller zip to C:\Tools\agntctrl.win_ia32-TPTP-4.7.2

Edit your system environment variables and add

RASERVER_HOME=C:\Tools\agntctrl.win_ia32-TPTP-4.7.2 PATH=C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin;%PATH%  Open a command prompt and goto agent controller cd C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin SetConfig.bat 

This should display the following:

C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin>SetConfig.bat Specify the fully qualified path of "javaw.exe" (e.g. c:\jdk1.4\jre\bin\javaw.ex e):   Default>"C:\Program Files\IBM\WebSphere\AppServer\java\jre\bin\javaw.exe" (Pre ss  to accept the default value)   New value> Network access mode (ALL=allow any host, LOCAL=allow only this host, CUSTOM=list  of hosts):   Default>"LOCAL" (Press  to accept the default value)   New value>ALL Security enabled. (true/false):   Default>"FALSE" (Press  to accept the default value)   New value> 

Start the Agent Controller by launching a command console window with Administrator privledges (Run as Admni..) The change your working directory to

cd C:\Tools\agntctrl.win_ia32-TPTP-4.7.2\bin
ACServer.exe

See this link for more agent controller info http://dev.eclipse.org/viewcvs/viewvc.cgi/platform/org.eclipse.tptp.platform.agentcontroller/src-native-new/packaging_md/windows/getting_started.html?root=TPTP_Project&view=co

This is also a link with good info on TPTP http://eclipse.sys-con.com/node/508048?page=0,2

Configure piAgent and start your application with Maven by adding this to MAVEN_OPTS environment variable:

-XrunpiAgent:server=enabled 

From eclipse navigate to Run | Profile Configurations... | Attach to Agent | New

ACServer should be running on localhost port 10002, check this with netstat -a -b -n command or test button in eclipse

Jetty JVM Agent should be detected on the Agent tab. select ONLY ONE of the profile probes, CPU --or-- MEMORY etc.. do NOT select more than one, treat them as mutually exclusive radio buttons rather than check boxes.

You can then perform tasks in your application and save the data captured. Also you can create new reports from the captured data with TPTP eclipse tools.

See http://www.eclipse.org/articles/Article-TPTP-Profiling-Tool/tptpProfilingArticle.html

About Me

My photo
Lead Java Developer Husband and Father

Tags