Problem with SimpleDateFormat (CommandLine vs WebApp)
Hello Friends,
I have a strange problem. Not sure what is the mistake from my side. I have simple class that returns formatted date based on TimeZone. It gives me different result if run on command line vs when used in web app. Below is the code & other information.
import java.util.*;
import java.text.*;
public class Test {
public static String getDateFormatted(String tZone) {
DateFormat dfm = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss z");
dfm.setTimeZone(TimeZone.getTimeZone(tZone));
return dfm.format(new Date());
public static void main(String ar[]) {
System.out.println(getDateFormatted(ar[0]));
Output From Command Prompt
java Test PST
06-October-2008 20:37:01 PDT
Output From webapp running on Weblogic Server Version 10.0
06-October-2008 23:37:04 GMT-04:00
Java version from my command prompt
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)
To confirm if this problem is due to JRockit that is used as default for Weblogic, I changed Java Home in setDomainEnv.cmd to Sun JDK. But still no luck.
set BEA_JAVA_HOME=C:\bea\jrockit_150_11
set SUN_JAVA_HOME=C:\bea\jdk150_11
if "%JAVA_VENDOR%"=="BEA" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
if "%JAVA_VENDOR%"=="Sun" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
set JAVA_VENDOR=Sun
set JAVA_HOME=C:\bea\jdk150_11
Thanks & Appreciate any suggestions
how are you getting the tZone in web application?
are you taking it from the request?
in that case the timezone will be according to the settings in the browser.
Similar Messages
-
Problem with SimpleDateFormat.parse()
Hello
I have a problem with the parse-function in SimpleDateFormat.
When i try to parse the date Fri Jul 15 17:23:41 2005 with this pattern EEE MMM d HH:mm:ss yyyy i get the exception java.text.ParseException: Unparseable date: "Fri Jul 15 17:23:41 2005".
This is my code:
SimpleDateFormat df=new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
try {
df.parse(strDate);
} catch (ParseException e) {
e.printStackTrace();
}Can someone explain me what i did wrong?
Thanks
MatthiasSince your name is "Matthias" it is possible that your locale is one that does not use the English language. If that is the case then your problem is that "Fri" or "Jul" are not correct abbreviations in your language.
Easiest way to test this idea is to format a date (such as now) using that SimpleDateFormat object and see what the output looks like. -
Hi all,
I would like to parse a time (00:00:00) in String format into a Date obj. I am using the following code to achieve it. however, the result come out is not what i expect.
String fromTimeStr = "00:00:00";
TimeZone sg = TimeZone.getTimeZone("Asia/Singapore");
System.out.println("Timezone "+sg);
SimpleDateFormat DF = new SimpleDateFormat("HH:mm:ss");
DF.setTimeZone(sg);
Date time = DF.parse(fromTimeStr);
System.out.println("DAte time"+ time);the output is as followed:
Timezone sun.util.calendar.ZoneInfo[id="Asia/Singapore",offset=28800000,dstSavings=0,useDaylight=false,transitions=8,lastRule=null]
DAte timeThu Jan 01 00:30:00 GMT+08:00 1970
From what i know, the timezone of Singapore is fallen within the GMT+8 zone; thus the result should be Jan 01 00:00:00 GMT+08:00 1970
My system timezone is "Kuala Lumpur\Singapore GMT+8".
Could someone enlighten me what there is 30 minutes extra from the output.
Thanksjnaish wrote:
This is basically what I'm doing:
package test;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormatError
private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
private Date dateOfBirth;
public static void main(String[] args)
DateFormatError x = new DateFormatError();
x.run();
public void run()
String dob = "10/06/1989";
try
dateOfBirth = sdf.parse(dob);
catch (Exception e)
sdf.format(dateOfBirth);
System.out.println(dateOfBirth.toString());
}Edited by: jnaish on Feb 4, 2009 12:07 PMHey jnaish, thanks for the SSCCE, but your problem is probably already resolved after phdk's post. Just a small side note: never "swallow exceptions". Never ever! To "swallow an exception" is this:
try {
// something that may throw an exception
} catch(AnException e) {
// do nothing with it: ie, swallow it
}because whenever something goes wrong, you will not notice it since nothing is even printed to the screen: this makes debugging your code very hard! Always at least print the stack trace:
try {
// something that may throw an exception
} catch(AnException e) {
e.printStackTrace();
}so you will see some helpful message on your screen when something goes wrong.
Good luck! -
Problem with creating a new webapp
Hi All,
i wrote a web app using tomcat as a web server, servlet and jsp container.
and i would like to deploy my app to weblogic5.1.
i created a directory D:\weblogic\MyAppName and placed my app file in it.
i have created an entry for my web app in weblogic.properties:
weblogic.httpd.webApp.WebBcc=MyAppName
this works fine.
the problem is that my context path is more complicated : WebBcc/EN
and it is hard coded in all my jsp files.
so i tried this:
weblogic.httpd.webApp.WebBcc/EN=MyAppName
this end up in file not found!!
is there a way to specify a context name that contains "/" ???
thanks in advance
Yaron.I don't see any information within the specification or documentation which
mentions conventions pertaining to the context name. I tried with an
exploded and war format, and the inclusion of "/" in the context name always
results in a 404 error. I don't think its possible and is probably related
to request path elements.
Patrick
"Jacobson Yaron" <[email protected]> wrote in message
news:[email protected]..
Hi All,
i wrote a web app using tomcat as a web server, servlet and jsp container.
and i would like to deploy my app to weblogic5.1.
i created a directory D:\weblogic\MyAppName and placed my app file in it.
i have created an entry for my web app in weblogic.properties:
weblogic.httpd.webApp.WebBcc=MyAppName
this works fine.
the problem is that my context path is more complicated : WebBcc/EN
and it is hard coded in all my jsp files.
so i tried this:
weblogic.httpd.webApp.WebBcc/EN=MyAppName
this end up in file not found!!
is there a way to specify a context name that contains "/" ???
thanks in advance
Yaron. -
Strange problem with SimpleDateFormat.parse method
I got something strange with this method.
String pattern = "yyyy/MM/dd";
String mydate = "2007/00/10";
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
Date newdate = formatter.parse(mydate);
I get "2006/12/10"
is this correct.dongyisu wrote:
and there no exception get thrown outYes it does. I ran this:
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormatTest
public static final String DEFAULT_DATE_FORMAT = "yyyy/MM/dd";
public static void main(String[] args)
DateFormat formatter = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
formatter.setLenient(false);
for (int i = 0; i < args.length; ++i)
try
Date date = formatter.parse(args);
System.out.println("input: " + args[i] + " date: " + date);
catch (ParseException e)
System.err.println(args[i] + " is not a valid date");
and got this when I input "2007/00/10":
com.intellij.rt.execution.application.AppMain DateFormatTest 2007/00/10
2007/00/10 is not a valid date
Process finished with exit code 0% -
New problems with simpledateformat
sorry guys to my previous post i had solved the issue of formatting my date format..
but i have a new problem now is that when i enter the 13 mnth 2006 simpledateformat auto helped me rectify to jan of 2007.. and i look through the simpledateformat class it does not have any methods to help me check the validity of the date i am inputting.. is there any other class i have to use to check the validity??hmm SimpleDateFormat doesn't have a set lenient
method only calendar has that...Scroll down some more. -
I have a problem with JDBC Realm in Tomcat/Oracle/Win XP
I have a problem with JDBC Realm in Tomcat.
I have attached my server.xml file located in the
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
The Problem is that when I login I get the user name and password prompt but it does not resolve.
When I enter in the tomcat-users.xml password with memory realm uncommented it works fine.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\tomcat-users.xml
Is there a cache or something I need to reset for the JDBC Realm to work?
I have attached my tables and contents as well...
Did I miss something????
Thanks
Phil
server.xml
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
</GlobalNamingResources>
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Catalina">
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector
port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
<!--
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
connectionName="testName" connectionPassword="testPass"
userTable="users"
userNameCol="user_name"
userCredCol="user_pass"
userRoleTable="user_roles"
roleNameCol="role_name" />
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
Tables
create table users
user_name varchar(15) not null primary key,
user_pass varchar(15) not null
create table roles
role_name varchar(15) not null primary key
create table user_roles
user_name varchar(15) not null,
role_name varchar(15) not null,
primary key( user_name, role_name )
select * from users;
----------------------+
| user_name | user_pass |
----------------------+
| tomcat | tomcat |
| user1 | tomcat |
| user2 | tomcat |
| user3 | tomcat |
----------------------+
select * from roles;
| role_name |
| tomcat |
| role1 |
select * from user_roles;
-----------------------+
| role_name | user_name |
-----------------------+
| tomcat | user1 |
| role1 | user2 |
| tomcat | tomcat |
| role1 | tomcat |
-----------------------+Jan 2, 2008 11:49:35 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 2, 2008 11:49:35 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 734 ms
Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.9
Jan 2, 2008 11:49:35 AM org.apache.catalina.realm.JDBCRealm start
SEVERE: Exception opening database connection
java.sql.SQLException: oracle.jdbc.driver.OracleDriver
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:684)
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:758)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1004)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Jan 2, 2008 11:49:36 AM org.apache.catalina.core.StandardContext resourcesStart -
Problem with Configuring Tomcat for running jsp web applications..Plz HELP
I am using Tomcat 5.5 and Jdk 1.5.0_12 and Oracle 10g. I am using jdbc-odbc bridge connection
to connect to the database. I have placed my project folder called
tdm under the webapps folder in Tomcat. This 'tdm' folder consists of
a collection of html pages,jsp pages and images of my project. Also I created a
WEB-INF folderand in that I have lib folder which contains catalina-root.jar
, classes12.jar and nls_charset.jar files. And also in the WEB-INF folder I have the web.xml
file which looks like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app>
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/gdn</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
My Server.xml file in Tomcat\conf folder is as follows
<!-- Example Server Configuration File -->
<!-- Note that component elements are nested corresponding to their
parent-child relationships with each other -->
<!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port.
Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<Server port="8005" shutdown="SHUTDOWN">
<!-- Comment these entries out to disable JMX MBeans support used for the
administration web application -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="jdbc/gdn" auth="Container"
type="javax.sql.DataSource" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
url="jdbc:odbc:gdn"
username="system" password="tiger" maxActive="20" maxIdle="10"
maxWait="-1"/>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required.
Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Catalina">
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Each Connector passes requests on to the
associated "Container" (normally an Engine) for processing.
By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
You can also enable an SSL HTTP/1.1 Connector on port 8443 by
following the instructions below and uncommenting the second Connector
entry. SSL support requires the following steps (see the SSL Config
HOWTO in the Tomcat 5 documentation bundle for more detailed
instructions):
* If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
* Execute:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
with a password value of "changeit" for both the certificate and
the keystore itself.
By default, DNS lookups are enabled when a web application calls
request.getRemoteHost(). This can have an adverse impact on
performance, so you can disable it by setting the
"enableLookups" attribute to "false". When DNS lookups are disabled,
request.getRemoteHost() will return the String version of the
IP address of the remote client.
-->
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector
port="5050" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to 0 -->
<!-- Note : To use gzip compression you could set the following properties :
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
<!--
<Connector port="8443"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
<!-- See proxy documentation for more information about using this. -->
<!--
<Connector port="8082"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" acceptCount="100" connectionTimeout="20000"
proxyPort="80" disableUploadTimeout="true" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host). -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">
-->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
<!-- The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
headers and cookies that were sent, for all requests received by
this instance of Tomcat. If you care only about requests to a
particular virtual host, or a particular application, nest this
element inside the corresponding <Host> or <Context> entry instead.
For a similar mechanism that is portable to all Servlet 2.4
containers, check out the "RequestDumperFilter" Filter in the
example application (the source for this filter may be found in
"$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
Request dumping is disabled by default. Uncomment the following
element to enable it. -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- Because this Realm is here, an instance will be shared globally -->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Comment out the old realm but leave here for now in case we
need to go back quickly -->
<!--
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/authority"
connectionName="test" connectionPassword="test"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
connectionName="scott" connectionPassword="tiger"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL="jdbc:odbc:CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- Defines a cluster for this node,
By defining this element, means that every manager will be changed.
So when running a cluster, only make sure that you have webapps in there
that need to be clustered and remove the other ones.
A cluster has the following parameters:
className = the fully qualified name of the cluster class
name = a descriptive name for your cluster, can be anything
mcastAddr = the multicast address, has to be the same for all the nodes
mcastPort = the multicast port, has to be the same for all the nodes
mcastBindAddr = bind the multicast socket to a specific address
mcastTTL = the multicast TTL if you want to limit your broadcast
mcastSoTimeout = the multicast readtimeout
mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
in case of multiple ethernet cards.
auto means that address becomes
InetAddress.getLocalHost().getHostAddress()
tcpListenPort = the tcp listen port
tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
has a wakup bug in java.nio. Set to 0 for no timeout
printToScreen = true means that managers will also print to std.out
expireSessionsOnShutdown = true means that
useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
false means to replicate the session after each request.
false means that replication would work for the following piece of code: (only for SimpleTcpReplicationManager)
<%
HashMap map = (HashMap)session.getAttribute("map");
map.put("key","value");
%>
replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
* Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
* Synchronous means that the thread that executes the request, is also the
thread the replicates the data to the other nodes, and will not return until all
nodes have received the information.
* Asynchronous means that there is a specific 'sender' thread for each cluster node,
so the request thread will queue the replication request into a "smart" queue,
and then return to the client.
The "smart" queue is a queue where when a session is added to the queue, and the same session
already exists in the queue from a previous request, that session will be replaced
in the queue instead of replicating two requests. This almost never happens, unless there is a
large network delay.
-->
<!--
When configuring for clustering, you also add in a valve to catch all the requests
coming in, at the end of the request, the session may or may not be replicated.
A session is replicated if and only if all the conditions are met:
1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
2. a session exists (has been created)
3. the request is not trapped by the "filter" attribute
The filter attribute is to filter out requests that could not modify the session,
hence we don't replicate the session after the end of this request.
The filter is negative, ie, anything you put in the filter, you mean to filter out,
ie, no replication will be done on requests that match one of the filters.
The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
ending with .gif and .js are intercepted.
The deployer element can be used to deploy apps cluster wide.
Currently the deployment only deploys/undeploys to working members in the cluster
so no WARs are copied upons startup of a broken node.
The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
When a new war file is added the war gets deployed to the local instance,
and then deployed to the other instances in the cluster.
When a war file is deleted from the watchDir the war is undeployed locally
and cluster wide
-->
<!--
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="4001"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"
ackTimeout="15000"/>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
<Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
</Cluster>
-->
<!-- Normally, users must authenticate themselves to each web app
individually. Uncomment the following entry if you would like
a user to be authenticated the first time they encounter a
resource protected by a security constraint, and then have that
user identity maintained across all web applications contained
in this virtual host. -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
-->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<!-- Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
This access log implementation is optimized for maximum performance,
but is hardcoded to support only the "common" and "combined" patterns.
-->
<!--
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<Context path="/tdm" docBase="tdm" debug="0" reloadable="true" />
</Host>
</Engine>
</Service>
</Server>
I have set the context path to /tdm in the server.xml file. Should this be placed in context.xml?
My first page in the project is called Homepage.html. To start my project I give http://localhost:5050/tdm/homepage.html
in a browser. Here I accept a username and password from the user and then do the validation in
a valid.jsp file, where I connect to the database and check and use jsp:forward to go to next pages
accordingly. However when I enter the username and password and click Go in the homepage, nothing is
displayed on the next page. The URL in the browser says valid.jsp but a blank screen appears.
WHY DOES IT HAPPEN SO? DOES IT MEAN THAT TOMCAT IS NOT RECOGNIZING JAVA IN MY SYSTEM OR IS IT A PROBLEM
WITH THE DATABASE CONNECTION OR SOMETHING ELSE? I FEEL THAT TOMCAT IS NOT EXECUTING JSP COMMANDS?
IS IT POSSIBLE?WHY WILL THIS HAPPEN?
I set the JAVA_HOME and CATALINA_HOME environment to the jdk and tomcat folders resp.
Is there any other thing that I need to set in classpath? Should I have my project as a
WAR file in the webapps of TOMCAT or just a folder i.e. directory structure will fine?I am using Tomcat 5.5 and Jdk 1.5.0_12 and Oracle 10g. I am using jdbc-odbc bridge connection
to connect to the database. I have placed my project folder called
tdm under the webapps folder in Tomcat. This 'tdm' folder consists of
a collection of html pages,jsp pages and images of my project. Also I created a
WEB-INF folderand in that I have lib folder which contains catalina-root.jar
, classes12.jar and nls_charset.jar files. And also in the WEB-INF folder I have the web.xml
file which looks like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app>
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/gdn</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
My Server.xml file in Tomcat\conf folder is as follows
<!-- Example Server Configuration File -->
<!-- Note that component elements are nested corresponding to their
parent-child relationships with each other -->
<!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port.
Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<Server port="8005" shutdown="SHUTDOWN">
<!-- Comment these entries out to disable JMX MBeans support used for the
administration web application -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="jdbc/gdn" auth="Container"
type="javax.sql.DataSource" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
url="jdbc:odbc:gdn"
username="system" password="tiger" maxActive="20" maxIdle="10"
maxWait="-1"/>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required.
Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Catalina">
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Each Connector passes requests on to the
associated "Container" (normally an Engine) for processing.
By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
You can also enable an SSL HTTP/1.1 Connector on port 8443 by
following the instructions below and uncommenting the second Connector
entry. SSL support requires the following steps (see the SSL Config
HOWTO in the Tomcat 5 documentation bundle for more detailed
instructions):
* If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
* Execute:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix)
with a password value of "changeit" for both the certificate and
the keystore itself.
By default, DNS lookups are enabled when a web application calls
request.getRemoteHost(). This can have an adverse impact on
performance, so you can disable it by setting the
"enableLookups" attribute to "false". When DNS lookups are disabled,
request.getRemoteHost() will return the String version of the
IP address of the remote client.
-->
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector
port="5050" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to 0 -->
<!-- Note : To use gzip compression you could set the following properties :
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
<!--
<Connector port="8443"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
<!-- See proxy documentation for more information about using this. -->
<!--
<Connector port="8082"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" acceptCount="100" connectionTimeout="20000"
proxyPort="80" disableUploadTimeout="true" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host). -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">
-->
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost">
<!-- The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
headers and cookies that were sent, for all requests received by
this instance of Tomcat. If you care only about requests to a
particular virtual host, or a particular application, nest this
element inside the corresponding <Host> or <Context> entry instead.
For a similar mechanism that is portable to all Servlet 2.4
containers, check out the "RequestDumperFilter" Filter in the
example application (the source for this filter may be found in
"$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
Request dumping is disabled by default. Uncomment the following
element to enable it. -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<!-- Because this Realm is here, an instance will be shared globally -->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Comment out the old realm but leave here for now in case we
need to go back quickly -->
<!--
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/authority"
connectionName="test" connectionPassword="test"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
connectionName="scott" connectionPassword="tiger"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL="jdbc:odbc:CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- Defines a cluster for this node,
By defining this element, means that every manager will be changed.
So when running a cluster, only make sure that you have webapps in there
that need to be clustered and remove the other ones.
A cluster has the following parameters:
className = the fully qualified name of the cluster class
name = a descriptive name for your cluster, can be anything
mcastAddr = the multicast address, has to be the same for all the nodes
mcastPort = the multicast port, has to be the same for all the nodes
mcastBindAddr = bind the multicast socket to a specific address
mcastTTL = the multicast TTL if you want to limit your broadcast
mcastSoTimeout = the multicast readtimeout
mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat
mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received
tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
in case of multiple ethernet cards.
auto means that address becomes
InetAddress.getLocalHost().getHostAddress()
tcpListenPort = the tcp listen port
tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
has a wakup bug in java.nio. Set to 0 for no timeout
printToScreen = true means that managers will also print to std.out
expireSessionsOnShutdown = true means that
useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
false means to replicate the session after each request.
false means that replication would work for the following piece of code: (only for SimpleTcpReplicationManager)
<%
HashMap map = (HashMap)session.getAttribute("map");
map.put("key","value");
%>
replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
* Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
* Synchronous means that the thread that executes the request, is also the
thread the replicates the data to the other nodes, and will not return until all
nodes have received the information.
* Asynchronous means that there is a specific 'sender' thread for each cluster node,
so the request thread will queue the replication request into a "smart" queue,
and then return to the client.
The "smart" queue is a queue where when a session is added to the queue, and the same session
already exists in the queue from a previous request, that session will be replaced
in the queue instead of replicating two requests. This almost never happens, unless there is a
large network delay.
-->
<!--
When configuring for clustering, you also add in a valve to catch all the requests
coming in, at the end of the request, the session may or may not be replicated.
A session is replicated if and only if all the conditions are met:
1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
2. a session exists (has been created)
3. the request is not trapped by the "filter" attribute
The filter attribute is to filter out requests that could not modify the session,
hence we don't replicate the session after the end of this request.
The filter is negative, ie, anything you put in the filter, you mean to filter out,
ie, no replication will be done on requests that match one of the filters.
The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
ending with .gif and .js are intercepted.
The deployer element can be used to deploy apps cluster wide.
Currently the deployment only deploys/undeploys to working members in the cluster
so no WARs are copied upons startup of a broken node.
The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
When a new war file is added the war gets deployed to the local instance,
and then deployed to the other instances in the cluster.
When a war file is deleted from the watchDir the war is undeployed locally
and cluster wide
-->
<!--
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="4001"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"
ackTimeout="15000"/>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
<Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
</Cluster>
-->
<!-- Normally, users must authenticate themselves to each web app
individually. Uncomment the following entry if you would like
a user to be authenticated the first time they encounter a
resource protected by a security constraint, and then have that
user identity maintained across all web applications contained
in this virtual host. -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
-->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<!-- Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
This access log implementation is optimized for maximum performance,
but is hardcoded to support only the "common" and "combined" patterns.
-->
<!--
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<Context path="/tdm" docBase="tdm" debug="0" reloadable="true" />
</Host>
</Engine>
</Service>
</Server>
I have set the context path to /tdm in the server.xml file. Should this be placed in context.xml?
My first page in the project is called Homepage.html. To start my project I give http://localhost:5050/tdm/homepage.html
in a browser. Here I accept a username and password from the user and then do the validation in
a valid.jsp file, where I connect to the database and check and use jsp:forward to go to next pages
accordingly. However when I enter the username and password and click Go in the homepage, nothing is
displayed on the next page. The URL in the browser says valid.jsp but a blank screen appears.
WHY DOES IT HAPPEN SO? DOES IT MEAN THAT TOMCAT IS NOT RECOGNIZING JAVA IN MY SYSTEM OR IS IT A PROBLEM
WITH THE DATABASE CONNECTION OR SOMETHING ELSE? I FEEL THAT TOMCAT IS NOT EXECUTING JSP COMMANDS?
IS IT POSSIBLE?WHY WILL THIS HAPPEN?
I set the JAVA_HOME and CATALINA_HOME environment to the jdk and tomcat folders resp.
Is there any other thing that I need to set in classpath? Should I have my project as a
WAR file in the webapps of TOMCAT or just a folder i.e. directory structure will fine? -
Communication problem with proxy server
We have establish the configuration of an iPad to access the enterprise net, but when trying to access any webpage we get the next message: Safari can not open the page. Error:"There is a communication problem with proxy web server (HTTP)"
The access has no problems with other movile devices.
Ahy help?Hi,
I am not sure whether you have already solved the problem or not....
Do the following to deploy MobileBIService.war file on tomcat
1.Stop Tomcat Web application server.
2.Copy the file, MobileBIService.war from [Install directory]\Mobile 14\Client to the Tomcat's "Webapps" directory.
In my case, I copied the MobileBIService.war from C:\Program Files (x86)\SAP BusinessObjects\Mobile14\Client to C:\Program Files (x86)\SAP BusinessObjects\Tomcat6\webapps. ( I used BO 4.0 SP02)
3. Start Tomcat.
Restarting Tomcat would automatically deploy war file as a Web App
One folder u201CMobileBiServiceu201D will appear in webapps folder when MobileBIService.war is deployed successfully.
Hope it helps.
Regards,
Ankur -
Hello,
I am having a strange problem with Tomcat and axis. I have a webservice that uses axis2 for wsdl2java class generation. When I compile my project in maven a Test is performed. During the test a glassfish server is established and the project is deployed -everything work great with the expected results. However when I try to deploy the webservice on tomcat it has some problems.
At first I tried to call axis code in a POST method that takes a MultiPart message. The code is as below:
*@Path("identifyWavestream")*
*@POST*
*@Consumes(MediaType.MULTIPART_FORM_DATA)*
*@Produces(MediaType.APPLICATION_XML)*
*public String multipartTest(com.sun.jersey.multipart.MultiPart multiPart) throws Exception {*
*// get first body part (index 0)*
*//tomcat shows that the first error is here (line 122 is the nest one with bodypart)*
BodyPart bp = multiPart.getBodyParts().get(0);
BodyPartEntity bodyPartEntity = (BodyPartEntity) bp.getEntity();
InputStream stream = bodyPartEntity.getInputStream();
*//the rest of the code either saves the incoming file or implements the wsdl2java axis interface - neither works.*
And the tomcat error is:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.util.ArrayList.RangeCheck(Unknown Source)
java.util.ArrayList.get(Unknown Source)
com.webserv.rest.resources.SearchResource.test.multipartTest(SearchResource.java:122)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:138)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:124)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:555)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:514)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:505)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:359)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
It was strange to me since this simple approach of handling a Multipart method worked for me earlier. Then I decided skip the handling of multipart method and just call the axis code. But the results also caused an error. I then tried to call the axis code in a simple @GET method (to cross out any issues regarding the multipart) and the result where the same. Again everything works on the maven- glassfish test. In this case the tomcat error is the following:
javax.servlet.ServletException: java.lang.NoSuchMethodError: org.apache.commons.httpclient.HttpConnectionManager.getParams()Lorg/apache/commons/httpclient/params/HttpConnectionManagerParams;
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:361)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
com.sun.jersey.api.container.MappableContainerException: java.lang.NoSuchMethodError: org.apache.commons.httpclient.HttpConnectionManager.getParams()Lorg/apache/commons/httpclient/params/HttpConnectionManagerParams;
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:74)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:124)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:555)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:514)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:505)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:359)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.lang.NoSuchMethodError: org.apache.commons.httpclient.HttpConnectionManager.getParams()Lorg/apache/commons/httpclient/params/HttpConnectionManagerParams;
org.apache.axis2.transport.http.AbstractHTTPSender.initializeTimeouts(AbstractHTTPSender.java:454)
org.apache.axis2.transport.http.AbstractHTTPSender.getHttpClient(AbstractHTTPSender.java:514)
org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:156)
org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371)
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209)
org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
com.webserv.rest.webapp.IntSoapServiceStub.getServerData(IntSoapServiceStub.java:2447)
com.webserv..rest.resources.AIntSoapImpl.getServerData(AIntSoapImpl.java:112)
com.webserv..rest.resources.SearchResource.test.pingTest(SearchResource.java:167)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:138)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:124)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:555)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:514)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:505)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:359)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
I think it is also a good ide to post the pom.xml file :
Edited by: 803864 on 2010-10-21 00:30I think it is also a good ide to post the pom.xml file:
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<modelVersion>4.0.0</modelVersion>+
+<groupId>com.myProjects</groupId>+
+<artifactId>audioid-rest-interface</artifactId>+
+<packaging>war</packaging>+
+<name>AudioID Rest Interface</name>+
+<version>0.1</version>+
+<dependencies>+
+<!--+
+<dependency>+
+<groupId>com.sun.tools.xjc.maven2</groupId>+
+<artifactId>maven-jaxb-plugin</artifactId>+
+<version>1.1</version>+
+<scope>test</scope>+
+</dependency>+
+<dependency>+
+<groupId>com.sun.jersey</groupId>+
+<artifactId>jersey-client</artifactId>+
+<version>1.0.1</version>+
+</dependency>+
+<dependency>+
+<groupId>com.sun.jersey.contribs</groupId>+
+<artifactId>jersey-multipart</artifactId>+
+<version>1.0.1</version>+
+</dependency>+
+<dependency>+
+<groupId>com.sun.grizzly</groupId>+
+<artifactId>grizzly-servlet-webserver</artifactId>+
+<version>1.9.0</version>+
+<scope>test</scope>+
+</dependency>-->+
+<dependency>+
+<groupId>com.sun.jersey.contribs</groupId>+
+<artifactId>jersey-multipart</artifactId>+
+<version>1.0.1</version>+
+</dependency>+
+<dependency>+
+<groupId>com.sun.jersey</groupId>+
+<artifactId>jersey-client</artifactId>+
+<version>1.0.1</version>+
+</dependency>+
+<dependency>+
+<groupId>com.sun.jersey</groupId>+
+<artifactId>jersey-bundle</artifactId>+
+<version>1.0.1</version>+
+</dependency>+
+<dependency>+
+<groupId>commons-logging</groupId>+
+<artifactId>commons-logging</artifactId>+
+<version>1.0.4</version>+
+</dependency>+
+<dependency>+
+<groupId>commons-collections</groupId>+
+<artifactId>commons-collections</artifactId>+
+<version>3.1</version>+
+</dependency>+
+<dependency>+
+<groupId>org.slf4j</groupId>+
+<artifactId>slf4j-log4j12</artifactId>+
+<version>1.5.6</version>+
+</dependency>+
+<dependency>+
+<groupId>junit</groupId>+
+<artifactId>junit</artifactId>+
+<version>3.8.2</version>+
+<scope>test</scope>+
+</dependency>+
+<dependency>+
+<groupId>org.glassfish.distributions</groupId>+
+<artifactId>web-all</artifactId>+
+<version>10.0-build-20080430</version>+
+<scope>test</scope>+
+</dependency>+
+<dependency>+
+<groupId>org.glassfish.embedded</groupId>+
+<artifactId>gf-embedded-api</artifactId>+
+<version>1.0-alpha-4</version>+
+<scope>test</scope>+
+</dependency>+
+<dependency>+
+<groupId>com.sun.jersey</groupId>+
+<artifactId>jersey-server</artifactId>+
+<version>1.0.3.1</version>+
+<scope>test</scope>+
+</dependency>+
+<dependency>+
+<groupId>com.sun.jersey.contribs</groupId>+
+<artifactId>maven-wadl-plugin</artifactId>+
+<version>1.0.3.1</version>+
+</dependency>+
+<dependency>+
+<groupId>org.hibernate</groupId>+
+<artifactId>hibernate</artifactId>+
+<version>3.2.5.ga</version>+
+<exclusions>+
+<exclusion>+
+<groupId>javax.transaction</groupId>+
+<artifactId>jta</artifactId>+
+</exclusion>+
+<exclusion>+
+<groupId>cglib</groupId>+
+<artifactId>cglib</artifactId>+
+</exclusion>+
+</exclusions>+
+</dependency>+
+<dependency>+
+<groupId>org.apache.axis2</groupId>+
+<artifactId>axis2</artifactId>+
+<version>1.4.1</version>+
+</dependency>+
+<!-- <dependency> -->+
+<dependency>+
+<groupId>org.apache.axis2</groupId>+
+<artifactId>axis2-aar-maven-plugin</artifactId>+
+<version>1.4.1</version>+
+<scope>test</scope>+
+</dependency>+
+<dependency>+
+<groupId>org.apache.axis2</groupId>+
+<artifactId>axis2-java2wsdl</artifactId>+
+<version>1.4.1</version>+
+<scope>test</scope>+
+</dependency>+
+<dependency>+
+<groupId>org.apache.axis2</groupId>+
+<artifactId>axis2-xmlbeans</artifactId>+
+<version>1.4.1</version>+
+</dependency>+
+<!-- <dependency> -->+
+<dependency>+
+<groupId>com.sun.xml.bind</groupId>+
+<artifactId>jaxb-impl</artifactId>+
+<version>2.1.12</version>+
+</dependency>+
+<dependency>+
+<groupId>cglib</groupId>+
+<artifactId>cglib-nodep</artifactId>+
+<version>2.1_3</version>+
+</dependency>+
+</dependencies>+
+<build>+
+<finalName>audioid-rest-interface</finalName>+
+<plugins>+
+<plugin>+
+<!-- This class is just generated for wadl support!!! -->+
+<!-- Take care that folder ../music-dna-core is existing -->+
+<groupId>com.sun.tools.xjc.maven2</groupId>+
+<artifactId>maven-jaxb-plugin</artifactId>+
+<version>1.1</version>+
+<executions>+
+<execution>+
+<phase>generate-sources</phase>+
+<goals>+
+<goal>generate</goal>+
+</goals>+
+</execution>+
+</executions>+
+<configuration>+
+<generatePackage> com.webserv.wsparameters</generatePackage>+
+<schemaDirectory>../audioid-rest-interface/src/main/resources+
+</schemaDirectory>+
+<includeSchemas>+
+<includeSchema>**/*.xsd</includeSchema>+
+</includeSchemas>+
+<extension>true</extension>+
+<strict>false</strict>+
+<verbose>false</verbose>+
+</configuration>+
+</plugin>+
+<plugin>+
+<groupId>org.apache.maven.plugins</groupId>+
+<artifactId>maven-javadoc-plugin</artifactId>+
+<!-- <version>2.6</version> -->+
+<executions>+
+<execution>+
+<goals>+
+<goal>javadoc</goal>+
+</goals>+
+<phase>compile</phase>+
+</execution>+
+</executions>+
+<configuration>+
+<encoding>UTF-8</encoding>+
+<verbose>false</verbose>+
+<show>public</show>+
+<subpackages> com.webserv.rest.rest.resources: com.webserv.rest.rest.commons: com.webserv.wsparameters+
+</subpackages>+
+<doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>+
+<docletPath>${path.separator}${project.build.outputDirectory}+
+</docletPath>+
+<docletArtifacts>+
+<docletArtifact>+
+<groupId>com.sun.jersey.contribs</groupId>+
+<artifactId>wadl-resourcedoc-doclet</artifactId>+
+<version>1.0.3.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>com.sun.jersey</groupId>+
+<artifactId>jersey-server</artifactId>+
+<version>1.0.3.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>xerces</groupId>+
+<artifactId>xercesImpl</artifactId>+
+<version>2.6.1</version>+
+</docletArtifact>+
+</docletArtifacts>+
+<additionalparam>-output+
+${project.build.outputDirectory}/resourcedoc.xml</additionalparam>+
+<useStandardDocletOptions>false</useStandardDocletOptions>+
+</configuration>+
+</plugin>+
+<plugin>+
+<groupId>com.sun.jersey.contribs</groupId>+
+<artifactId>maven-wadl-plugin</artifactId>+
+<version>1.0.3.1</version>+
+<executions>+
+<execution>+
+<id>generate</id>+
+<goals>+
+<goal>generate</goal>+
+</goals>+
+<phase>compile</phase>+
+</execution>+
+</executions>+
+<configuration>+
+<wadlFile>${project.build.outputDirectory}/application.wadl+
+</wadlFile>+
+<formatWadlFile>true</formatWadlFile>+
+<baseUri>http://192.168.2.149:8080/${project.build.finalName}+
+</baseUri>+
+<packagesResourceConfig>+
+<param> com.webserv.rest.resources</param>+
+</packagesResourceConfig>+
+<wadlGenerators>+
+<wadlGeneratorDescription>+
+<className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc+
+</className>+
+<properties>+
+<property>+
+<name>applicationDocsFile</name>+
+<value>${basedir}/src/main/doc/application-doc.xml</value>+
+</property>+
+</properties>+
+</wadlGeneratorDescription>+
+<wadlGeneratorDescription>+
+<className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport+
+</className>+
+<properties>+
+<property>+
+<name>grammarsFile</name>+
+<value>${basedir}/src/main/doc/application-grammars.xml</value>+
+</property>+
+</properties>+
+</wadlGeneratorDescription>+
+<wadlGeneratorDescription>+
+<className>com.sun.jersey.server.wadl.generators.resourcedoc.WadlGeneratorResourceDocSupport+
+</className>+
+<properties>+
+<property>+
+<name>resourceDocFile</name>+
+<value>${project.build.outputDirectory}/resourcedoc.xml</value>+
+</property>+
+</properties>+
+</wadlGeneratorDescription>+
+</wadlGenerators>+
+</configuration>+
+</plugin>+
+<plugin>+
+<groupId>org.codehaus.mojo</groupId>+
+<artifactId>exec-maven-plugin</artifactId>+
+<version>1.1</version>+
+<executions>+
+<execution>+
+<goals>+
+<goal>java</goal>+
+</goals>+
+</execution>+
+</executions>+
+<configuration>+
+<mainClass>com.sun.jersey.samples.generatewadl.Main</mainClass>+
+</configuration>+
+</plugin>+
+<plugin>+
+<groupId>org.apache.maven.plugins</groupId>+
+<artifactId>maven-compiler-plugin</artifactId>+
+<inherited>true</inherited>+
+<configuration>+
+<source>1.5</source>+
+<target>1.5</target>+
+<!--+
exclude temporary types that are only needed for wadl and doc
generation
-->
+<!--+
+<excludes> <exclude>com/webserv/types/temporary/**</exclude>+
+<exclude>com/webserv/rest/commons/Examples.java</exclude>+
+</excludes>+
-->
+</configuration>+
+</plugin>+
+<plugin>+
+<groupId>org.jvnet.jaxb2.maven2</groupId>+
+<artifactId>maven-jaxb2-plugin</artifactId>+
+<executions>+
+<execution>+
+<goals>+
+<goal>generate</goal>+
+</goals>+
+</execution>+
+</executions>+
+</plugin>+
+<plugin>+
+<groupId>org.apache.axis2</groupId>+
+<artifactId>axis2-wsdl2code-maven-plugin</artifactId>+
+<version>1.4.1</version>+
+<executions>+
+<execution>+
+<id>generate reco core</id>+
+<goals>+
+<goal>wsdl2code</goal>+
+</goals>+
+<configuration>+
+<packageName>com.webserv.rest.webapp</packageName>+
+<wsdlFile>src/main/java/com/webserv/wsdl/web.wsdl</wsdlFile>+
+<databindingName>adb</databindingName>+
+</configuration>+
+</execution>+
+</executions>+
+</plugin>+
+<plugin>+
+<groupId>com.sun.tools.xjc.maven2</groupId>+
+<artifactId>maven-jaxb-plugin</artifactId>+
+<version>1.1</version>+
+<executions>+
+<execution>+
+<goals>+
+<goal>generate</goal>+
+</goals>+
+</execution>+
+</executions>+
+<configuration>+
+<generatePackage>com.webserv.wsparameters</generatePackage>+
+<schemaDirectory>src/main/xsd</schemaDirectory> <includeSchemas>+
+<includeSchema>**/*.xsd</includeSchema> </includeSchemas>+
+<extension>true</extension>+
+<strict>false</strict>+
+<verbose>true</verbose>+
+</configuration>+
+</plugin>+
+</plugins>+
+</build>+
+<profiles>+
+<profile>+
+<id>jdk-1.5</id>+
+<activation>+
+<jdk>1.5</jdk>+
+</activation>+
+<dependencies>+
+<dependency>+
+<groupId>com.sun.xml.bind</groupId>+
+<artifactId>jaxb-impl</artifactId>+
+<version>2.1.10</version>+
+</dependency>+
+</dependencies>+
+<build>+
+<plugins>+
+<plugin>+
+<groupId>org.apache.maven.plugins</groupId>+
+<artifactId>maven-javadoc-plugin</artifactId>+
+<configuration>+
+<docletArtifacts>+
+<docletArtifact>+
+<groupId>com.sun.jersey.contribs</groupId>+
+<artifactId>maven-wadl-plugin</artifactId>+
+<version>1.0.3.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>com.sun.jersey.contribs</groupId>+
+<artifactId>wadl-resourcedoc-doclet</artifactId>+
+<version>1.0.3.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>com.sun.jersey</groupId>+
+<artifactId>jersey-server</artifactId>+
+<version>1.0.3.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>xerces</groupId>+
+<artifactId>xercesImpl</artifactId>+
+<version>2.6.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>javax.xml.bind</groupId>+
+<artifactId>jaxb-api</artifactId>+
+<version>2.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>javax.xml</groupId>+
+<artifactId>jaxb-impl</artifactId>+
+<version>2.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>javax.activation</groupId>+
+<artifactId>activation</artifactId>+
+<version>1.1</version>+
+</docletArtifact>+
+<docletArtifact>+
+<groupId>javax.xml.stream</groupId>+
+<artifactId>stax-api</artifactId>+
+<version>1.0</version>+
+</docletArtifact>+
+</docletArtifacts>+
+</configuration>+
+</plugin>+
+</plugins>+
+</build>+
+</profile>+
+<profile>+
+<id>xsltproc</id>+
+<activation>+
+<file>+
+<exists>../xsltproc_win32/xsltproc.exe</exists>+
+</file>+
+</activation>+
+<build>+
+<plugins>+
+<!-- Create/generate the application.html using xsltproc -->+
+<!-- Create/generate the application.html using xsltproc -->+
+<plugin>+
+<groupId>org.codehaus.mojo</groupId>+
+<artifactId>exec-maven-plugin</artifactId>+
+<version>1.1</version>+
+<executions>+
+<execution>+
+<id>copy-docs-to-builddir</id>+
+<goals>+
+<goal>exec</goal>+
+</goals>+
+<phase>compile</phase>+
+<configuration>+
+<executable>copy</executable>+
+<commandlineArgs>src\\main\\doc\\*.* target\\classes+
+</commandlineArgs>+
+</configuration>+
+</execution>+
+<execution>+
+<id>prepare-xsltproc</id>+
+<goals>+
+<goal>exec</goal>+
+</goals>+
+<phase>package</phase>+
+<configuration>+
+<executable>copy</executable>+
+<commandlineArgs>..\\audioid-rest-interface\\src\\main\\resources\\*.xsd+
target\\classes</commandlineArgs>
+</configuration>+
+</execution>+
+<execution>+
+<id>exec-xsltproc: target/application.html</id>+
+<goals>+
+<goal>exec</goal>+
+</goals>+
+<phase>package</phase>+
+<configuration>+
+<!--<executable>xsltproc</executable>-->+
+<executable>../xsltproc_win32/xsltproc.exe</executable>+
+<commandlineArgs>-o target/application.html+
src/main/doc/wadl_documentation.xsl
target/classes/application.wadl</commandlineArgs>
+</configuration>+
+</execution>+
+</executions>+
+</plugin>+
+</plugins>+
+</build>+
+</profile>+
+</profiles>+
+<pluginRepositories>+
+<pluginRepository>+
+<id>maven2-repository.dev.java.net</id>+
+<name>Java.net Repository for Maven</name>+
+<url>http://download.java.net/maven/2/</url>+
+<layout>default</layout>+
+</pluginRepository>+
+<pluginRepository>+
+<id>maven-repository.dev.java.net</id>+
+<name>Java.net Maven 1 Repository (legacy)</name>+
+<url>http://download.java.net/maven/1</url>+
+<layout>legacy</layout>+
+</pluginRepository>+
+</pluginRepositories>+
+<repositories>+
+<repository>+
+<id>maven2-repository.dev.java.net</id>+
+<name>Java.net Repository for Maven</name>+
+<url>http://download.java.net/maven/2/</url>+
+<layout>default</layout>+
+</repository>+
+<repository>+
+<id>maven-repository.dev.java.net</id>+
+<name>Java.net Maven 1 Repository (legacy)</name>+
+<url>http://download.java.net/maven/1</url>+
+<layout>legacy</layout>+
+</repository>+
+<repository>+
+<id>glassfish-repository</id>+
+<name>Java.net Repository for Glassfish</name>+
+<url>http://download.java.net/maven/glassfish</url>+
+</repository>+
+</repositories>+
+</project>+
Can anyonr contribute? -
Problem with writing and reading using serialization
I am having a problem with writing and reading an object that has another object in it. The purpose of the class is to write a order that has multiple items in it. And there will be several orders. This is for an IB project, where one of the requirements is to utilize a hierarchical composite data structure. That is, it is "one that contains more than one element and at least one of the elements is a composite data structure. Examples are, an array or linked list of records, a record that has one field that is another record, or an array". The code is shown below:
The error produced is
java.lang.NullPointerException
at SamsonRubberIndustries.CustomerOrderDetails.createCustOrdDetailsScreen(CustomerOrderDetails.java:150)
at SamsonRubberIndustries.CustomerOrderDetails$1.run(CustomerOrderDetails.java:78)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
public class CustOrdObject implements Serializable {
public int CustID;
public int CustOrderID;
public Object OrderDate;
public InnerCustOrdObject[] innerCustOrdObj;
public float GrandTotal;
public int MaxItems;
public CustOrdObject() {}
public CustOrdObject(InnerCustOrdObject[] innerCustOrdObj,
int CustID, int CustOrderID, Object OrderDate,
float GrandTotal, int innerarrlength, int innerarrpos, int MaxItems) {
this.CustID = CustID;
this.CustOrderID = CustOrderID;
this.OrderDate = OrderDate;
this.GrandTotal = GrandTotal;
this.MaxItems = MaxItems;
this.innerCustOrdObj = new InnerCustOrdObject[MaxItems];
public InnerCustOrdObject[] getInnerCustOrdObj() {
return innerCustOrdObj;
public void setInnerCustOrdObj(InnerCustOrdObject[] innerCustOrdObj) {
this.innerCustOrdObj = innerCustOrdObj;
public int getCustID() {
return CustID;
public void setCustID(int custID) {
CustID = custID;
public int getCustOrderID() {
return CustOrderID;
public void setCustOrderID(int custOrderID) {
CustOrderID = custOrderID;
public Object getOrderDate() {
return OrderDate;
public void setOrderDate(Object orderDate) {
OrderDate = orderDate;
public void setGrandTotal(float grandTotal) {
GrandTotal = grandTotal;
public float getGrandTotal() {
return GrandTotal;
public int getMaxItems() {
return MaxItems;
public void setMaxItems(int maxItems) {
MaxItems = maxItems;
public class InnerCustOrdObject implements Serializable{
public int ItemNumber;
public float UnitPrice;
public int QuantityRequired;
public float TotalPrice;
public InnerCustOrdObject() {}
public InnerCustOrdObject(int ItemNumber, float
UnitPrice, int QuantityRequired, float TotalPrice){
this.ItemNumber = ItemNumber;
this.UnitPrice = UnitPrice;
this.QuantityRequired = QuantityRequired;
this.TotalPrice = TotalPrice;
public int getItemNumber() {
return ItemNumber;
public void setItemNumber(int itemNumber) {
ItemNumber = itemNumber;
public int getQuantityRequired() {
return QuantityRequired;
public void setQuantityRequired(int quantityRequired) {
QuantityRequired = quantityRequired;
public float getTotalPrice() {
return TotalPrice;
public void setTotalPrice(float totalPrice) {
TotalPrice = totalPrice;
public float getUnitPrice() {
return UnitPrice;
public void setUnitPrice(float unitPrice) {
UnitPrice = unitPrice;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
public class CustomerOrderDetails extends CommonFeatures{
//TODO
private static int MAX_ORDERS = 200;
private static int MAX_ORDERITEMS = 100;
private static int MaxRecord;
private static int CurrentRecord = 1;
private static int currentItem;
private static int MaxItems;
private static boolean FileExists, recFileExists;
private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];
private static File OrderDetailsFile = new File("CustOrdDetails.dat");
private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
private static PrintWriter writeFile;
private static BufferedReader readFile;
private static ObjectOutputStream objOut;
private static ObjectInputStream objIn;
//Set format for date
SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
//--<BEGINNING>--Declaring Interface Variables------------------------------------------//
private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
//--<END>--Declaring Interface Variables------------------------------------------------//
public static void main(String[] args) {
final CustomerOrderDetails COD = new CustomerOrderDetails();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
COD.createCustOrdDetailsScreen();
} catch (Exception eb) {
eb.printStackTrace();
//--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
public JFrame createCustOrdDetailsScreen() {
createDefaultFrame();
mainframe.setSize(800,500);
createContainerPanel();
containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
//containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
//containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
mainframe.setContentPane(containerpanel);
mainframe.setLocationRelativeTo(null);
mainframe.setVisible(true);
//--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
if (OrdRecordNumStore.exists() == true) {
recFileExists = true;
}else {
recFileExists = false;
if (recFileExists == true) {
MaxRecord = readRecordNumber();
CurrentRecord = MaxRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
}else{
MaxRecord = 1;
writeRecordNumber(MaxRecord);
CustOrderIDTxt.setText(""+MaxRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
//--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
if(readOrder() != null){
orderDetails = (CustOrdObject[]) readOrder();
innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
MaxItems = orderDetails[CurrentRecord].getMaxItems();
if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
externalnextbtn.setEnabled(true);
externalprevbtn.setEnabled(true);
if(CurrentRecord >= MaxRecord){
externalnextbtn.setEnabled(false);
getFieldText(CurrentRecord-1);
}else{
orderDetails[CurrentRecord] = new CustOrdObject();
currentItem = 1;
return mainframe;
//--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
public JPanel createCustOrdDetailsTitle(){
createTitlePanel();
titlepanel.setBackground(TxtfontColor);
label.setText("- Customer Order Details -");
labelpanel.setBackground(TxtfontColor);
label.setForeground(Color.white);
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor) ;
buttonpanel.add(createReturnToMainMenuButton());
titlepanel.add(labelpanel, BorderLayout.WEST);
titlepanel.add(buttonpanel, BorderLayout.EAST);
return titlepanel;
public JPanel createCustOrdDetailsMainPanel(){
createmainpanel();
mainpanel.setBackground(TxtfontColor);
mainpanel.setLayout(new BorderLayout());
mainpanel.setBorder(BorderFactory.createTitledBorder(""));
mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
return mainpanel;
public JPanel createInnerTopPanel(){
innertoppanel = new JPanel(new GridBagLayout());
innertoppanel.setBackground(TxtfontColor);
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
CustIDLbl = new JLabel("Customer ID");
CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustIDLbl.setFont(font);
CustIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innertoppanel.add(CustIDLbl, GBC);
CustIDTxt = new JTextField(20);
CustIDTxt.setEditable(true);
GBC.gridx = 2;
GBC.gridy = 1;
innertoppanel.add(CustIDTxt, GBC);
GBC.gridx = 3;
GBC.gridy = 1;
innertoppanel.add(Box.createHorizontalStrut(220), GBC);
OrderedDateLbl = new JLabel("Order Date");
OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
OrderedDateLbl.setFont(font);
OrderedDateLbl.setForeground(LblfontColor);
GBC.gridx = 4;
GBC.gridy = 1;
innertoppanel.add(OrderedDateLbl, GBC);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
OrderedDateTxt.setEditable(false);
GBC.gridx = 5;
GBC.gridy = 1;
innertoppanel.add(OrderedDateTxt, GBC);
CustOrderIDLbl = new JLabel("Customer Order ID");
CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustOrderIDLbl.setFont(font);
CustOrderIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDLbl, GBC);
CustOrderIDTxt = new JTextField(20);
CustOrderIDTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDTxt, GBC);
return innertoppanel;
public JPanel createInnerCenterPanel(){
innercenterpanel = new JPanel(new GridBagLayout());
innercenterpanel.setBackground(TxtfontColor);
innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
ItemNumberLbl = new JLabel("Item Number");
ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
ItemNumberLbl.setFont(font);
ItemNumberLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberLbl, GBC);
ItemNumberTxt = new JTextField(20);
GBC.gridx = 2;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberTxt, GBC);
UnitPriceLbl = new JLabel("Unit Price");
UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
UnitPriceLbl.setFont(font);
UnitPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceLbl, GBC);
UnitPriceTxt = new JTextField(20);
//UnitPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceTxt, GBC);
QuantityReqLbl = new JLabel("Quantity Required");
QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
QuantityReqLbl.setFont(font);
QuantityReqLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqLbl, GBC);
QuantityReqTxt = new JTextField(20);
//QuantityReqTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqTxt, GBC);
TotPriceLbl = new JLabel("Total Price");
TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
TotPriceLbl.setFont(font);
TotPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 4;
innercenterpanel.add(TotPriceLbl, GBC);
TotPriceTxt = new JTextField(20);
//TotPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 4;
innercenterpanel.add(TotPriceTxt, GBC);
return innercenterpanel;
public JPanel createInnerBottomPanel(){
innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
innerbottompanel.setBackground(TxtfontColor);
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
GrandTotLbl = new JLabel("Grand Total");
GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
GrandTotLbl.setFont(font);
GrandTotLbl.setForeground(LblfontColor);
innerbottompanel.add(GrandTotLbl);
innerbottompanel.add(Box.createHorizontalStrut(30));
GrandTotTxt = new JTextField(20);
innerbottompanel.add(GrandTotTxt);
return innerbottompanel;
public JPanel createInnerRightPanel(){
innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerrightpanel.setBackground(TxtfontColor);
innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerrightpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalnextbtn = new JButton(createNextButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//getInnerFieldText(currentItem);
internalprevbtn.setEnabled(true);
if(currentItem < MaxItems){
++CurrentRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
setInnerFieldText(currentItem);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(currentItem == MaxItems){
internalnextbtn.setEnabled(false);
innerrightpanel.add(internalnextbtn, GBC);
return innerrightpanel;
public JPanel createInnerLeftPanel(){
innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerleftpanel.setBackground(TxtfontColor);
innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerleftpanel.setForeground(Color.BLACK);
innerleftpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalprevbtn = new JButton(createPreviousButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//getInnerFieldText(currentItem);
internalnextbtn.setEnabled(true);
if(currentItem == 1){
internalprevbtn.setEnabled(false);
if(currentItem > 0){
--currentItem;
//readOrder();
setInnerFieldText(currentItem);
innerleftpanel.add(internalprevbtn, GBC);
return innerleftpanel;
public JPanel createCustOrdDetailsButtons(){
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor);
externalprevbtn = new JButton(createPreviousButtonIcon());
externalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalnextbtn.setEnabled(true);
if(CurrentRecord == 1){
externalprevbtn.setEnabled(false);
if(CurrentRecord > 0){
--CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
buttonpanel.add(externalprevbtn);
addrecordbtn = new JButton("Add Record", createAddButtonIcon());
addrecordbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
MaxRecord = readRecordNumber();
MaxRecord++;
writeRecordNumber(MaxRecord);
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
CustIDTxt.setText("");
CustOrderIDTxt.setText(""+MaxRecord);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt.setText(""+simpleDF.format(todaydate));
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
GrandTotTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
externalnextbtn.setEnabled(false);
externalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(addrecordbtn);
savebtn = new JButton("Save Data", createSaveButtonIcon());
savebtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
setFieldText(CurrentRecord);
writeOrder();
writeRecordNumber(MaxRecord);
System.out.println(CurrentRecord);
System.out.println(MaxRecord);
buttonpanel.add(savebtn);
java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
additemreqbtn = new JButton("Add Item", AddRowIcon);
additemreqbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
//CurrentRecord = MaxRecord;
currentItem++;
setInnerFieldText(currentItem);
internalnextbtn.setEnabled(false);
internalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(additemreqbtn);
externalnextbtn = new JButton(createNextButtonIcon());
externalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalprevbtn.setEnabled(true);
if(CurrentRecord < MaxRecord){
++CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(CurrentRecord == MaxRecord){
externalnextbtn.setEnabled(false);
buttonpanel.add(externalnextbtn);
return buttonpanel;
//TODO
public void setFieldText(int orderID){//TODO
orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
orderDetails[orderID].setMaxItems(MaxItems);
setInnerFieldText(currentItem);
orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
public void setInnerFieldText(int currentItem){//TODO
innerCustOrdObj[currentItem] = new InnerCustOrdObject();
innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
public void getFieldText(int orderID){
CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());
currentItem = orderDetails[orderID].getMaxItems();
System.err.println("currentItem" + currentItem);
getInnerFieldText(currentItem);
GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
public void getInnerFieldText(int currentItem){
ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
public void writeOrder(){//TODO
try {
objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
objOut.writeObject(orderDetails);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
} catch (IOException e) {
e.printStackTrace();
public Object readOrder(){
Object temporaryObj;
try{
objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
temporaryObj = objIn.readObject();
CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
System.out.println("Outer: "+blah[1].getCustID());
InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
System.out.println("Inner: "+whee[1].getItemNumber());
objIn.close();
System.out.println("Read Worky!");
return temporaryObj;
}catch(Exception e){
e.printStackTrace();
System.out.println("Read No Worky!");
return null;
public void writeRecordNumber(int MaxRecord){
try{
objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
objOut.writeObject(MaxRecord);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
}catch(Exception e){e.printStackTrace();}
public int readRecordNumber() {
try {
objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
int temporaryObj = Integer.parseInt(objIn.readObject().toString());
objIn.close();
System.out.println("Read Number Worky!");
return temporaryObj;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Read Number No Worky!");
return -1;
}Message was edited by:
Kilik07
Message was edited by:
Kilik07ok i got reading to work to a certain extent... but the prob is i cnt seem to save my innerCustOrdObj proprly...when ever i look for a record using the gotorecordbtn, the outerobject, which is the orderDetails, seems to change but the innerCustOrdObj remains the same... heres the new code..
public class CustomerOrderDetails extends CommonFeatures{
//TODO
private static int MAX_ORDERS = 200;
private static int MAX_ORDERITEMS = 100;
private static int MaxRecord;
private static int CurrentRecord = 1;
private static int currentItem;
private static int MaxItems = 1;
private static boolean FileExists, recFileExists;
private static boolean RecordExists;
private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];
private static File OrderDetailsFile = new File("CustOrdDetails.ser");
private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
private static PrintWriter writeFile;
private static BufferedReader readFile;
private static ObjectOutputStream objOut;
private static ObjectInputStream objIn;
//Set format for date
SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
//--<BEGINNING>--Declaring Interface Variables------------------------------------------//
private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
//--<END>--Declaring Interface Variables------------------------------------------------//
public static void main(String[] args) {
final CustomerOrderDetails COD = new CustomerOrderDetails();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
COD.createCustOrdDetailsScreen();
} catch (Exception eb) {
eb.printStackTrace();
//--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
public JFrame createCustOrdDetailsScreen() {
createDefaultFrame();
mainframe.setSize(800,500);
createContainerPanel();
containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
//containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
//containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
mainframe.setContentPane(containerpanel);
mainframe.setLocationRelativeTo(null);
mainframe.setVisible(true);
//--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
if (OrdRecordNumStore.exists() == true) {
recFileExists = true;
}else {
recFileExists = false;
if (recFileExists == true) {
MaxRecord = readRecordNumber();
CurrentRecord = MaxRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
}else{
MaxRecord = 1;
writeRecordNumber(MaxRecord);
CustOrderIDTxt.setText(""+MaxRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
//--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
if(readOrder() != null){
orderDetails = (CustOrdObject[]) readOrder();
//CurrentRecord--;
//System.out.println("Current Rec Here"+CurrentRecord);
if(orderDetails[CurrentRecord] == null){
System.err.println("CustomerOrderObj 1 is null !!");
}else{
System.err.println("CustomerOrderObj 1 is not null !!");
if(orderDetails[CurrentRecord].getInnerCustOrdObj() == null){
System.err.println("InnerCustomerOrderObj is null !!");
}else{
System.err.println("InnerCustomerOrderObj is not null !!");
innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
MaxItems = orderDetails[CurrentRecord].getMaxItems();
if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
externalnextbtn.setEnabled(true);
externalprevbtn.setEnabled(true);
if(CurrentRecord >= MaxRecord){
externalnextbtn.setEnabled(false);
getFieldText(CurrentRecord);
getInnerFieldText(MaxItems);
}else{
orderDetails[CurrentRecord] = new CustOrdObject();
currentItem = 1;
return mainframe;
//--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
public JPanel createCustOrdDetailsTitle(){
createTitlePanel();
titlepanel.setBackground(TxtfontColor);
label.setText("- Customer Order Details -");
labelpanel.setBackground(TxtfontColor);
label.setForeground(Color.white);
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor) ;
buttonpanel.add(createReturnToMainMenuButton());
titlepanel.add(labelpanel, BorderLayout.WEST);
titlepanel.add(buttonpanel, BorderLayout.EAST);
return titlepanel;
public JPanel createCustOrdDetailsMainPanel(){
createmainpanel();
mainpanel.setBackground(TxtfontColor);
mainpanel.setLayout(new BorderLayout());
mainpanel.setBorder(BorderFactory.createTitledBorder(""));
mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
return mainpanel;
public JPanel createInnerTopPanel(){
innertoppanel = new JPanel(new GridBagLayout());
innertoppanel.setBackground(TxtfontColor);
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
CustIDLbl = new JLabel("Customer ID");
CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustIDLbl.setFont(font);
CustIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innertoppanel.add(CustIDLbl, GBC);
CustIDTxt = new JTextField(20);
CustIDTxt.setEditable(true);
GBC.gridx = 2;
GBC.gridy = 1;
innertoppanel.add(CustIDTxt, GBC);
GBC.gridx = 3;
GBC.gridy = 1;
innertoppanel.add(Box.createHorizontalStrut(220), GBC);
OrderedDateLbl = new JLabel("Order Date");
OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
OrderedDateLbl.setFont(font);
OrderedDateLbl.setForeground(LblfontColor);
GBC.gridx = 4;
GBC.gridy = 1;
innertoppanel.add(OrderedDateLbl, GBC);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
OrderedDateTxt.setEditable(false);
GBC.gridx = 5;
GBC.gridy = 1;
innertoppanel.add(OrderedDateTxt, GBC);
CustOrderIDLbl = new JLabel("Customer Order ID");
CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustOrderIDLbl.setFont(font);
CustOrderIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDLbl, GBC);
CustOrderIDTxt = new JTextField(20);
//CustOrderIDTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDTxt, GBC);
return innertoppanel;
public JPanel createInnerCenterPanel(){
innercenterpanel = new JPanel(new GridBagLayout());
innercenterpanel.setBackground(TxtfontColor);
innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
ItemNumberLbl = new JLabel("Item Number");
ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
ItemNumberLbl.setFont(font);
ItemNumberLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberLbl, GBC);
ItemNumberTxt = new JTextField(20);
GBC.gridx = 2;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberTxt, GBC);
UnitPriceLbl = new JLabel("Unit Price");
UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
UnitPriceLbl.setFont(font);
UnitPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceLbl, GBC);
UnitPriceTxt = new JTextField(20);
//UnitPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceTxt, GBC);
QuantityReqLbl = new JLabel("Quantity Required");
QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
QuantityReqLbl.setFont(font);
QuantityReqLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqLbl, GBC);
QuantityReqTxt = new JTextField(20);
//QuantityReqTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqTxt, GBC);
TotPriceLbl = new JLabel("Total Price");
TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
TotPriceLbl.setFont(font);
TotPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 4;
innercenterpanel.add(TotPriceLbl, GBC);
TotPriceTxt = new JTextField(20);
TotPriceTxt.setEditable(false);
TotPriceTxt.addFocusListener(new FocusAdapter(){
public void focusGained(FocusEvent evt){
TotPriceTxt.setText(""+Integer.parseInt(UnitPriceTxt.getText())*Integer.parseInt(QuantityReqTxt.getText()));
GBC.gridx = 2;
GBC.gridy = 4;
innercenterpanel.add(TotPriceTxt, GBC);
return innercenterpanel;
public JPanel createInnerBottomPanel(){
innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
innerbottompanel.setBackground(TxtfontColor);
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
GrandTotLbl = new JLabel("Grand Total");
GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
GrandTotLbl.setFont(font);
GrandTotLbl.setForeground(LblfontColor);
innerbottompanel.add(GrandTotLbl);
innerbottompanel.add(Box.createHorizontalStrut(30));
GrandTotTxt = new JTextField(20);
innerbottompanel.add(GrandTotTxt);
return innerbottompanel;
public JPanel createInnerRightPanel(){
innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerrightpanel.setBackground(TxtfontColor);
innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerrightpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalnextbtn = new JButton(createNextButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getInnerFieldText(currentItem);
internalprevbtn.setEnabled(true);
if(currentItem < MaxItems){
++currentItem;
orderDetails[CurrentRecord].getInnerCustOrdObj();
setInnerFieldText(currentItem);
System.out.println("Current Item" + currentItem);
if(currentItem == MaxItems){
internalnextbtn.setEnabled(false);
innerrightpanel.add(internalnextbtn, GBC);
return innerrightpanel;
public JPanel createInnerLeftPanel(){
innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerleftpanel.setBackground(TxtfontColor);
innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerleftpanel.setForeground(Color.BLACK);
innerleftpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalprevbtn = new JButton(createPreviousButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getInnerFieldText(currentItem);
internalnextbtn.setEnabled(true);
if(currentItem == 1){
internalprevbtn.setEnabled(false);
if(currentItem > 0){
--currentItem;
orderDetails[CurrentRecord].getInnerCustOrdObj();
setInnerFieldText(currentItem);
System.out.println("Current Item" + currentItem);
innerleftpanel.add(internalprevbtn, GBC);
return innerleftpanel;
public JPanel createCustOrdDetailsButtons(){
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor);
externalprevbtn = new JButton(createPreviousButtonIcon());
externalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalnextbtn.setEnabled(true);
if(CurrentRecord == 1){
externalprevbtn.setEnabled(false);
if(CurrentRecord > 0){
--CurrentRecord;
setFieldText(CurrentRecord);
System.out.println("Current Record " + CurrentRecord);//Checking RECORD_NUM
buttonpanel.add(externalprevbtn);
addrecordbtn = new JButton("Add Record", createAddButtonIcon());
addrecordbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
MaxRecord = readRecordNumber();
MaxRecord++;
CurrentRecord = MaxRecord;
orderDetails[CurrentRecord] = new CustOrdObject();
writeRecordNumber(MaxRecord);
MaxItems = 1;
innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
CustIDTxt.setText("");
CustOrderIDTxt.setText(""+MaxRecord);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt.setText(""+simpleDF.format(todaydate));
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
GrandTotTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
externalnextbtn.setEnabled(false);
externalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(addrecordbtn);
savebtn = new JButton("Save Data", createSaveButtonIcon());
savebtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
setFieldText(CurrentRecord);
setInnerFieldText(MaxItems);
writeOrder();
writeRecordNumber(MaxRecord);
System.out.println(CurrentRecord);
System.out.println(MaxRecord);
buttonpanel.add(savebtn);
java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
additemreqbtn = new JButton("Add Item", AddRowIcon);
additemreqbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
//CurrentRecord = MaxRecord;
MaxItems++;
innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
System.out.println("Max Items "+MaxItems);
currentItem = MaxItems;
orderDetails[CurrentRecord].setMaxItems(MaxItems);
///setInnerFieldText(currentItem);
internalnextbtn.setEnabled(false);
internalprevbtn.setEnabled(true);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(additemreqbtn);
externalnextbtn = new JButton(createNextButtonIcon());
externalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalprevbtn.setEnabled(true);
if(CurrentRecord < MaxRecord){
++CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(CurrentRecord == MaxRecord){
externalnextbtn.setEnabled(false);
buttonpanel.add(externalnextbtn);
gotorecordbtn = new JButton("Go To Record", createGotoButtonIcon());
gotorecordbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt){
* The text from the GotorecordTxt textfield will be taken and assigned
* to a temporary integer variable called Find.
int Find = Integer.parseInt(CustOrderIDTxt.getText());
for(int j=1; j <= MaxRecord; j++){
* Using a for loop, each record can be read using the readCustRecord
* method.
getFieldText(j);
* An if condition is utilized to check whether the temporary stored variable, Find,
* matches a field in a record. If this record is found, then using the RecordExists
* which was declared at the top, either a true or false statement can be assigned
* If the record exists, then a true statement will be assigned, if not a false
* statement will be assigned.
if(orderDetails[j].getCustOrderID() == Find){
RecordExists = true;
break;
}else{
RecordExists = false;
if(RecordExists == false){
* If the RecordExists is assigned a false statement, then a message will be
* displayed to show that the record does not exist.
JOptionPane.showMessageDialog(null, "Record Does Not Exist!", "Error Message", JOptionPane.ERROR_MESSAGE, createErrorIcon());
}else{
getFieldText(Find);
buttonpanel.add(gotorecordbtn);
return buttonpanel;
//TODO
public void setFieldText(int orderID){//TODO
orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
orderDetails[orderID].setMaxItems(MaxItems);
setInnerFieldText(currentItem);
orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
public void setInnerFieldText(int currentItem){//TODO
innerCustOrdObj[currentItem] = new InnerCustOrdObject();
innerCustOrdObj[currentItem].setMaxItems(MaxItems);
innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
public void getFieldText(int orderID){
CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());
currentItem = orderDetails[orderID].getMaxItems();
orderDetails[orderID].getInnerCustOrdObj();
System.err.println("currentItem" + currentItem);
//getInnerFieldText(currentItem);
GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
public void getInnerFieldText(int currentItem){
ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
public void writeOrder(){//TODO
try {
objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
objOut.writeObject(orderDetails);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
} catch (IOException e) {
e.printStackTrace();
public Object readOrder(){
Object temporaryObj;
try{
objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
temporaryObj = objIn.readObject();
CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
/* System.out.println("Outer: "+blah[1].getCustID());
InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
System.out.println("Inner: "+whee[1].getItemNumber());*/
objIn.close();
System.out.println("Read Worky!");
return temporaryObj;
}catch(Exception e){
e.printStackTrace();
System.out.println("Read No Worky!");
return null;
public void writeRecordNumber(int MaxRecord){
try{
objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
objOut.writeObject(MaxRecord);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
}catch(Exception e){e.printStackTrace();}
public int readRecordNumber() {
try {
objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
int temporaryObj = Integer.parseInt(objIn.readObject().toString());
objIn.close();
System.out.println("Read Number Worky!");
return temporaryObj;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Read Number No Worky!");
return -1;
}Message was edited by:
Kilik07 -
Problem with application server shutdown when connecting
Hi Friends,
I am new to J2EE applications.
I developed a web application that uses jxl and mysql for reading excel sheets. The host I am working on is supposed to be the server. The application I am running is working absolutely fine, by creating a directory and saving the excel file in my webapps folder and inserting the data to the database. But the minute I send the file from client system, there is a sudden shutdown in my server.
I am sending the jsp and java code related to this application and related log file..
I guess the main problem is with sending the exact path from the remote client, rest all is fine including excel and database interactions.
I commented the database interaction class just for now as I don't think there is a problem with it.
I am using Tomcat 4.1, MySQL 3.23
====================================================
JSP FILE
=====================================================
<%@ page language="java" import="pdss.*"%>
<html>
<head><title>File Upload</title></head>
<body>
<% String action=request.getParameter("go");
String message=request.getParameter("msg");
String str="";
if(message!=null)
str="Please enter valid filename!";
ExcelInteraction xlInt=new ExcelInteraction();
if(action==null)
%>
<center><font color="red"><%=str%></font></center>
<form name="myform" method="post">
<input type="file" name="filename"></input>
<input type="submit" name="go" value="Send">
</form>
<%
else if("send".equalsIgnoreCase(action))
String filename=request.getParameter("filename");
int ex=0;
System.out.println("************"+filename.endsWith(".xls"));
if(filename!=null && (filename.endsWith(".xls")))
ex=xlInt.fileTransfer(filename, getServletContext());
else if(filename==null || ("".equals(filename)) || filename.endsWith(".xls")==false)
response.sendRedirect("uploadFile.jsp?msg=a");
if(ex>0)
%> DONE
<% }
else
%> Data Inconsistency found
<% }
%>
</body>
</html>
======================================================
JAVA FILES
======================================================
ExcelInteraction:
package pdss;
import pdss.*;
import java.io.*;
import java.lang.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ExcelInteraction
//PDSSUtilities pdsUtil=new PDSSUtilities();
public int fileTransfer(String readFile, ServletContext app) throws Exception
int i=0, j=0;
String strDirectory = "pdssexcelfiles";
System.out.println("..............ReadFile..."+readFile);
File srcFile=new File(readFile);
System.out.println(".................Created source file."+srcFile.getAbsolutePath());
File destFile=null;
String newDirStr="",srcFileName="",destFileLoc="", realPath="";
try{
realPath=app.getRealPath("/");
System.out.println("newDirStr..........."+realPath);
newDirStr=realPath+strDirectory;
System.out.println("newDirStr..........."+newDirStr);
if((new File(newDirStr)).exists()==false)
boolean success = (new File(newDirStr)).mkdir();
System.out.println("....................success..."+success);
if (success) {
System.out.println(".................Directory...: " + strDirectory + " created");
srcFileName = srcFile.getName();
destFileLoc=newDirStr+"\\"+srcFileName;
System.out.println("DestFileLoc............"+destFileLoc);
if(srcFile.exists()){
destFile=new File(destFileLoc);
InputStream in = new FileInputStream(srcFile);
OutputStream out = new FileOutputStream(destFile);
byte[] buf = new byte[1024];
int len=0;
while ((len = in.read(buf)) > 0){
out.write(buf, 0, len);
in.close();
out.close();
System.out.println("............File copied to... "+destFile.getAbsolutePath());
System.out.println("......Closing Streams......");
/*if(destFile.exists())
j=pdsUtil.readXlData(destFileLoc);
System.out.println("..........j::"+j+"rows affected");
catch(Exception e)
e.printStackTrace();
System.exit(0);
return j;
=====================================================
LOG FILE FROM HOST SYSTEM:
=====================================================
2008-09-16 16:53:52 StandardContext[pdss]: Mapping contextPath='/pdss' with requestURI='/pdss/uploadFile.jsp' and relativeURI='/uploadFile.jsp'
2008-09-16 16:53:52 StandardContext[pdss]: Trying exact match
2008-09-16 16:53:52 StandardContext[pdss]: Trying prefix match
2008-09-16 16:53:52 StandardContext[pdss]: Trying extension match
2008-09-16 16:53:52 StandardContext[pdss]: Mapped to servlet 'jsp' with servlet path '/uploadFile.jsp' and path info 'null' and update=true
2008-09-16 16:54:01 StandardContext[pdss]: Mapping contextPath='/pdss' with requestURI='/pdss/uploadFile.jsp' and relativeURI='/uploadFile.jsp'
2008-09-16 16:54:01 StandardContext[pdss]: Trying exact match
2008-09-16 16:54:01 StandardContext[pdss]: Trying prefix match
2008-09-16 16:54:01 StandardContext[pdss]: Trying extension match
2008-09-16 16:54:01 StandardContext[pdss]: Mapped to servlet 'jsp' with servlet path '/uploadFile.jsp' and path info 'null' and update=true
=====================================================
LOG FILE FROM CLIENT SYSTEM:
2008-09-16 16:54:41 StandardContext[pdss]: Mapping contextPath='/pdss' with requestURI='/pdss/uploadFile.jsp' and relativeURI='/uploadFile.jsp'
2008-09-16 16:54:41 StandardContext[pdss]: Trying exact match
2008-09-16 16:54:41 StandardContext[pdss]: Trying prefix match
2008-09-16 16:54:41 StandardContext[pdss]: Trying extension match
2008-09-16 16:54:41 StandardContext[pdss]: Mapped to servlet 'jsp' with servlet path '/uploadFile.jsp' and path info 'null' and update=true
2008-09-16 16:54:42 StandardContext[pdss]: Stopping
2008-09-16 16:54:42 StandardContext[pdss]: Stopping filters
2008-09-16 16:54:42 StandardContext[pdss]: Processing standard container shutdown
2008-09-16 16:54:42 ContextConfig[pdss]: ContextConfig: Processing STOP
2008-09-16 16:54:42 StandardWrapper[pdss:jsp]: Waiting for 1 instance(s) to be deallocated
2008-09-16 16:54:42 StandardContext[pdss]: Sending application stop events
2008-09-16 16:54:42 StandardContext[pdss]: Stopping complete
=====================================================
Regards
VasumitraThe VERY FIRST message in the server log gives you a hint as to what the problem might be. The server thinks you have spaces in your PATH to the application server. Therefore, the solution is to kill the server however you need to (task manager, whatever) and then reinstall it in a path that doesn't contain spaces. That's the low-hanging fruit here; if that doesn't work, well, then we will have to find some other solution.
-
Problem with JavaBeans in JSP.IT'S URGENT!!!
Hi, i have problems with JavaBeans in JSP.
In a jsp file( locating in ROOT directory of tomcat 4.0.6 :jakarta-tomcat-4.0.6\webapps\root ) i have this code:
<jsp:useBean id="paramBean" class="licentza.ParamBean" />
<jsp:setProperty name="paramBean"
property="nume"
value='<%= request.getParameter("numeUser") %>' />
where ParamBean it's a "bean" class locating in jakarta-tomcat-4.0.6\webapps\examples\web-inf\classes\licentza (licentza is the package i'm using).
And i get this error:
Generated servlet error:
D:\jakarta-tomcat-4.0.6\work\Standalone\localhost\_\dora\intrare2$jsp.java:67: Class licentza.ParamBean not found.
ParamBean paramBean = null;
What is the problem?Thank you.Hi,
Put the class file or the package under :jakarta-tomcat-4.0.6\webapps\root\WEB-INF\classes.
Rajesh -
Problem with binding in h:dataTable
Hi
I have a problem with h:dataTable, where the table rows are bound to objects (Bean$Line) nested within a backing bean (Bean).
JSP:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<html>
<f:view>
<head>
<link href="styles.css" rel="stylesheet" type="text/css"/>
<title>Sandbox</title>
</head>
<body>
<h:form>
<h:dataTable value="#{bean.lines}" var="line">
<h:column>
<h:outputText value="#{line.id}"/>
</h:column>
<h:column>
<!-- using value = line.lineSelected here works (assuming boolean property Line.lineSelected) --/>
<h:selectBooleanCheckbox binding="#{line.lineSelected}"/>
</h:column>
</h:dataTable>
</h:form>
</body>
</f:view>
</html>Bean:
package com.test;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.UISelectBoolean;
public final class Bean {
private final List<Line> lines;
public Bean() {
lines = new ArrayList<Line>();
lines.add(new Line("one"));
lines.add(new Line("two"));
lines.add(new Line("three"));
public List<Line> getLines() {
return lines;
* Nested class in order to access containing class
* properties etc.
public static class Line {
//private boolean lineSelected = false;
private UISelectBoolean lineSelected;
private String id;
public Line(String id) {
this.id = id;
/*public boolean isLineSelected() {
return lineSelected;
public void setLineSelected(boolean lineSelected) {
this.lineSelected = lineSelected;
public UISelectBoolean getLineSelected() {
return lineSelected;
public void setLineSelected(UISelectBoolean lineSelected) {
this.lineSelected = lineSelected;
public String getId() {
return id;
public void setId(String id) {
this.id = id;
} // Line
}The setup works when I use value="#{line.lineSelected}" (assuming the property is defined as boolean in Bean$Line) but as soon as I use a binding, I get the following exception:
com.sun.rave.web.ui.appbase.ApplicationException: javax.servlet.ServletException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'line' resolved to null
at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:594)
at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:325)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
faces_config:
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<application>
<locale-config>
<default-locale>en_GB</default-locale>
<supported-locale>en_GB</supported-locale>
</locale-config>
</application>
<managed-bean>
<managed-bean-name>bean</managed-bean-name>
<managed-bean-class>com.test.Bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>What am I missing here?
Help much appreciated
LanceGuys
Thanks a lot, both of your replies are immensely instructive. Maybe a little background on what I'm trying to do. In the table, I have header rows with dependent line rows. When a check box is ticked in the header, I want the corresponding check boxes in the dependent lines to be checked automatically (in slave fashion and ideally without using JavaScript). My idea was to update the bound components (for the lines) from within the Bean (in response to change on the header). However, given there's only a single component for each column in the table, this of course doesn't make sense.
I'm trying to get to the typical MVC workflow of a) user updates a View component, b) Controller detects the change and updates the Model, c) The Model fires a property change event, which the View detects and updates appropriately. What's the way to achieve this in JSF (by design)?
Here's a simple fragment (which does not work):
<h:dataTable value="#{bean.lines}" var="line">
<h:column>
<h:outputText value="#{line.id}"/>
</h:column>
<h:column>
<!-- (1) This is the master and (2) should refresh on update here --/>
<h:selectBooleanCheckbox onchange="submit()" value="#{line.lineSelected}"/>
</h:column>
<h:column>
<!-- (2) This is the slave and I want this to update in response to a change of (1) above --/>
<h:selectBooleanCheckbox value="#{line.slaveSelected}"/>
</h:column>
</h:dataTable>In the setter method for lineSelected, I'm setting slaveSelected to the new value but the View is not refreshing based on this. How do I get the View to update (each dependent line) based on the new values for slaveSelected?
Thanks again
Lance -
Problem with 9iAS and Day Communiquh 3
Hi,
i have a problem with the deployment of Day Communiquh 3 web application (a tool for content management) on Oracle 9iAS (not on the OC4J stand-alone..).
As explained on Day guide, i've disabled the following services in the delivery.xml of publish/system/conf directory (the file is put in attachment for a better comprehension):
- ServletEngineService;
- ShoutService.
Moreover, i've updated the following tags:
- fakeurls, with <redirect from="/" to="/cq3/playground/en.html" />;
- loopback, with the port i use (7778).
Then i have packed up the CQ3 webapp in a WAR file (cq3-web.war): i give you in attachment the WEB-INF/web.xml used.
Finally i have packed up the WAR file in a EAR file, using the Enterprise Manager of 9iAS: i've put "cq3" as name of the deployed application, and "/cq3" as context root, so that users can access the application typing in a browser "http://<server_address>:<port>/cq3".
Then i've found the following problems:
- firstly, "http://<server_address>:<port>/cq3" doesn't redirect to "http://<server_address>:<port>/cq3/playground/en.html" as specified in delivery.xml: a "404 not found" error raises; so i have to type "http://<server_address>:<port>/cq3/playground/en.html" manually to view the Communiquh Playground;
- anyway, the Communiquh Playground isn't shown correctly: every link and every image refers to an address like, for example, "http://<server_address>:<port>/playground/en/my_image.gif", i.e. without the "/cq3" context root in front of "/playground..".
Anyone that could help me to resolve this issue is welcome. Please answer to [email protected]Hi,
i have a problem with the deployment of Day Communiquh 3 web application (a tool for content management) on Oracle 9iAS (not on the OC4J stand-alone..).
As explained on Day guide, i've disabled the following services in the delivery.xml of publish/system/conf directory (the file is put in attachment for a better comprehension):
- ServletEngineService;
- ShoutService.
Moreover, i've updated the following tags:
- fakeurls, with <redirect from="/" to="/cq3/playground/en.html" />;
- loopback, with the port i use (7778).
Then i have packed up the CQ3 webapp in a WAR file (cq3-web.war): i give you in attachment the WEB-INF/web.xml used.
Finally i have packed up the WAR file in a EAR file, using the Enterprise Manager of 9iAS: i've put "cq3" as name of the deployed application, and "/cq3" as context root, so that users can access the application typing in a browser "http://<server_address>:<port>/cq3".
Then i've found the following problems:
- firstly, "http://<server_address>:<port>/cq3" doesn't redirect to "http://<server_address>:<port>/cq3/playground/en.html" as specified in delivery.xml: a "404 not found" error raises; so i have to type "http://<server_address>:<port>/cq3/playground/en.html" manually to view the Communiquh Playground;
- anyway, the Communiquh Playground isn't shown correctly: every link and every image refers to an address like, for example, "http://<server_address>:<port>/playground/en/my_image.gif", i.e. without the "/cq3" context root in front of "/playground..".
Anyone that could help me to resolve this issue is welcome. Please answer to [email protected]
Maybe you are looking for
-
RFC Function Error: Cannot convert a value of 'MM/DD/YYYY' from type java.l
hi experts, iam calling an RFC using SAP_JCO_Function. one of the input parameters is date which shud be in the format 'MM/DD/YYYY' but when i create a transaction property of data type DATETIME the format changes to " 2007-06-21 14:31:50 ". to refra
-
Printing current selected pages
i was wondering - it there a way to print the currently selected pages in indesign //like we can do in acrobat//? its not very sexy to manually type in all the pages you want to output and writing a pdf file to select and print the pages in acrobat c
-
How to setup a company code for material management
Hi, While creating material in MM01, in sales org tab, when I gave plant XXXX, it is giving an error "Company code YYYY is not setup for material management". So can you help me , how to setup a company code for material management Help is appreciate
-
System error: Unable to lock table/view V_T077K
Hi i am getting this error, i tried to look at the oss notes. Cannot find any solution. Pls clarify. Thanks, Sravan
-
Installing SQLDeveloper with Oracle Database Express Edition 11g Release 2
Hello, I have a problem with sqldeveloper in connecting to the database with the following message: *"java.lang.unsatisfiedlinkerror oracle.jdbc.driver.t2cconnection.t2csetsessiontimezone"* I can connect to the database via SQL / SQLPLUS. I cannot se