Posts Tagged ‘java’

Weird Jenkins Error: java.lang.NoClassDefFoundError: hudson/model/ComputerSet

Wednesday, May 30th, 2012

I finally got passed that Jenkins NoClassDefFound error when managing nodes… Now no such errors and the system was back. The slave machines are back to work and projects are building now!

The Jenkins error message (the log jenkins.log is under /var/log/jenkins/ in a standard standalone Linux installation) does not make sense and was misleading:

May 29, 2012 3:03:32 PM hudson.triggers.SafeTimerTask run

SEVERE: Timer task hudson.model.LoadStatistics$LoadStatisticsUpdater@12c8855 failed

java.lang.NoClassDefFoundError: hudson/model/ComputerSet

at hudson.model.LoadStatistics$LoadStatisticsUpdater.doRun(LoadStatistics.java:215)

at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:54)

at java.util.TimerThread.mainLoop(Timer.java:512)

The class was there. We just need to remove nodeMonitor.xml when migrating Jenkins instance.

nodeMonitors.xml: when migrating to another instance of Jenkins, remove the old nodeMonitors.xml to solve that NoClassDefFound erroe/issue as follows:

sudo  mv /var/lib/jenkins/nodeMonitors.xml /var/lib/jenkins/nodeMonitors.xml.old

nodeMonitors.xml will be automatically generated.

During the time I tried to resolve the issue, I also tweaked the JDK setting in Jenkins config. I added a jdk named jdk1.6-/usr/java/default/bin/java with JAVA_HOME: /usr/java/default

Be sure to take this out in Jenkins config if you are using slaves; it depends on slave machines env varianle JAVA_HOME. Adding this only confuses the salve machine as this overrides its local JAVA_HOME setting. If your master machine is Linux and your slave machine is Windows(like for building .net applications we we also are doing, in addition to Java jobs), this will definitely cause an error: incorrect JDK home.

Finally, got osgi hot deployed in Glassfish V3!

Thursday, November 11th, 2010

The tricky part is, no matter what the online tutorials say (/opt/SUNWappserver/domains/domain1/autodeploy/bundles), the default hot deploy folder out of box for Glassfish V 3.0.1 for osgi auto deployment is:

/opt/SUNWappserver/domains/domain1/config/load

as indicated below:

[#|2010-11-11T16:53:20.863-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|{felix.fileinstall.poll (ms) = 2000, felix.fileinstall.dir = /opt/SUNWappserver/domains/domain1/config/./load, felix.fileinstall.debug = -1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = /tmp/fileinstall--5626012334122035867, felix.fileinstall.filter = null}|#]

After I did the following,

cp  /opt/SUNWappserver/domains/domain1/autodeploy/bundles/plugins/HelloOSGi_1.0.0.jar  /opt/SUNWappserver/domains/domain1/config/load/

all works as expected:

[#|2010-11-11T16:53:20.857-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|Hello World!!|#]

[#|2010-11-11T16:53:20.863-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|{felix.fileinstall.poll (ms) = 2000, felix.fileinstall.dir = /opt/SUNWappserver/domains/domain1/config/./load, felix.fileinstall.debug = -1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = /tmp/fileinstall--5626012334122035867, felix.fileinstall.filter = null}|#]

[#|2010-11-11T16:53:20.868-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|Goodbye World!!|#]

[#|2010-11-11T16:53:20.876-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|Hello World!!|#]

[#|2010-11-11T16:53:20.876-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|Updated /opt/SUNWappserver/domains/domain1/config/load/HelloOSGi_1.0.0.jar|#]

[#|2010-11-11T16:53:22.882-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|A bundle with the same symbolic name (HelloOSGi) and version (1.0.0) is already installed.  Updating this bundle instead.|#]

[#|2010-11-11T16:53:22.883-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|Goodbye World!!|#]

[#|2010-11-11T16:53:22.893-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|Hello World!!|#]

[#|2010-11-11T16:53:22.893-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|Installed ./load/HelloOSGi_1.0.0.jar|#]

[#|2010-11-11T16:53:22.894-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=17;_ThreadName=Thread-1;|Started bundle: file:/opt/SUNWappserver/domains/domain1/config/./load/HelloOSGi_1.0.0.jar|#]

Open-source solutions commonly used in Java UI development

Friday, October 29th, 2010

Format is:

For each third party library:

1) Name of all the third party software used in your components.

2) Version

3) Website where I can get that tool.

4) One line summary.

Here is the list:

Simple Logging Facade for Java (SLF4J)

rev=”1.5.8″;

www.slf4j.org/

The Simple Logging Facade for Java or (SLF4J) serves as a simple facade or abstraction for various logging frameworks, e.g. java.util.logging, log4j and logback, allowing the end user to plug in the desired logging framework at deployment time.

PrimeFaces

rev=”0.8.3″

http://www.primefaces.org/

PrimeFaces is a lightweight open source component suite for Java Server Faces 2.0 featuring 100+ rich set of JSF components. Additional TouchFaces module features a UI kit for developing mobile web applications.

hibernate

rev=”3.2.3.ga”

www.hibernate.org/

Hibernate an open source Java persistence framework project. Perform powerful object relational mapping and query databases using HQL and SQL.

click framework

rev=”2.1.0-RC1-incubating”

click.apache.org/

Click Framework is a modern JEE web application framework, providing a natural rich client style programming model.

Apache Tomcat

rev=”6.0.14″

tomcat.apache.org/

Apache Tomcat (or Jakarta Tomcat or simply Tomcat) is an open source servlet container developed by the Apache Software Foundation (ASF).

JSP/JSF Expression Language Implementation

rev=”1.0″

download.java.net/maven/glassfish/org/glassfish/web/el-impl/

A JSP/JSF Expression Language Implementation

How to enable Eclipse/Glassfish remote debugging

Monday, March 22nd, 2010

You would normally enable jdb by adding debug options into your Java start up command by attaching debugging into JVM process, like the following:

DEBUG_OPTS=”-Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend
=n”

You would consider adding this into your Glassfish’s(V2, in my case) start up script asadmin as below:

“$AS_JAVA”/bin/java “$DEBUG_OPTS” -Dcom.sun.aas.instanceName=server -Djava.libra
ry.path=”$AS_NSS”:”$AS_INSTALL/lib”:”$AS_ICU_LIB” -Dcom.sun.aas.configRoot=”$AS_
CONFIG” -Djava.endorsed.dirs=”$AS_INSTALL/lib/endorsed” -Dcom.sun.aas.processLau
ncher=”SE” -cp “$AS_DERBY_INSTALL/lib/derby.jar”:”$AS_INSTALL/jbi/lib/jbi-admin-
cli.jar”:”$AS_INSTALL/jbi/lib/jbi-admin-common.jar”:”$AS_INSTALL/lib”:”$AS_INSTA
LL/lib/appserv-rt.jar”:”$AS_INSTALL/lib/appserv-ext.jar”:”$AS_INSTALL/lib/javaee
.jar”:”$AS_INSTALL/lib/appserv-se.jar”:”$AS_INSTALL/lib/admin-cli.jar”:”$AS_INST
ALL/lib/appserv-admin.jar”:”$AS_INSTALL/lib/commons-launcher.jar”:”$AS_INSTALL/l
ib/install/applications/jmsra/imqjmsra.jar” -Dcom.sun.appserv.admin.pluggable.fe
atures=com.sun.enterprise.ee.admin.pluggable.EEClientPluggableFeatureImpl com.su
n.enterprise.cli.framework.CLIMain “${@}”

Actually this will not work.

You have to log into the Glassfish admin console, under:

Application server

JVM General Settings

Debug
Enabled (check it)

Hit save

Restart Glassfish.

You’ll see Glassfish start up script spits the following message:

Listening for transport dt_socket at address: 9009
Application server is listening at address 9009 for debugger to attach using transport dt_socket

It started to listen at port 9009 by default instead of 1044.

You’ll configure your Eclipse accordingly to do remote debugging. Remember the port number 9009 instead of 1044.

Click Framework And Jsp: Notes

Wednesday, July 1st, 2009

ClickFrameworkAndJsp

===========
Rendered page example:
http://www.avoka.com/click-examples/jsp/customer-table.htm
Source:
http://www.avoka.com/click-examples/source-viewer.htm?filename=/jsp/customer-table.htm

customer-table.jsp (src code) ==============>when accessing from browser: it should be accessed AS

customer-table.htm—this auto mapped to

customer-table.jsp-map to

CustomerTable.java

(if accessing it as .jsp, page is not rendered correctly)

This will first invoke customer-table.jsp,

-then invoke CustomerTable.java

-then invoke border-template.jsp as indicated in getTemplate method in above .java

- then render customer-table.htm (mapped to .jsp) via ${forward} in border-template.jsp when rendering border-template.jsp

(template is also a .jsp file.

…………….

<%@taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%>
<%@taglib prefix=”fmt” uri=”http://java.sun.com/jsp/jstl/fmt”%>

<style type=”text/css”>
th { color: white; }
</style>

<p>
Example JSP customers table.
</p>

<table style=”border: 1px solid black;” cellpadding=”6″ cellspacing=”0″>
<tr valign=”baseline” bgcolor=”404060″>
<th align=”center”> ID </th>
<th align=”left”> Name </th>
<th align=”left”> Email </th>
<th align=”center”> Age </th>
<th align=”left”> Category </th>
<th align=”center”> Portfolio </th>
<th align=”right”> Date Joined </th>
<th align=”center”> Active </th>
</tr>

<c:forEach var=”customer” items=”${customers}” varStatus=”lineInfo”>

<c:choose>
<c:when test=”${lineInfo.count % 2 == 0}”> <tr bgcolor=”#f7f7e7″> </c:when>
<c:otherwise> <tr bgcolor=”white”> </c:otherwise>
</c:choose>

<td align=”center”> ${customer.id} </td>
<td align=”left”> ${customer.name} </td>
<td align=”left”> <a href=”${customer.email}”>${customer.email}</a> </td>
<td align=”center”> ${customer.age} </td>
<td align=”left”> ${customer.investments} </td>
<td align=”right”> <fmt:formatNumber value=”${customer.holdings}” type=”currency”/></td>
<td align=”right”> <fmt:formatDate value=”${customer.dateJoined}” pattern=”dd MMM yyyy”/> </td>

<td align=”center”>
<c:choose>
<c:when test=”${customer.active}”> <input type=”checkbox” checked=”checked”/> </c:when>
<c:otherwise> <input type=”checkbox”/> </c:otherwise>
</c:choose>
</td>

</tr>

</c:forEach>

</table>

<p>&nbsp;</p>

The <tt>CustomerTable</tt> page is automatically mapped to the request:

<pre class=”codeConfig”>
GET customer-table.htm </pre>

When pages are configured to use automapping the <tt>ClickServlet</tt>
will automatically associated the file path <tt>customer-table.jsp</tt>
with the page class <tt>CustomerTable</tt>.

===========
http://www.avoka.com/click-examples/source-viewer.htm?filename=WEB-INF/classes/org/apache/click/examples/page/jsp/CustomerTable.java

package org.apache.click.examples.page.jsp;

import java.util.List;

import org.apache.click.examples.page.BorderPage;

/**
* Provides JSP Page example where a JSP page and JSP border template is used to
* render a table.
*
* @author Malcolm Edgar
*/
public class CustomerTable extends BorderPage {

public List customers = null;

/**
* @see org.apache.click.Page#onRender()
*/
public void onRender() {
customers = getCustomerService().getCustomersSortedByName(10);
}

/**
* Returns the name of the border template: &nbsp; <tt>”/border-template.jsp”</tt>
*
* @see org.apache.click.Page#getTemplate()
*/
public String getTemplate() {
return “/border-template.jsp”;
}

}

======================
This is the template file:

http://fisheye6.atlassian.com/browse/click/trunk/click/examples/webapp/border-template.jsp?r=787399

<!doctype html>
2
sabob 724639 3 <!–
4 Licensed to the Apache Software Foundation (ASF) under one
5 or more contributor license agreements.  See the NOTICE file
6 distributed with this work for additional information
7 regarding copyright ownership.  The ASF licenses this file
8 to you under the Apache License, Version 2.0 (the
9 “License”); you may not use this file except in compliance
10 with the License.  You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing,
15 software distributed under the License is distributed on an
16 “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 KIND, either express or implied.  See the License for the
18 specific language governing permissions and limitations
19 under the License.
20 –>
malcolm_edgar 715468 21
22
sabob 787399 23 <%– Menu –%>
24 <table id=“menuTable” border=“0″ width=“100%” cellspacing=“0″ cellpadding=“0″ style=“margin-top: 2px;”>
25 <tr>
26 <td>
27 <div class=“menustyle” id=“menu”>
28 <ul class=“menubar” id=“dmenu”>
29 <c:forEach items=“${rootMenu.children}” var=“topMenu”>
30 <li class=“topitem”>${topMenu}
31 <ul class=“submenu”
32 <c:forEach items=“${topMenu.children}” var=“subMenu”>
33 ><li>${subMenu}</li
34 </c:forEach>
35 ></ul>
36 </li>
37 </c:forEach>
38 <li class=“topitem”><a target=“_blank” href=“${context}/source-viewer.htm?filename=WEB-INF/classes/${srcPath}” title=“Page Java source”><img border=“0″ class=“link” alt=“” src=“${context}/assets/images/lightbulb1.png”/> Page Java</a>
39 </li>
40 <li class=“topitem”><a target=“_blank” href=“${context}/source-viewer.htm?filename=${path}” title=“Page Content source”><img border=“0″ class=“link” alt=“” src=“${context}/assets/images/lightbulb2.png”/> Page HTML</a>
41 </li>
42 </ul>
43 </div>
44 </td>
45 </tr>
46 </table>
47 </div>
malcolm_edgar 715468 48
sabob 787399 49 <%– Page Content –%>
50 <div class=“content”>
51 <h2>${title}</h2>  <============ from BorderPage.java
52 <p/>
sabob 782056 53 <jsp:include page=${forward} flush=“true”/>  <============= htm equivalent of path; the .htm page requested, in this case it renders requesing .htm page: customer-table.htm
sabob 787399 54 </div>
55
56 </div>
malcolm_edgar 715468 57
sabob 757699 58 ${jsElements}
59
malcolm_edgar 715468 60 </body>
malcolm_edgar 716421 61 </html>

=========imports for jsp==========
http://incubator.apache.org/click/docs/click-api/org/apache/click/util/PageImports.html

public class PageImportsextends Object

Provides a utility object for rendering a Page’s HTML header imports and its control HTML header imports.

A PageImports instance is automatically added to the Velocity Context for Velocity templates, or as a request attribute for JSP pages using the key name “imports“.

PageImports Examples

To use the PageImports object simply reference it your page header section. For example: <html>
<head>
$imports
</head>
<body>
$form
<body>
</html>
imports” include all javascript and stylesheet imports.
PageImports also provides a way of including the javascript and stylesheet separately using the key names “cssImports” and “jsImports“.

You should follow the performance best practice by importing CSS includes in the head section, then include the JS imports after the html body. For example:

<html>
<head>
$cssImports
</head>
<body>
$form
<br/>
$table
<body>
</html>
$jsImports
Please also see Page.getHtmlImports() and Control.getHtmlImports().

Tip of the day: Click Framework: variables in JSP

Wednesday, July 1st, 2009

A variable in a JSP should be included in bracelets, otherwise it will not be traeted as variables, although it works with .htm with Velocity engine. So $path works in .htm, in JSP it should write as ${path} if you wnat it to be teated as a variable instead of a literal.