Monday, August 22, 2016
OpenXava
Monday, February 23, 2009
Make Tiny Time Tracker launch faster!
- Go to the CVS repository and select tinytimetracker.jar and download the latest tinytimetracker.jar. You will probably need to download poi-3.5-beta3-20080926.jar if you don't have it.
- You can put the tinytimetracker.jar file anywhere on your system. For simplicity, I assume you are putting it at c:\TinyTimeTracker\tinytimetracker.jar.
- Using Windows Explorer, navigate to the C:\TinyTimeTracker directory.
- Right-click and choose New | Shortcut.
- For the location of the item field that comes up, just enter the following: javaw -cp "C:\TinyTimeTracker\tinytimetracker.jar" tracker.Tracker
- Name the shortcut whatever you want to.
- Now you can double-click the shortcut and Tiny Time Tracker will launch much faster than it ever did using Java WebStart.
Friday, June 27, 2008
A safe way to save entities in HP OpenView Service Desk (OVSD) web-api
If you have have worked with HP OpenView Service Desk (OVSD) web-api, you may have noticed sometimes it throws an exception that says "There are no changes to save." when you call the save() method on entities such as Servicecall, Workorder, Change, etc. This is annoying and fairly useless thing to know if you ask me. This should not be an exception in my opinion if you call save too often, especially since the api doesn't support transactions. Instead of repeating the same try catch blocks everywhere in my code, it became obvious to me that the safest thing to do is to just write a very simple method to call instead of the standard save() method on an entity. What the method below does is allows you to pass virtually any type of entity from HPOV web-api objects that have a save() method or more specifically inherit from IApiEntity object (this is at least all the major ones). Now instead of ... myServiceCallObject.save(); just call the method and pass it the object you want to save. SaveEntity(myServiceCallObject); This is clean and reduces unexpected bugs caused by this "exception" :) private void SaveEntity(IApiEntity entity) throws Exception { try{ entity.save(); } catch (Exception ex) { if (!ex.getMessage().equalsIgnoreCase("There are no changes to save.")) { throw ex; } } }
HP OpenView Service Desk Web-api saves when you don't expect it to.
Thursday, June 26, 2008
HP OpenView template field returns null from Web-api
Thursday, March 20, 2008
Lessons learned with Web Services in Eclipse 6
<mappings>
<mapping>
<property name="datePropertyName" nillable="true"/>
<property name="anotherDatePropertyName" nillable="true"/>
</mapping>
</mappings>Storing application settings in a property file
Monday, March 17, 2008
Creating a web service in MyEclipse 5 or 6 and deploying to Tomcat application server.
Thursday, March 6, 2008
Setting Default page in JSF
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> That's it. Side Notes This all assumes that JSF is using the .faces pattern to designate what a JSF page is. The whole reason we need the first two steps to create the index.jsp file is because the welcome-file tag must point to a file that actually exists in the file system. It can't be a .faces file, because it doesn't actually exist. Has anyone tried it such that JSF is setup to use a pattern like /faces/* instead of *.faces?. I have not tried it, but I think the same problem would exist because the faces directory directory doesn't exist either. Feedback is welcome on this issue. Instead of the JSP forward tag, you could use pageContext.forward("/MyJSFPage.faces") or requestDispatcher.forward("/MyJSFPage.faces") and the behavior would be the same. On the other hand if you want the url to change to the url of the new page in the browser, you could use response.sendRedirect("...") which can redirect to any page on any server (any url really). The difference is that this sends a response to the browser that sends back an immediate request to the url that you wanted to redirect to. This is slower, but may be the behavior that you need in some cases.
Monday, February 25, 2008
The cost effective way to develop web applications using Java.
- User friendly environment that is similar to ASP.Net
- Low or no cost to develop and deploy
- Flexible deployment options
- Use standard and frameworks where possible
- MVC or other separation of presentation code from business logic. In short Multi-tier architecture
- It supports deployment multiple Java Application servers
- Sun as all but decided that there will not be a next version of Java Studio Creator (pending out cry from community), and has pushed technology out to NetBeans 6.0
- Supports J2EE and Java 5 EE platform.
- JavaServer Faces built in gives an IDE and framework much like ASP.Net.
- Keeps pace with Java releases and technology changes
- Drag and Drop or code by hand developement
- FREE and OpenSource and Open Standards
- IDE and our applications are platform independent.
- Extensible IDE.
- Is to be included in future J2EE standard.
- Can be used in same project as Struts (MVC defacto standard, but not an official standard)
- Component based framework that encourages reuse between applications
ASP.Net and NetBeans JavaServer Faces (JSF) comparison from a .Net Developers perspective
Wednesday, December 19, 2007
Fixing Derby Driver error in NetBeans 6.0
Wednesday, September 12, 2007
How to optimize HP OpenView Service Desk web-api calls
Monday, August 6, 2007
Converting String to / from Date using Custom Formatting
Thursday, July 12, 2007
HP Open View Service Desk web-api maybe long, but isn't Long
Tuesday, February 27, 2007
Java Application Server start and stop manually
Starting the Java Application Server that comes with Java Studio Enterprise 8 by running the start-domain is not recommended due to parameters that are expected by the batch file. Consequently the batch file hangs.
To properly start the Java Application Server, open a command prompt and type:
Asadmin start-domain
To properly stop the Java Application Server, open a command prompt and type:
Asadmin stop-domain
Tuesday, January 16, 2007
Java Web Service Exception Handling
This assumes that you are using JAX-RPC which uses SOAP 1.1 to implement a web service, and that the web service is being consumed by .Net (1.1 or 2.0). If you are using WS 2.0 there are some different options.
While it is possible to just throw an plain old Exception in your java web service, it will show up your .Net client as a exception. The problem is determining what exception you have catch once you get it. In this situation we need a code that can be used in the client to identify the exception without try to rely on the message of the exception since this is typically semi user-friendly text. Exception class doesn’t have the concept of a code to identify the exception. The good news is SOAPFaultException has the concept of a code and it also allows you to attach any other data that may be useful.
Creating a SOAPFaultException can be a little messy, so I recommend created a convenience method to encapsulate this. In case this isn’t clear, this goes in your java web service.
// Creates and returns a SOAPFaultException. Throws one if there is an error creating
// Should be Client or Server
// If it is Client then message should NOT be resent without change
// i.e. Server.Fault or Client.Fault
public SOAPFaultException NewException(String faultType, String errorCode, String errorMessage, String webServiceOperationName) throws SOAPException
{
// The faultcode element provides an algorithmic mechanism for identifying the fault.
//SOAP defines a small set of SOAP fault codes covering basic SOAP faults.
QName faultCode = new QName("http://FrontLineWebService/" + webServiceOperationName, faultType + "." + errorCode);
// The faultstring provides a human-readable description of the SOAP fault and is not intended for algorithmic processing.
String faultString = errorMessage;
// The faultactor element provides information about which SOAP node on the SOAP message path caused the fault to happen.
//It indicates the source of the fault.
String faultActor = "http://FrontLineWebService/" + webServiceOperationName;
// The detail element is intended for carrying application specific error information related to the SOAP Body.
Detail faultDetail = SOAPFactory.newInstance().createDetail();
// Define what the body of the email should be in terms of XML. You can put whatever data you want here
faultDetail.addChildElement("ErrorMessage").addTextNode(errorMessage);
faultDetail.addChildElement("ErrorCode").addTextNode(errorCode);
// for more info on params: see http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383507
throw new SOAPFaultException(faultCode, faultString, faultActor, faultDetail);
}
Here is an example of how you would throw the SOAPFaultException in your web service.
public void testMethod() throws Exception, SOAPFaultException, java.rmi.RemoteException
{
throw NewException("Server.Fault", "TEST_CODE", "This is only a test description in English", "testMethod");
}
Now that you can easily throw a SOAPFaultException (SoapException in .Net), you are all set. Here is an example of catching it in your .Net client.
using System.Web.Services.Protocols;
...
try
{
MyWS ws = new MyWS();
ws.testMethod(new testMethod());
}
catch (SoapException ex)
{
if (ex.Code.Name == "Server.Fault.TEST_CODE")
{
// do stuff here
}
}
Tuesday, December 12, 2006
Web.xml to configure your Java Web Service
This blog describes how to configure your Java Web Service. Specifically, how to initialize your Java Web Service. In this article I assume you have used Sun Java Studio Enterprise 8 to create your RPC based web service.
Add the following lines to the top of you web service class. Typically this class ends in Impl. Your web service class needs to implement ServiceLifecycle. The example below shows how to read the init param called MyParam that is in web.xml.
import javax.xml.rpc.server.*;
import javax.xml.rpc.*;
public class MyDemoWSImpl implements MyDemoWSSEI, ServiceLifecycle {
// store the servletContext here since we can only get it when the applet starts up.
private ServletContext servletContext;
// Required by ServiceLifecycle interface
// This is only called once when the web service is started.
// This is NOT called everytime a web method is called
public void init(Object context) throws ServiceException
{
// get the servlet context
// This is where the General context parameters (aka init parameters) of the web.xml are stored.
ServletEndpointContext soapContext = (ServletEndpointContext) context;
servletContext = soapContext.getServletContext();
}
// Required by ServiceLifecycle interface
public void destroy()
{
}
public String MyParam() throws Exception
{
return GetInitParam("MyParam");
}
}
To add and specify the value for MyParam in web.xml you need to find you web.wml file. It is typically in the Web Pages\Web-INF\web.xml path if you are using BluePrints type project in Sun Java Studio Enterprise 8. You can type the entry in web.xml as shown below or you can just double click the web.xml file and use the Sun Java Studio Enterprise 8 editor. The editor has tabs. Click on the General tab if it is not already selected. Expand the Context Parameters section, then click the Add button. Type in MyParam as the Param Name, some value as Param Value, and Description is a description of what the param is or what it is for (whatever you want to put there, it is just for documentation purposes).
Here is web.xml
<?xml version="1.0" encoding="UTF-8"?>
<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">
<context-param>
<description>MyParam description for documentation</description>
<param-name>MyParam</param-name>
<param-value>the value of MyParam</param-value>
</context-param>
<servlet>
<servlet-name>WSServlet_MyDemoWS</servlet-name>
<servlet-class>philips.MyDemoWSImpl</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WSServlet_MyDemoWS</servlet-name>
<url-pattern>/MyDemoWS</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>