Server threads
how can i know server threads allocated to the Essbase Server process. If it is default server threads ,it depends on the ports.
Could u please tell how server threads depend on ports
Thanx for yuor information sandeep.
But my intention is to know the server threads(exact count) allocated to the Essbase Server process initially.
I know that it equals to some value depending on the default ports.
But the ports are of three types here.
In our case,
number of ports in use = 1
number of ports available =65534
number of licensed ports = 65535
I am not sure of licensed ports as i have taken that value in the LICENSE tab having number of installed ports.
Now my question is to know the server threads which ports i have to consider
Your advise is highly appreciated
Similar Messages
-
Java.rmi.ServerException: RemoteException occurred in server thread
I have written a simple CMP Entity Bean,While Running the Client I am getting the Exception,I have included all jars needed.
EXCEPTION IS
err in HomeCreatejava.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: Could not instantiate bean; nested exception is:
java.lang.InstantiationException; nested exception is:
java.rmi.ServerException: Could not instantiate bean; nested exception is:
java.lang.InstantiationException
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: Could not instantiate bean; nested exception is:
java.lang.InstantiationException; nested exception is:
java.rmi.ServerException: Could not instantiate bean; nested exception is:
java.lang.InstantiationException
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:287)
at sun.rmi.transport.Transport$1.run(Transport.java:151)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:147)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:463)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.lang.Thread.run(Thread.java:539)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:250)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:226)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:136)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:128)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:185)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
at $Proxy0.create(Unknown Source)
at StudentClient.main(StudentClient.java:39)
Caused by: java.rmi.ServerException: Could not instantiate bean; nested exception is:
java.lang.InstantiationException; nested exception is:
java.rmi.ServerException: Could not instantiate bean; nested exception is:
java.lang.InstantiationException
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:140)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at org.jboss.ejb.Container.invoke(Container.java:726)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:362)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
at java.lang.reflect.Method.invoke(Method.java:313)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:256)
at sun.rmi.transport.Transport$1.run(Transport.java:151)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:147)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:463)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.lang.Thread.run(Thread.java:539)
Caused by: java.rmi.ServerException: Could not instantiate bean; nested exception is:
java.lang.InstantiationException
at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:211)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:122)
at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
... 20 more
Caused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:33)
at java.lang.reflect.Constructor.newInstance(Constructor.java:263)
at java.lang.Class.newInstance0(Class.java:301)
at java.lang.Class.newInstance(Class.java:254)
at org.jboss.ejb.plugins.BMPPersistenceManager.createBeanClassInstance(BMPPersistenceManager.java:145)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createBeanClassInstance(CachedConnectionInterceptor.java:251)
at org.jboss.ejb.EntityContainer.createBeanClassInstance(EntityContainer.java:294)
at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:208)
... 24 more
Pls explain what can i do now.
regards,
NaveenBabu.A
my client code is
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import java.util.*;
import student.student1.*;
public class StudentClient
public static void main(String args[])
System.out.println("i am in start");
StudentHome home= null;
try{
System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
System.setProperty("java.naming.provider.url", "localhost:1099");
Context context = new InitialContext();
try{
home = (StudentHome)PortableRemoteObject.narrow(context.lookup("Student"), StudentHome.class);
}catch(Exception e){System.out.println("err in StudentHome"+e);}
/* try{
home.create("Ammamn","A01");
}catch(Exception e){System.out.println("err in HomeCreate"+e);}*/
}catch(Exception e){System.out.println("error in client"+e);}
System.out.println("i am in end");
}Try this,
Context context = new InitialContext(System.getProperties()); -
RemoteException: 111 java.rmi.ServerError: Error occurred in server thread
Hi,
I'm just new to the RMI field of JAVA. I'm trying to write a program that import the math.jar file in the server side. And the client end can invoke the methods of math.jar and get the value.
I got the error messages as below:
RemoteException: 111 java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.NoClassDefFoundError: org/mathwhizz/Heron
It can work well if I use source classes(*.class) directly instead of importing math.jar. The failure only happened when I try to make use of jar file. Thus I guess my setup and configuration should be ok. Is there anything I should be very careful if I try to run RMI and import a jar file in the program of server side ?
Do I need to use JNLP and web start application in this issue?
I'm appreciated for your responses...thanks...
Sincerely,
BrandonI've got a problem with rmi, when I launch my server, I have this error:
Erreur du remote: java.rmi.ServerError: Error occurred in server thread; nested exception is:
java.lang.NoClassDefFoundError: com/borland/dx/dataset/DataSetData
Help me please
Thank you -
Hi,
I am trying to load metadata using ODI 11.1.1.7 into Hyperion Planning 11.1.2.4. It errored out saying
Cannot load dimension member, error message is: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object.
Source - File
Please let me know if there is any fix to this.
Thanks,
SravanDid you definitely follow the steps in "How to Apply ODI Patch 18687916 for Hyperion Planning and Errors that May Occur if Patch Has Not Been Applied Correctly (Doc ID 1683307.1)"
If you are still getting the error if everything in the support doc has been done then maybe the issue relates to 11.1.2.4
It is interesting to see the Oracle state of direction doc have the following statement:
"The KM's for EPM release 11.1.2.3 and ODI release 11.1.1.7 are not certified with EPM Release 11.1.2.4."
Cheers
John
http://john-goodwin.blogspot.com/ -
Java Server Threading Problems
Cross-posted at: http://www.java-forums.org/networking/41574-server-threading-confusion.html with no answers as of this edit.
I'm very new to networking in java, and it's been a few months since I last did any major programming. I decided to try out networking, and I'm beginning to get a feel for it, but I've jumped in to trying to make a server for a multiplayer game, and I've gotten a bit stuck about how to do it, specifically on how to use threads to take care of my clients, and still be able to keep track of the threads so I can have the server send out info to them about where characters are, when the threads should close because someone wants to log out, etc.
If anyone could help me out that would be awesome :D
Here's some code:
import java.net.*;
import java.io.*;
public class GameThread extends Thread // this is the actual thread class I made
public Socket socket;
public DataInputStream in;
public DataOutputStream out; // a socket and two I/O streams for sending ints
public GameThread(Socket socket) // typical constructor for getting socket
try
this.socket = socket;
in = new DataInputStream(socket.getInputStream());
out = new DataOutputStream(socket.getOutputStream());
catch(Exception e)
e.printStackTrace();
public Socket getSocket() // I don't believe this is ever used. Ignore it.
return socket;
public void print() // Used to make sure the thread is active/knows about the socket
System.out.println("GameThread says: " + socket);
public void run()
while(true)
}Here's the class I use to manage the threads, or, at least, where I attempt to do so.
import java.io.*;
import java.util.ArrayList;
import java.net.*;
public class Threader
public ArrayList clients;
public ArrayList<GameThread> threads; // GameThread is the thread class above
public Threader()
threads = new ArrayList<GameThread>(); //constructor for this arraylist
public void updateClientCount(ArrayList<Socket> clients) // this method works
this.clients = clients; // it's not the problem.
public void openThreads() //Here's probably where problems begin
if(clients.size() > threads.size()) // this is to make the threads arraylist
int f = clients.size()-threads.size();//equal length compared to clients arraylist
while(f > 1)
threads.add(null);
f--;
if(clients.size() < threads.size()) //same as above, just if threads is bigger
threads.subList(clients.size(),(threads.size()-1)).clear();
for(int h=0;h<clients.size();h++) //Here: for each client spot
if(threads.get(h) == null) //Threads is tested in that spot to see if there's
{ // A thread there
GameThread gt = new GameThread((Socket)clients.get(h));
threads.add(gt); //and if there isn't then it makes one
gt.start(); // and starts it, but I guess this isn't happening as I want
} // it to because in the method below none of the GameThreads print socket info
public void print() //used to make sure the Threader/GameThread(s) is getting the info
for(int y = 0;y<clients.size();y++)
System.out.println("Threader says: " + clients.get(y));
for(int x = 0;x<threads.size();x++)
threads.get(x).print();
}If anyone could help me find what is going on, or maybe (probably) I'm going about making a server wrong (I have another class with a serversocket and all, but I don't believe there are any bugs in it so it isn't included in here), so if I could get help that would be awesome.
Thanks guys!
Edited by: 848780 on Mar 30, 2011 8:55 PM
Edited by: 848780 on Mar 30, 2011 11:55 PMYour thread management is back to front. All you need is a new thread per client, started every time you accept a new Socket. When you do that, if you want to manage them, enter the new thread into a collection, and when it exits remove it. But you normally don't need to keep track of client threads. You may want to keep track of client Sockets, in which case you should maintain a collection of Sockets on the same basis.
-
How to take OIM Managed server Thread Dump
Hi All,
how can i take the oim managed server thread dump
I used wlst command for this lyk follows
kill -3<pid>
./wlst.sh
connect("weblogic","password","t3://hostname:port")
threadDump()
but it is giving Admin server dump, i want oim managed server threadDump how can i get thishi kalyan,
after connecting to wlst
i tried these steps
cd('Servers')
cd('server_oim_DEV')--which is my managed server name
threadDump()
after this i got the threadDump but i dont think so i am getting different file
when i open this it is mentioned lyk Admin server dump
is this the ryt process and can i know the ryt process to take managed server thread Dump -
How to getr StackTraces of all server threads
Hi all,
I've tried to get stacktraces for all threads on Sun Java Application Server V8. I followed the manual. I tried CTRL+\ in verbose mode. But i think i got only stack traces of some supporting java process, not of the whole server. So my question is quite simple. How to get stacktraces of all server threads on Windows 2003 server?
I need to find some time consuming thread.
Thank you for your advice.
DadmanOn the Windows server, you can get a full java stackdump to push the 'Break' key.
I also verified in my env.
Hope this help.
Thanks,
- Nocky -
Aplication server thread pool problem
I'm using sun app server 8.
After some time from starting (and using) the server, it stops responding to clients.
When I change the max number of threads on server the number of clients it can serve before hanging folows the change. So I guess that some threads are not recycled.
But, I can't get full thread dump to see what's happening.
Also I can't get any thread pool monitoring information through asadmin.
(I can see that EJB's are all removed successfuly)
Any suggestions.
Thanks in advance.First of all, thank you for helping me.
The client wasn't making problems, but server did. (I didn't said that I use the app. server on XP.)
For now I solved the problem by installing the new beta 2004Q4. It works fine now, it also has some thread monitoring in web console...
I was getting this, when I tried to monitor the thread-pool (it is set on HIGH):
asadmin> get -m server.thread-pools.thread-pool.thread-pool-1.*
No matches resulted from the wildcard expression.
CLI137 Command get failed.
If it means anything this is what I was getting when I do ctrl-break. (this thread dump stays the same even after server stops responding...)
Full thread dump Java HotSpot(TM) Client VM (1.4.2_04-b04 mixed mode):
"Thread-6" prio=5 tid=0x02edad08 nid=0xb40 runnable [331f000..331fd8c]
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:177)
at org.apache.commons.launcher.StreamConnector.run(StreamConnector.java:
115)
"Thread-5" prio=5 tid=0x02ebbb98 nid=0x8ac runnable [32df000..32dfd8c]
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:194)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:220)
at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
- locked <0x10089900> (a java.io.BufferedInputStream)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
at org.apache.commons.launcher.StreamConnector.run(StreamConnector.java:
115)
"Signal Dispatcher" daemon prio=10 tid=0x0093dc18 nid=0x930 waiting on condition
[0..0]
"Finalizer" daemon prio=9 tid=0x008a5c20 nid=0xbd0 in Object.wait() [2b5f000..2b
5fd8c]
at java.lang.Object.wait(Native Method)
- waiting on <0x10502a00> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
- locked <0x10502a00> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=10 tid=0x008a47f0 nid=0xb4 in Object.wait() [2b1
f000..2b1fd8c]
at java.lang.Object.wait(Native Method)
- waiting on <0x10502a68> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:429)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
- locked <0x10502a68> (a java.lang.ref.Reference$Lock)
"main" prio=5 tid=0x000362a0 nid=0xc38 runnable [7f000..7fc3c]
at java.lang.Win32Process.waitFor(Native Method)
at org.apache.commons.launcher.LaunchTask.execute(LaunchTask.java:705)
at org.apache.tools.ant.Task.perform(Task.java:341)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:336)
at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
at org.apache.commons.launcher.Launcher.start(Launcher.java:402)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at LauncherBootstrap.main(LauncherBootstrap.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.enterprise.admin.servermgmt.pe.PEInstancesManager.startInstan
ce(PEInstancesManager.java:115)
at com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager.startDomain(P
EDomainsManager.java:126)
at com.sun.enterprise.cli.commands.StartDomainCommand.runCommand(StartDo
mainCommand.java:59)
at com.sun.enterprise.cli.framework.CLIMain.invokeCommand(CLIMain.java:1
23)
at com.sun.enterprise.cli.framework.CLIMain.main(CLIMain.java:39)
"VM Thread" prio=5 tid=0x0093c698 nid=0x9b4 runnable
"VM Periodic Task Thread" prio=10 tid=0x00940438 nid=0xbd4 waiting on condition
"Suspend Checker Thread" prio=10 tid=0x0093d2b8 nid=0x2c0 runnable -
I am still getting the server thread issue (see earler posting), despite having increased the SERVERTHREADS parameter. We seem to hit a limit on the number of applications that can be loaded at any one time, and as soon as it is reached, the error appears. Unload a few applications and the error temporarily goes away.When looking at the disk swapping section in the "System Info" tab of the "Server Information" dialog, the status is "Enabled, File not Found". We have less than 4Gbs of memory (3,833,168), so Essbase should be able to display the swap file. The servers that we are experiencing this problem have Windows 2003 installed, with Essbase 6.5.5. The old server that does have this problem is running Windows 2000 and Essbase 6.5.5.On the compatibility section of the Hyperion web-site, they confirm that Essbase 6.5.5 and Windows 2003 will work.Any ideas, apart from installing Windows 2000, which apparently isn't an option?!Cheers,Doug
I think I've found the problem! It seems the server team didn't set up the swap file, hence, when physical memory started to run a little low on the box, the thread could not be created. FYI, we had already increased the SERVERTHREADS option in the Essbase.cfg file.
-
Error 1013000 loading application: Unable to Create Request Server Thread
We are currently getting the following error "Error 1013000 loading application: Unable to Create Request Server Thread" when attempting to load more than 5 applications onto our new Essbase server. The O/S is Windows 2003 and we are running Essbase 6.5.5. Our old server, running Windows 2000, is not experiencing this problem.
I think I've found the problem! It seems the server team didn't set up the swap file, hence, when physical memory started to run a little low on the box, the thread could not be created. FYI, we had already increased the SERVERTHREADS option in the Essbase.cfg file.
-
Help needed with diagnosis of WebLogic server thread dump
Sorry, my mistake - I was trying to search for "weblogic" before the dump file
loaded fully.... I am not very familiar with VisiBroker and may be totally
wrong, but my guess is it creates a thread for each connection/client. I would
look for VisiBroker properties or settings that could limit the runaway creation
of threads....
Arunabh
"Dimitri I. Rakitine" wrote:
It is, preceded by lots and lots of CORBA (visibroker) threads. Is it
possible that application code
creates new ORBs more often than it should ?
"Arunabh Hazarika" <[email protected]> wrote in message
news:[email protected]...
The attached file does not look like a WebLogic Server thread dump.....
Arunabh
Kapil Singh Pawar wrote:
I am running a web application on WebLogic server 6.0 sp2 + rp1 (HP-UX).
After
I start loading the web application with more users I constantly get thejava.lang.OutOfMemoryError.
I tried increasing the max_thread_proc kernel parameter to 2048 but thatdoes
not seem to help much. Here is the error that I get on the WebLogicServer console.
<Oct 7, 2002 5:00:27 PM GMT+02:00> <Error> <HTTP><[WebAppServletContext(1828590,i2)]
Servlet failed with Exception
java.lang.OutOfMemoryError: max threads limit being reached in VM
at java.lang.Thread.start(Native Method)
at netscape.ldap.LDAPConnThread.<init>(LDAPConnThread.java:112)
atnetscape.ldap.LDAPConnection.getNewThread(LDAPConnection.java:1117)
atnetscape.ldap.LDAPConnection.connect(LDAPConnection.java:1034)
at netscape.ldap.LDAPConnection.connect(LDAPConnection.java:915)
at netscape.ldap.LDAPConnection.connect(LDAPConnection.java:759)
atcom.i2.scm.LDAP.ScmLDAPDefaultAuthenticate.authenticate(ScmLDAPDefaultAuthen
ticate.java:129)
at scmldap.service(scmldap.java:452)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
atweblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1302)
atweblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1676)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
I am posting the thread dump obtained at the OutOfMemoryError stage. Anyhelp
in diagnosing the thread dump and possible fix for this error is highlyappreciated.
For information sake, while the web application encountersOutOfMemoryError the
example web apps and WebLogic console application work fine. So it looksto be
a case of memory outage only for my custom application.
Thanks
Kapil Singh Pawar
Name: thread_dump.txt
thread_dump.txt Type: Plain Text (text/plain)
Encoding: base64--
Dimitri -
Loosing datasource connection in a server thread
Hi,
In a backing bean I start a long term thread that uses the datasource connection taken from application module.
Everything works fine but after a period of time between one and two hours the connection is lost and server throws a
<BEA-001112> <Test "SELECT 1 FROM DUAL" set up for pool "AEE2010DS" failed with exception: "java.sql.SQLException: Connection Closed".>
Is there any way to stop the server from closing the connection that is used in a separate thread, programmatically or using configuration?
Any comment will be helpful,
ThanksThat looks like something external is killing the connection, either the DBMS or a firewall.
-
Server thread for Chat server error
hey i am trying to make a server for a simple chat service..i have written the code for the server but in my ChatServer thread in the run() function it is giving a null pointer exception...please help me out in this as unless the server is not running i can procede on checking my client code.
i am attaching the code for my ChatServer.java
import java.net.ServerSocket;
import java.net.Socket;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.io.IOException;
import java.lang.Thread;
@SuppressWarnings("unused")
public class ChatServer extends Thread
Thread thread;
Socket socket;
ServerSocket serversocket;
ArrayList<ClientObj> userarraylist;
@SuppressWarnings("unchecked")
ArrayList messagearrayList;
ClientObj clientobject;
public ChatServer()
@SuppressWarnings("unchecked")
public void StartServer()
try{
serversocket = new ServerSocket(4567);
}catch(IOException e) { }
userarraylist = new ArrayList();
messagearrayList = new ArrayList();
thread = new Thread(this);
thread.start();
public void run()
while(true)
try{
socket = serversocket.accept(); //I AM GETTING AN EXCEPTION HERE
System.out.println("Waiting for connection");
}catch(IOException e) { }
ChatFunctionality chatFunc = new ChatFunctionality(this,socket);
public ClientObj GetClientObject(String UserName)
ClientObj returnClientObject = null;
ClientObj TempClientObject;
int m_userListSize = userarraylist.size();
for(int j = 0; j < m_userListSize; j++)
TempClientObject = (ClientObj) userarraylist.get(j);
if(TempClientObject.getUserName().equalsIgnoreCase(UserName))
returnClientObject = TempClientObject;
break;
return returnClientObject;
public boolean IsUserExists(String UserName)
if(GetClientObject(UserName) != null)
return true;
else
return false;
public void SendMessageToClient(Socket clientsocket,String message)
String sSentence = message;
try{
DataOutputStream outToClient = new DataOutputStream(clientsocket.getOutputStream());
outToClient.writeBytes(sSentence + '\n');
}catch(IOException e) { }
public void AddUser(Socket clientSocket,String UserName)
if(IsUserExists(UserName))
SendMessageToClient(clientSocket,"EXISTS");
return;
clientobject = new ClientObj(clientSocket,UserName);
userarraylist.add(clientobject);
public void SendListOfUsers(Socket clientSocket)
int listCount = userarraylist.size();
for(int i=0;i<listCount;i++)
String name = userarraylist.get(i).ClientUserName;
SendMessageToClient(clientSocket,name );
public void SendMessageToAll(String Message)
int UserCount = userarraylist.size();
for(int k=0;k<UserCount;k++)
ClientObj TempClient = userarraylist.get(k);
SendMessageToClient(TempClient.Clientsocket,Message);
public static void main(String[] args)
ChatServer chatserver = new ChatServer();
chatserver.StartServer();
return;
}So lets have a look at your error.
java.net. --------------->BindException<-------------------: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at ChatServer.StartServer(ChatServer.java:36)
at ChatServer.main(ChatServer.java:132)It clearly states that you have an [BindException. |http://java.sun.com/j2se/1.4.2/docs/api/java/net/BindException.html] So now we go to the java api and look up BindException to find out what it is. And after a have found out what it is, we fix the problem.
Tell me how you solve the problem after reading what it is.(A hint, try: 4444)
EDIT: After checking with NETSTAT command in windows cmd, I dont find port 4567 being used.. So it might not be the reason. But it sertainly is worth a try.
Edited by: prigas on Jul 6, 2008 1:15 AM -
When I invoke the method getNextJob() in my Client.
This sends a this message (CLNT::GETNEXTJOB) to the server which then triggers the Server to invoke the corresponding method and send back another message. (Which as far as I know it does).
My problem is this, when I run the getNextJob() method a thread is supposed to be created and ran in parallel which listens for the Servers reply and unfortunately this thread keeps telling me that its get a NullPointerException (specifically at my Socket connection clientSocket). If I uncomment out this.openConnection(); within my run() method it works BUT I get no response from my server even though it is telling me it has sent a message.
I hope you can help.
OUTPUTTED TEXT
CLIENT: Building GUI
CLIENT: Get Next Job Invoked
CLIENT: Opening Connection
CLIENT: Socket is now OPEN
CLIENT: Listerner Loaded
Exception in thread "Thread-2" java.lang.NullPointerException
CLIENT ->CLNT::GETNEXTJOB JAVA CODE
package Client;
import java.net.*;
import java.io.*;
public class Kernel implements Runnable {
//Socket Variables & Streams
Socket clientSocket;
//variables
private boolean msgReceived = true;
private String faultNumber;
//listening thread
public void run() {
String serverMessage = "ERROR: run";
System.out.println("CLIENT: Listerner Loaded");
//builds listener
try {
//this.openConnection();
//opens socket connection
BufferedReader in = new BufferedReader(
new InputStreamReader(
this.clientSocket.getInputStream()));
BufferedReader stdIn = new BufferedReader(
new InputStreamReader(
System.in));
while((stdIn.readLine()) != null) {
System.out.println("CLIENT: Listener Received Line = " + stdIn.readLine());
serverMessage = stdIn.readLine();
System.out.println(in.readLine());
msgReceived = false;
in.close();
stdIn.close();
} catch(IOException e) {System.err.println("Error Details:" + e);}
//sets current Tail to new value returned
this.setCurrentTail(serverMessage);
private void openConnection() throws IOException{
try {
System.out.println("CLIENT: Opening Connection");
this.clientSocket = new Socket("localhost", 4444);
} catch (UnknownHostException e) {
System.err.println("CLIENT: Host not found");
System.exit(1);
} catch (IOException e) {
System.err.println("CLIENT: Couldn't get I/O for the connection to: Brenda.");
System.exit(1);
public String getNextJob()
System.out.println("CLIENT: Get Next Job Invoked");
try{
//opens socket connection
this.openConnection();
//waits for the socket to open
System.out.println("CLIENT: Socket is now OPEN");
//invokes Listener
(new Thread(new Kernel())).start();
//sends a message
this.sendMessage("CLNT::GETNEXTJOB");
//waits for a reply from the server
//while(msgReceived){}
//closes socket connection
//this.closeConnection();
}catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to: taranis.");
System.exit(1);
return this.getCurrentTail();
private void setCurrentTail(String tail) {
this.faultNumber = tail;
private String getCurrentTail() {
return this.faultNumber;
private void closeConnection()
try{
clientSocket.close();
System.out.println("CLIENT: Connection Closed");
}catch (IOException e) {e.printStackTrace();}
private void sendMessage(String strMessage){
try{
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
out.println(strMessage);
System.out.println("CLIENT ->" + strMessage);
//Closes output stream.
out.close();
}catch(IOException e){System.err.println(e);}
}Edited by: DaveyB on Sep 2, 2009 3:19 PMI have made some modifications based on the above information but I have hit another brick wall.
The below code returns this to the output pane:
run:
CLIENT: Building GUI
CLIENT: Get Next Job Invoked
Never Reached Statement Within getNext StartValue
CLIENT: Listerner Loaded
CLIENT: Opening Connection
CLIENT ->CLNT::GETNEXTJOB
STATEMENT NEVER REACHED
null
ErrorWhat you can see is the CLIENT sets up the connection and invokes the Listener thread (run). When this is ran it hits the while loop and even when a non null value is returned via the .ReadLine() as shown via the second value in the output pane {'null', 'Error'} it doesn't exit the loop.
Any ideas why this would be.
package webtoolclient;
import java.net.*;
import java.io.*;
public class Kernel implements Runnable {
//Socket Variables & Streams
Socket clientSocket = null;
BufferedReader in = null;
PrintWriter out = null;
//variables
private String faultNumber = "StartValue";
private boolean isListenerLoaded = false;
//listening thread
public void run() {
//String serverMessage = "ERROR: run";
System.err.println("CLIENT: Listerner Loaded");
//builds listener
try {
//opens socket connection
this.openConnection();
//sends a message
this.sendMessage("CLNT::GETNEXTJOB");
//creates inputstreams
in = new BufferedReader(
new InputStreamReader(
this.clientSocket.getInputStream()));
String line = null; // in.readLine();
while((line = in.readLine()) != null){
System.out.println(line);
System.out.println("STATEMENT NEVER REACHED WITHIN THREAD line = " + line);
this.setCurrentTail(line);
this.isListenerLoaded = true;
//in.close();
//stdIn.close();
//this.closeConnection();
} catch(IOException e) {System.err.println("Error In run: " + e);}
//sets current Tail to new value returned
//this.setCurrentTail(line);
private void openConnection() throws IOException{
try {
System.err.println("CLIENT: Opening Connection");
this.clientSocket = new Socket("localhost", 4444);
} catch (UnknownHostException e) {
System.err.println("CLIENT: Host not found");
System.exit(1);
} catch (IOException e) {
System.err.println("CLIENT: Couldn't get I/O for the connection to: Brenda.");
System.exit(1);
public String getNextJob()
System.err.println("CLIENT: Get Next Job Invoked");
//try{
//opens socket connection
//this.openConnection();
//waits for the socket to open
//System.err.println("CLIENT: Socket is now OPEN");
//invokes Listener
new Thread(this).start();
//ensures Listerner is open before message is sent.
while(this.isListenerLoaded){}
//waits for a reply from the server
//while(this.getCurrentTail().equals("StartValue")){}
System.err.println("Never Reached Statement Within getNext " + this.getCurrentTail());
//closes socket connection
//this.closeConnection();
return this.getCurrentTail();
/*}catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to: taranis.");
System.exit(1);
//return this.getCurrentTail();
private void setCurrentTail(String tail) {
this.faultNumber = tail;
private String getCurrentTail() {
return this.faultNumber;
private void closeConnection()
try{
clientSocket.close();
System.err.println("CLIENT: Connection Closed");
}catch (IOException e) {e.printStackTrace();}
private void sendMessage(String strMessage){
try{
out = new PrintWriter(clientSocket.getOutputStream(), true);
out.println(strMessage);
System.err.println("CLIENT ->" + strMessage);
//Closes output stream.
//out.close();
}catch(IOException e){System.err.println(e);}
} -
Server, thread and limited connexions
I use this code for my server. I got it from the book "Java thread" written by Scott Oaks and Henry Wong" and edited by O'Reilly.
This code works very good. I just want to implement a limited allowed connexions at a same time (ie 20 or 30 connexions possible at a same time).
I think a simple count of the created threads isn't enougth because i can't figure out how to decrease it. I was thinking using thread pool and counting the threads inside, so that i know exactly how many connexions are opened.
Any advice about this is welcome.
Here is the code :
import java.net.*;
import java.io.*;
public class TCPServer implements Cloneable, Runnable
Thread runner = null;
ServerSocket server = null;
Socket data = null;
boolean ShouldStop = false;
public synchronized void startServer(int port) throws IOException
if(runner == null)
server = new ServerSocket(port);
runner = new Thread(this);
runner.start();
public synchronized void stopServer()
if(server != null)
ShouldStop = true;
runner.interrupt();
runner = null;
try
server.close();
catch(IOException ioe)
//ioe.printStackTrace();
server = null;
public void run()
if(server != null)
while(!ShouldStop)
try
Socket datasocket = server.accept();
TCPServer newSocket = (TCPServer) clone();
newSocket.server = null;
newSocket.data = datasocket;
newSocket.runner = new Thread(newSocket);
newSocket.runner.start();
catch(Exception e)
else
run(data);
public void run(Socket data)
}This class is used to implement the server. A derivated class is used to treat the connexion. I wish to implement the counter in this class if possible.
In advance thanks.To define the maximum allowed connections, use this constructor for ServerSocket
public ServerSocket(int port, int backlog)Backlog being the maximum allowed connections at a time. Any aditional connection attempts will be rejected.
public class TCPServer implements Cloneable, Runnable{
Thread runner = null;
ServerSocket server = null;
Socket data = null;
boolean ShouldStop = false;
private final int MAXIMUM_CONNECTIONS = 20; //or 30 or whatever you want your maximum to be
public synchronized void startServer(int port) throws IOException {
if(runner == null) {
server = new ServerSocket(port, MAXIMUM_CONNECTIONS);
runner = new Thread(this);
runner.start();
public synchronized void stopServer() {
//.......etc
}
Maybe you are looking for
-
Thunderbolt display long beep when plugged in to macbook
I have a MacBook Pro and connect it to a Thunderbolt display. After downloading Yosemite, whenever I connect to my display it makes a long, continuous (about 1-2 minute) beeping noise. The noise repeats every few minutes. It is loud and high pitch
-
Hi What does commit=y mean when use it with import syntax? bye.
-
Move recorded document between scripts using session map
Hi all experts on scripting! We have a 2 scripts ! First script is a callback script that is recording a message from the calling customer which is saved in a"recorded document" that will be played towards an Agent when he/she is picking up the callb
-
Updating current record using SET_CUSTOM_PROPERTY in a multi-record form
Hi, I have a multi record form and am using the SET_CUSTOM_PROPERTY method in the when validate trigger of an item. The problem is that it updates all records in the form instead of updating just the current record. Any inputs to resolve this would b
-
Dear all, Your urgent help required. i was updating my nokia e65 and only 12 minutes where left when i had and electricity failure and my pc restarted. now my phone is not starting. please suggest as i dont have any nokia care center near by.urgent h