Baijun Jiang

Greenhorn
+ Follow
since Oct 13, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Baijun Jiang

I have an applet which draws charts based on given datasets. Recently a issue was raised by a customer that there is 8-hour difference between local time and the time displayed on the applet. I investigated this issue and here is my finding:
The time displayed on the applet is greenwick mean time.
The windows timezone setting is correct on customer's computer.
The windows regional setting is correct.
The JRE version is updated.
The applet displays the correct local time on most of the PCs I tested, but does display wrongly on a few PCs.
On the PCs that does not work well with my applet, I also searched the web for other people's clock applets. It seems those PCs cannot handle timing in applet well.

Have anybody encoutered this problem before? Any solution?
15 years ago
I have a back end program which creates multiple threads that talks to mysql database. These threads finish their jobs in a few seconds and get closed, in the mean time new threads are created. In the end, The program uses a lot of sockets to build the connections to database. I use netstat -a to check the status, the screen shows that my program uses 100-200 sockets (most of them are in on_wait status, meaning they will wait for a while then release), however this number is no where near the default windows socket number limit of 5000.
The program runs normally at the beginning. After 2/3 days however, it shows it cannot establish connection with database anymore. In the meantime my tomcat server and mysql server could not respond to anything, even service restart. When i try to stop/start Tomcat log shows

java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)

Mysql log shows the similar thing

080721 10:11:13 InnoDB: Started; log sequence number 0 43655
080721 10:11:13 [ERROR] Do you already have another mysqld server running on port: 3306 ?
080721 10:11:13 [ERROR] Aborting

When I stop/start these 2 servers I use netstat to check the socket connections again.

Proto Local Address Foreign Address State
TCP asus-xp:smtp asus-xp:0 LISTENING
TCP asus-xp op3 asus-xp:0 LISTENING
TCP asus-xp:epmap asus-xp:0 LISTENING
TCP asus-xp:microsoft-ds asus-xp:0 LISTENING
TCP asus-xp:3389 asus-xp:0 LISTENING
TCP asus-xp:42510 asus-xp:0 LISTENING
TCP asus-xp:1028 asus-xp:0 LISTENING
TCP asus-xp:netbios-ssn asus-xp:0 LISTENING
TCP asus-xp:3389 203.116.53.114:4438 ESTABLISHED
UDP asus-xp:microsoft-ds *:*
UDP asus-xp:isakmp *:*
UDP asus-xp:4500 *:*
UDP asus-xp:4593 *:*
UDP asus-xp:ntp *:*
UDP asus-xp:1900 *:*
UDP asus-xp:ntp *:*
UDP asus-xp:netbios-ns *:*
UDP asus-xp:netbios-dgm *:*
UDP asus-xp:1900 *:*
UDP asus-xp:42508 *:*

So obviously nothing is using those ports. Does anyone have any idea what is happening?
I have found that after a few days the fault pages generated by anti virus softwares become excessive. MSMPENG.exe (Windows Defender) and RtvScan.exe (Norton) have 500M/200M fault pages respectively. I guess it is interrelated to my heavy I/O usage of my Java program. Does anyone encounter this problem before? How should I solve/diagnose it?
15 years ago
Recently I developed a small java application for a customer. This application receives some emails and sends out some SMS every hour. Now this customer is complaining that the server slows down after a few days the applicaion is installed. I tried to use Jprobe to diagnose the problem. Jprobe shows that after a few days the application consumes the same amount of memory and the number of objects in the application remains almost the same. However, for every passing day the page file usage shown in windows task manager seems to be increased by 100MB.
I have to admin I am not very familiar with operating system and JVM. What kind of situation can cause this kind of "memory leak"?
15 years ago
Recently I wrote a java program to ping devices but got rediculous results. Therefore I did a simple test:

import java.io.IOException;
import java.net.*;

public class test {

/**
* @param args
* @throws IOException
* @throws UnknownHostException
*/
public static void main(String[] args) throws UnknownHostException, IOException {
String ip="192.168.1.222";
boolean returned=reachable(ip);
System.out.println(returned);
returned=InetAddress.getByName(ip).isReachable(1000);
System.out.println(returned);
}
private static boolean reachable(String address){
boolean returned;
DatagramSocket aSocket = null;
byte [] m = address.getBytes();
try
{
aSocket = new DatagramSocket();

InetAddress aHost = InetAddress.getByName(address);


DatagramPacket request = new DatagramPacket(m, address.length());
aSocket.connect(aHost, 7);
// now call either send or receive to see if connected
aSocket.send(request);
// if you got here then probably the other side is alive
returned=true;
}
catch (Exception ex)
{
System.out.println(ex);
returned=false;
}
return returned;
}
}

1.The ip I used does not exist in the network.
However I got this result after I ran this test:

true
true

2.After that I disabled mynetwork connection and ran the test again, I got:

java.net.NoRouteToHostException: No route to host: Datagram send failed
false
true

Conclusion: no matter what the InetAddress.getByName(ip).isReachable(1000) method will return me true value. The socket way is also giving me wrong information.

Can anyone tell me why this happens?

ps. I am using JDK 5.0 Update 7.
Of course... I use a tomcat server.
and Yes, I have many applications running in the same server.But I do not think it is a problem coz I also tested the application in a server which has no other app running on it.
18 years ago
Hi. It is simply a DNS error. After I right click and then select property. The url shown is res://C:\WINNT\system32\shdoclc.dll/dnserror.htm#http://localhost/CAAS-test/servlet/detailFunction
Therefore I conclude that the servlet cannot be found.

This error does not relate to any content written by me in the servlet, coz in one of my test the doPost method is empty but I still get the same problem.
[ December 22, 2005: Message edited by: Baijun Jiang ]
18 years ago
In my application a jsp A interact post some parameters(a form) to Servlet B. Normally B's doPost method can handle it properly. However, when one of the parameter from A to B becomes longer(eg. 2000 characters), an crazy error occurs: "The page cannot be displayed".
I did some tests regarding this problem. It seems that
1. If A sends the form to a jsp page C, C can receive it and display the parameters correctly.
2. Even if after I rewrite the content inside B's doPost method to be empty, B still cannot be found by the server.
3. I hosted the application in 2 different PCs. I got the same errorfrom both of them.

Does anyone encounter this kind of thing before? what might be the solution?
18 years ago
I am running it on a tomcat server.
18 years ago
Hi. I have an applet invoked by a jsp page.

<APPLET height=500 width=900
code="applet/trend/trendchart">
</APPLET>

I got this this error:

java.lang.NullPointerException
at java.applet.Applet.getCodeBase(Unknown Source)
at applet.trend.trendchart.getServletConnection(trendchart.java:212)
...

in what kind of situation getCodeBase() can return a null value?
18 years ago
I encountered this problem today and looking for an answer.
I have an applet which can query a servlet and get an object back from that servlet.
Here is the codes:
Applet:
URL urlServlet = new URL("...");
URLConnection con = urlServlet.openConnection();

con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty(
"Content-Type",
"application/x-java-serialized-object");
...
// send data to the servlet
URLConnection con = getServletConnection();
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject("");
oos.flush();
oos.close();

// receive result from servlet
InputStream instr = con.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
Object result = inputFromServlet.readObject();
inputFromServlet.close();
instr.close();

servlet:
res.setContentType("application/x-java-serialized-object");

// read an object from applet
InputStream in = req.getInputStream();
ObjectInputStream inputFromApplet = new ObjectInputStream(in);
String temp = (String) inputFromApplet.readObject();

// send back an obect to the applet
OutputStream outstr = res.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstr);
oos.writeObject(returned);//should change to returned
oos.flush();
oos.close();

However, when I run this applet I got an error message:
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at applet.trend.trendchart.getData(trendchart.java:238)
...

Can anyone help me to figure out what went wrong?
Thanks.
18 years ago
Finally I cleared my part 1!!!
2 weeks ago I tried once and failed:

score:66
Concepts:50%
Component Archetecture:50%
Legacy Connectivity:60%
EJB:66%
EJB container model:75%
Protocols:100%
Applicability of J2EE:33%
Design Patterns:100%
Messaging:100%
Internationalization:50%
Security:50%

This time my score is slightly better than previous one:
score: 70
concepts:100%
Common Archetectures:33%
Legacy Connectivity:20%
EJB:77%
EJB container Model:50%
Protocols: 100%
Applicability of J2EE:100%
Design Patterns:80%
Messaging:100%
Internationalization:100%
Secutity:50%

not a good score... But I still believe SCEA will become the first certificate I get in IT.
I have java codes like this:

String sql="select energy_etc.kwhexp from ...";
System.out.println(sql);
Statement kwhexp_stmt = conn.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet kwhexp_rs = kwhexp_stmt.executeQuery( sql);
double d=1.1;
while(kwhexp_rs.next()){
kwhexp_rs.updateDouble("kwhexp",d);
kwhexp_rs.updateRow();
d++;
}

When I execute these codes I got a error message:
Exception in thread "main" java.sql.SQLException: Invalid operation for read onl
y resultset: updateDouble
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
at oracle.jdbc.driver.BaseResultSet.updateDouble(BaseResultSet.java:225)
at oracle.jdbc.driver.OracleResultSet.updateDouble(OracleResultSet.java:2816)
at MonthlyBillGeneration.main(MonthlyBillGeneration.java:34)


What could be the reason I cannot update my result set?
Thanks Santosh Pasupuleti.
Here is my section analysis:
Concepts:50%
Component Archetecture:50%
Legacy Connectivity:60%
EJB:66%
EJB container model:75%
Protocols:100%
Applicability of J2EE:33%
Design Patterns:100%
Messaging:100%
Internationalization:50%
Security:50%