Archive for the ‘java ee’ Category

How to use datepicker in struts 1

Monday, February 22nd, 2010

I spend a lot of time to find out the solution how to use datepicker in struts 1. I spend a lot of hours googling around but I did not find any useful information. I have already decided to move to struts 2 where a datepicker functionality is a very simple task. Fortunatelly I found the solution at the end.

SOLUTION:
I am using Struts 1.3.8. The Struts tag has no name attribute although the javascript needs the attribute name as the first parameter.

<html:text name="StrutsForm" property="formattedDate" size="11" maxlength="11"></html:text>
<script language="JavaScript">
new tcal ({
// form name
'formname': 'StrutsForm',
// input name
'controlname': 'formattedDate'
});
</script>

SEVERE: StandardServer.await: create[8005]: java.net.BindException: Address already in use: JVM_Bind

Thursday, October 22nd, 2009

I got the following error when I try to start tomcat:

SEVERE: StandardServer.await: create[8005]:
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:363)
at org.apache.catalina.startup.Catalina.await(Catalina.java:616)
at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

I am also running Netbeans and Glassfish at the same time.

First I tried to modify default tomcat port:

Modify C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml

It did not help. I found using netstat -abv command also gives you a detailed list of programs using ports. Note: this command takes a long time.

I have found occupied ports and modified them.

<Server port="8098" shutdown="SHUTDOWN">
<Connector port="8099" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<Connector port="8097"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

Problems with java ee tutorial 5

Sunday, September 20th, 2009

Below is a list of problems that I faced while I was testing java EE tutorial 5. I have found some solutions using google, and some of then by myself.

Problem 1:

Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
Error Code: 0
Call: SQLCall(SELECT BOOKID, PRICE, DESCRIPTION, FIRSTNAME, TITLE, CALENDAR_YEAR, SURNAME, INVENTORY, ONSALE FROM WEB_BOOKSTORE_BOOKS WHERE (BOOKID = ?))
Query: ReadObjectQuery(com.sun.bookstore.database.Book)

What I have done: Modify C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\bp-project\app-server.properties. I modified javaee.home value from c:\\glassfish-v3 to C:\\Program Files\\glassfish-v2.1.

cd C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\web\bookstore1

ant create-tables

You will also need to ensure that the passwordfile is present and contains AS_ADMIN_PASSWORD.

Create C:/Temp/javaee-5-doc-tutorial-1.0_05/javaeetutorial5/examples/bp-project/password.txt and add the following line into a password.txt file:

AS_ADMIN_PASSWORD=adminadmin

Modify C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\bp-project\app-server.properties

javaee.server.passwordfile=C:\\Temp\\javaee-5-doc-tutorial-1.0_05\\javaeetutorial5\\examples\\bp-project\\password.txt

Define JAVA_HOME

Solution: Copy C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\bp-project\build.properties.sample to C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\bp-project\build.properties

Modify:

javaee.tutorial.home=C:\\Temp\\javaee-5-doc-tutorial-1.0_05\\javaeetutorial5

javaee.home=C:\\Program Files\\glassfish-v2.1

cd C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\web\bookstore1

ant create-tables

Problem 2: I got the following error when I tried to run bookstore1 example

package javax.persistence does not exist

The problem occured because bookstore1 example is using library from bookstore/dist/bookstore.jar. The bookstore.jar does not exists when the bookstore1 example is used the first time. Right click on the project bookstore1 and select “Open Required Projects”. Read more at:
http://www.mail-archive.com/java-ee-j2ee-programming-with-passion@googlegroups.com/msg00651.html

Problem 3: I could not create database tables from the example.
C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\web\bookstore1>ant  create-tables
Buildfile: build.xml
-pre-init:
init:
check:
tools:
start-db:
BUILD FAILED
C:\Temp\javaee-5-doc-tutorial-1.0_05\javaeetutorial5\examples\bp-project\app-ser
ver-ant.xml:142: Execute failed: java.io.IOException: Cannot run program “\bin\a
sadmin.bat”: CreateProcess error=3, Path not found

SOLUTION: Modify ..\javaeetutorial5\examples\bp-project\build.properties
Define path for parameter javaee.home (javaee.home=C:/Program Files/glassfish-v3-prelude)