Calling run method
Hi frnds,
Why do we need to call thread.start() to execute a thread. why not just calling run().
run() is just a method...
you need new Thread object to start a new thread...
you can pass any Runnable object ( any class that implements the Runnable interface ) and when the start() method is called, the code in the Runnable's run() method will be executed in that new thread...
btw, you can always try calling the run() method an see the results...
- MaxxDmg...
- ' He who never sleeps... '
Similar Messages
-
How run method is called in a thread
Hello,
If I call start method of a thread, then I want to know if run method is automatically called or not.
Thank youA tutorial on threads would doubtlessly contain much of the information you're after. There might be something in the Java Tutorial that's worth looking at.
Have you tried it to find out what the behaviour is? It's really not very surprising...
In summary, though:
The run method of a Thread is called when the Thread is started. You can confirm this by overriding the run method if you want:
Thread myThread = new Thread() {
public void run() {
System.out.println("WOO HOO - Run!!");
System.out.println("Starting thread");
myThread.start();
System.out.println("Thread started");Hope this helps. -
Calling Appmodule method in Run() method
Hi all,
I am usin bindings inside the run method.I am getting below error.
oracle.adf.controller.ControllerException: ADFC-04007: The FacesPageLifecycleContext does not exist yet.
MyCode:
public void run() {
for(int i =0; i < billingNo.length ; i++){
BindingContainer bindings = getBindings();
OperationBinding operationBindingValues=null;
Map paramMap=null;
operationBindingValues = bindings.getOperationBinding("methodCall");
paramMap=operationBindingValues.getParamsMap();
paramMap.put("billingNo",billingNo);
paramMap.put("orderId",orderId);
paramMap.put("region",region.toString());
paramMap.put("type",type);
operationBindingValues.execute();
Please do me need full.This won't work this way. How do you suppose to get the result when the query is finished?
As you have done other things the result will be lost (in space) as nobody can get to it. It's destroyed when the thread finished it's work.
If you have long running queries you need to think on how to get the result once the query has finished. If you are doing a report you can e.g. store the result in a file or the db and give the user some way how he can access the result once it's ready.
You can't just use an application module in a thread as the application module you use in the request can be used by other users in the mean time (application module pooling). In general you have to create a new application module in your thread and release it once the tread has finished it's work. The thread should encapsulate it's work as you don't know when it's finished. One way to implement this is to move the method in the application module and call it as asynchronous web service. Still my feeling is that all this is way too complicated.
Can you elaborate on the use case a bit more?
How long do you expect it to run? How often does it run? What the result of the thread?
Timo -
Run method of an object called twice before first completed
Hello Everyone,
I have an object which has a run method. What will happen if the run method is called while the object is currently executing its run method.
Sincerely,
Justin DallasIts threads which execute code, not objects.
If you call run() in two different threads at once, they will both execute run() at the same time. Whether this causes a problem or not depend on whether run() is thread-safe. -
Error while calling a method on Bean (EJB 3.0)
I am getting an error while calling a method on EJB. I am using EJB3.0 and my bean is getting properly deployed(i am sure b'cos i can see the successfullly deployed message). Can any body help me
Error is -->
Error while destroying resource :An I/O error has occured while flushing the output - Exception: java.io.IOException: An established connection was aborted by the software in your host machine
Stack Trace:
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:33)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:104)
at sun.nio.ch.IOUtil.write(IOUtil.java:75)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:302)
at com.sun.enterprise.server.ss.provider.ASOutputStream.write(ASOutputStream.java:138)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at org.postgresql.PG_Stream.flush(PG_Stream.java:352)
at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:159)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:70)
at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:482)
at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:461)
at org.postgresql.jdbc1.AbstractJdbc1Connection.rollback(AbstractJdbc1Connection.java:1031)
at org.postgresql.jdbc2.optional.PooledConnectionImpl$ConnectionHandler.invoke(PooledConnectionImpl.java:223)
at $Proxy34.close(Unknown Source)
at com.sun.gjc.spi.ManagedConnection.destroy(ManagedConnection.java:274)
at com.sun.enterprise.resource.LocalTxConnectorAllocator.destroyResource(LocalTxConnectorAllocator.java:103)
at com.sun.enterprise.resource.AbstractResourcePool.destroyResource(AbstractResourcePool.java:603)
at com.sun.enterprise.resource.AbstractResourcePool.resourceErrorOccurred(AbstractResourcePool.java:713)
at com.sun.enterprise.resource.PoolManagerImpl.putbackResourceToPool(PoolManagerImpl.java:424)
at com.sun.enterprise.resource.PoolManagerImpl.resourceClosed(PoolManagerImpl.java:393)
at com.sun.enterprise.resource.LocalTxConnectionEventListener.connectionClosed(LocalTxConnectionEventListener.java:69)
at com.sun.gjc.spi.ManagedConnection.connectionClosed(ManagedConnection.java:618)
at com.sun.gjc.spi.ConnectionHolder.close(ConnectionHolder.java:163)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.closeDatasourceConnection(DatabaseAccessor.java:379)
at oracle.toplink.essentials.internal.databaseaccess.DatasourceAccessor.closeConnection(DatasourceAccessor.java:367)
at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.closeConnection(DatabaseAccessor.java:402)
at oracle.toplink.essentials.internal.databaseaccess.DatasourceAccessor.afterJTSTransaction(DatasourceAccessor.java:100)
at oracle.toplink.essentials.threetier.ClientSession.afterTransaction(ClientSession.java:104)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.afterTransaction(UnitOfWorkImpl.java:1816)
at oracle.toplink.essentials.transaction.AbstractSynchronizationListener.afterCompletion(AbstractSynchronizationListener.java:161)
at oracle.toplink.essentials.transaction.JTASynchronizationListener.afterCompletion(JTASynchronizationListener.java:87)
at com.sun.ejb.containers.ContainerSynchronization.afterCompletion(ContainerSynchronization.java:174)
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:467)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:357)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3653)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1247)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:197)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:110)
at $Proxy84.addDepartment(Unknown Source)
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 com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
End of Stack Trace
|#]
RAR5035:Unexpected exception while destroying resource. To get exception stack, please change log level to FINE.
EJB5018: An exception was thrown during an ejb invocation on [DepartmentSessionBean]
javax.ejb.EJBException: Unable to complete container-managed transaction.; nested exception is: javax.transaction.SystemException
javax.transaction.SystemException
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:452)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:357)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3653)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1247)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:197)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:110)
at $Proxy84.addDepartment(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)Means theres an error in XML/ABAP conversion probably due a syntax error...
Regards
Juan -
AutomationException while calling a method
Hi all,
I've got a problem accessing a COM/DCOM component in a Win2k box (Advanced Server)
with jcom. I configured the server and client described in the "JSP to COM" example.
The only difference: I don't want to access the excel sheet and I don't use a jsp
to execute.
I used the java2com.exe to create the proxies from my dll ScriptableUniversalTransAgt.dll.
But when I try to call a method on the dll via Java, I get the exception:
AutomationException: 0x80070005 - General access denied error in 'Invoke'
at com.bea.jcom.Rpc.a(Rpc.java)
at com.bea.jcom.be.a(be.java)
at com.bea.jcom.StdObjRef.a(StdObjRef.java)
at com.bea.jcom.Dispatch.vtblInvoke(Dispatch.java)
at de.conet.galileo.suta.IScriptableUniversalTransAgentProxy.setHcmName(IScriptableUniversalTransAgentProxy.java:271)
at de.conet.galileo.suta.ScriptableUniversalTransAgent.setHcmName(ScriptableUniversalTransAgent.java:336)
at de.conet.galileo.SUTATest.start(SUTATest.java:33)
at de.conet.galileo.SUTATest.main(SUTATest.java:27)
I checked everything on the server, the user has all rights he needs but it doesn't
work. In the eventlog of the server I can see that the login was successful.
The attachment contains some log files and my program with the dll.
Maybe someone can help me?
Thanks
Michael
[src.zip]"Jeff Muller" <[email protected]> wrote in message
news:[email protected]...
Yeah, now I'm getting this error on code that worked two days ago.
javax.servlet.ServletException: Unable to initialize servlet:
AutomationExceptio
n: 0x80070005 - General access denied error, status: Getting instance, and
calli
ng initialize.
at com.teloquent.MyApp.MyServlet.initCOMObj(MyServlet.
java:308)
at com.teloquent.MyApp.MyServlet.init(MyServlet.java:8
1)
at
weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
pl.java:700)
at
weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
Impl.java:643)
at
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
mpl.java:588)
at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
java:368)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:242)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2495)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2204)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
... but then again, I don't expect any response here.
"Michael" <[email protected]> wrote in message
news:[email protected]...
Hi all,
I've got a problem accessing a COM/DCOM component in a Win2k box
(Advanced
Server)
with jcom. I configured the server and client described in the "JSP toCOM" example.
The only difference: I don't want to access the excel sheet and I don'tuse a jsp
to execute.
I used the java2com.exe to create the proxies from my dllScriptableUniversalTransAgt.dll.
But when I try to call a method on the dll via Java, I get the
exception:
>>
AutomationException: 0x80070005 - General access denied error in'Invoke'
at com.bea.jcom.Rpc.a(Rpc.java)
at com.bea.jcom.be.a(be.java)
at com.bea.jcom.StdObjRef.a(StdObjRef.java)
at com.bea.jcom.Dispatch.vtblInvoke(Dispatch.java)
atde.conet.galileo.suta.IScriptableUniversalTransAgentProxy.setHcmName(IScript
ableUniversalTransAgentProxy.java:271)
at
de.conet.galileo.suta.ScriptableUniversalTransAgent.setHcmName(ScriptableUni
versalTransAgent.java:336)
at de.conet.galileo.SUTATest.start(SUTATest.java:33)
at de.conet.galileo.SUTATest.main(SUTATest.java:27)
I checked everything on the server, the user has all rights he needs butit doesn't
work. In the eventlog of the server I can see that the login wassuccessful.
The attachment contains some log files and my program with the dll.
Maybe someone can help me?
Thanks
Michael -
How can I kill all Threads of the same class from within the run() method?
Ok
I have a class called Consumer that extends Thread
I have several Consumer threans running... but, when a certain condition is true (within the run() method) in ANY of the threads, I want to kill ALL the threads of that object.
is this possible?I know this is gonna be too demanding, but can someone please tell me why my Consumer's run() method never reaches the System.out.println( "ALL CONSUMING DONE") line
Create a multi-threaded prime number calculator that is based on the producer-consumer model
using semaphores. Your program should be able to check for prime numbers in a range specified
by the user and with a variable number of threads. Example:
$ java PrimeFind 3 5000 10000
should use 1 producer and 2 consumers (3 threads in total, obviously the minimum is 2) to find all
the prime numbers in the range [5000,10000].
The producer should: use a buffer to store candidate numbers that have to be checked for
primality.
Consumers should: read from the buffer, check if a number is prime and update the status of the
program accordingly (e.g. show the number on the screen, or save it to a file)
import java.util.concurrent.Semaphore;
import java.io.*;
public class Assign1 {
static int fromThisNumber;
static int toThisNumber;
static int numberOfThreads;
static int buffer[];
static Semaphore ready; /*This semaphore is used by the Producer to signal
an "OK" to the consumers*/
static Semaphore critical; /*This is a Mutex semaphore. It allows only 1 consumer
to enter his critical section.
static Semaphore counter; /*This semaphore acts as a counter.
Instead of having a global variable
incremented each time, we just release()
this semephore when we find a prime number
Because remember that release() increments permits
static Producer prod;
static Consumer cons[];
static int in=0;
static int out=0;
static PrintWriter outFile;
public static void main (String args[]){
try{
outFile=new PrintWriter(new FileWriter("primes.txt"));
}catch(Exception e){}
numberOfThreads=Integer.parseInt(args[0]);
fromThisNumber=Integer.parseInt(args[1]);
toThisNumber=Integer.parseInt(args[2]);
buffer=new int[Integer.parseInt(args[2])-Integer.parseInt(args[1])+1];
ready=new Semaphore(0,false); /*We initialise it to 0 because we wait
for the Producer to produce atleast a
item. Suppose ready was 1 and if
Consumer ran first he would be in an
empty buffer */
critical=new Semaphore (1,false);/*We initialise it to 1 because when
the first Consumer thread tries
to enter its critical section, it
should be allowed to;
Subsequent threads will have to
wait since only 1 thread can
access its critical section at a time*/
counter=new Semaphore(0,false); // duh!
cons=new Consumer[numberOfThreads-1]; /*numberOfThreads-1 because 1 thread
is taken by the Producer*/
//Creating Producer object
prod=new Producer();
//Creating the Consumer object and start the thread.
for(int i=0;i<cons.length;i++)
cons=new Consumer();
cons[i].start();
prod.start();
//Printing to screen and file
/* for(int i=0;i<buffer.length;i++)
if(buffer[i]!=0)
System.out.println(buffer[i]);
outFile.println(buffer[i]);
System.out.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits()+"\n primes.txt written");
outFile.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits());
outFile.close();*/
static class Producer extends Thread {
public void run(){try{
while(in<buffer.length) /*'in' should always be more than 'out'.Oherwise the consumer will try to access an empty index*/
{ System.out.println("producing");
buffer[in]=fromThisNumber;
in++;
fromThisNumber++;
ready.release();
catch (Exception e){e.printStackTrace();}
System.out.println("ALL PRODUCING DONE");
static class Consumer extends Thread {
int tempout=0;
public void run(){try{
System.out.println("before while"+this.getId());
while(tempout<=in)
System.out.println("before ready"+this.getId()+" "+ready.availablePermits()+" "+in);
ready.acquire();
System.out.println("before critical.acquire"+this.getId());
critical.acquire();
tempout=out;
out++;
critical.release();
if(!isPrime(buffer[tempout]))
{System.out.println(buffer[tempout]+" by "+this.getId());buffer[tempout]=0;}
else {counter.release();System.out.println("prime added: "+buffer[tempout]+" by "+this.getId());}
critical.acquire();
tempout=out;
System.out.println("tempout:"+tempout+" of "+this.getId());
critical.release();
System.out.println("ALL CONSUMING DONE"+this.getId());
catch(Exception e){e.printStackTrace();}
//Prime number-checking method
public boolean isPrime(int n){
for(int i=2;i<=(n/2);i++)
if(n%i==0)
return false;
return true;
======================
import java.util.concurrent.Semaphore;
import java.io.*;
/* 3 questions to ask Barlas
* Why error if I start the Consumer threads before Producer
* Why does the counter semaphore always give a +1 result at the end
* Is there a way I can verify that all the work is not being done by only 1 consumer thread? In other words, the workload is being shared properly
* if I put ready.acquire() outside or inside the while loop, its not making any difference, why?
* Strangely, its not making any difference if I playing with the release() and aquire() of the semaphores, WHY?!?!
public class Assign1 {
static int fromThisNumber;
static int toThisNumber;
static int numberOfThreads;
static int buffer[];
static Semaphore ready; /*This semaphore is used by the Producer to signal
an "OK" to the consumers*/
static Semaphore critical; /*This is a Mutex semaphore. It allows only 1 consumer
to enter his critical section.
static Semaphore counter; /*This semaphore acts as a counter.
Instead of having a global variable
incremented each time, we just release()
this semephore when we find a prime number
Because remember that release() increments permits
static Producer prod;
static Consumer cons[];
static int in=0;
static int out=0;
static PrintWriter outFile;
public static void main (String args[]){
try{
outFile=new PrintWriter(new FileWriter("primes.txt"));
}catch(Exception e){}
numberOfThreads=Integer.parseInt(args[0]);
fromThisNumber=Integer.parseInt(args[1]);
toThisNumber=Integer.parseInt(args[2]);
buffer=new int[Integer.parseInt(args[2])-Integer.parseInt(args[1])+1];
ready=new Semaphore(0,false); /*We initialise it to 0 because we wait
for the Producer to produce atleast a
item. Suppose ready was 1 and if
Consumer ran first he would be in an
empty buffer */
critical=new Semaphore (1,false);/*We initialise it to 1 because when
the first Consumer thread tries
to enter its critical section, it
should be allowed to;
Subsequent threads will have to
wait since only 1 thread can
access its critical section at a time*/
counter=new Semaphore(0,false); // duh!
cons=new Consumer[numberOfThreads-1]; /*numberOfThreads-1 because 1 thread
is taken by the Producer*/
//Creating Producer object
prod=new Producer();
//Creating the Consumer object and start the thread.
for(int i=0;i<cons.length;i++)
cons[i]=new Consumer();
cons[i].start();
prod.start();
//Printing to screen and file
/* for(int i=0;i<buffer.length;i++)
if(buffer[i]!=0)
System.out.println(buffer[i]);
outFile.println(buffer[i]);
System.out.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits()+"\n primes.txt written");
outFile.println("Total primes found between "+args[1]+" and "+toThisNumber+": "+counter.availablePermits());
outFile.close();*/
static class Producer extends Thread {
public void run(){try{
while(in<buffer.length) /*'in' should always be more than 'out'.Oherwise the consumer will try to access an empty index*/
{ System.out.println("producing");
buffer[in]=fromThisNumber;
in++;
fromThisNumber++;
ready.release();
catch (Exception e){e.printStackTrace();}
System.out.println("ALL PRODUCING DONE");
static class Consumer extends Thread {
int tempout=0;
public void run(){try{
System.out.println("before while"+this.getId());
while(tempout<=in)
System.out.println("before ready"+this.getId()+" "+ready.availablePermits()+" "+in);
ready.acquire();
System.out.println("before critical.acquire"+this.getId());
critical.acquire();
tempout=out;
out++;
critical.release();
if(!isPrime(buffer[tempout]))
{System.out.println(buffer[tempout]+" by "+this.getId());buffer[tempout]=0;}
else {counter.release();System.out.println("prime added: "+buffer[tempout]+" by "+this.getId());}
critical.acquire();
tempout=out;
System.out.println("tempout:"+tempout+" of "+this.getId());
critical.release();
System.out.println("ALL CONSUMING DONE"+this.getId());
catch(Exception e){e.printStackTrace();}
//Prime number-checking method
public boolean isPrime(int n){
for(int i=2;i<=(n/2);i++)
if(n%i==0)
return false;
return true;
===========================
BTW, when I tried to change extends Thread to implements Runnable I got some kinda of error.
Actually, my program is pretty complete... its just that something if messed up in my Consumer's run() method's while loop... I think
I know guys its crazy to ask ya'll to look at so much code, but.... I'd really appreciate it. This assignment is killing me, been at it since 10 hours now.... -
How to get value from Thread Run Method
I want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that it seems that scope of the variable gets lost resulting to null value in the called method/class..
How can I get the variable with the value?
This is sample code:
public class SampleSynchronisation
public static void main(String df[])
sampleThread sathr= new sampleThread();
sathr.start();
System.out.println("This is the value from the run method "+sathr.x);
/* I should get Inside the run method::: But I get only Inside */
class sampleThread extends Thread
public String x="Inside";
public void run()
x+="the run method";I think this is what you're looking for. I hold up main(), waiting for the results to be concatenated to the String.
public class sampsynch
class SampleThread extends Thread
String x = "Inside";
public void run() {
x+="the run method";
synchronized(this) {
notify();
public static void main(String[] args) throws InterruptedException {
SampleThread t = new sampsynch().new SampleThread();
t.start();
synchronized(t) {
t.wait();
System.out.println(t.x);
} -
Getting Bad Type Error when calling a method in the proxy class
Hi,
I have generated the proxy classes from wsdl.
When I am calling the methods in the proxy class from one of external class, I am getting following error.
Can anyone please help me in resolving this issue.
javax.xml.ws.soap.SOAPFaultException: org.xml.sax.SAXException: Bad types (interface javax.xml.soap.SOAPElement -> class com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference) Message being parsed:
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:197)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:125)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:136)
at $Proxy176.find(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:84)
at $Proxy173.find(Unknown Source)
at com.xxx.fs.FNServices.findAccountWs(FNServices.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Thanks
AnoopHi Vlad,
The service has not been changed since i have generated the proxy.
I tried calling the service from soapUI and I am getting the following error now.
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uri="uri:webservice.subscribenet.intraware.com" xmlns:uri1="uri:subscribenet.intraware.com">
<soapenv:Header>
<uri:SessionHeader>
<uri:SessionID>hjkashd9sd90809dskjkds090dsj</uri:SessionID>
</uri:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<uri:Find>
<uri:SubscribeNetObjectReference>
<uri1:ID></uri1:ID>
<uri1:IntrawareID></uri1:IntrawareID>
<uri1:SharePartnerID></uri1:SharePartnerID>
</uri:SubscribeNetObjectReference>
</uri:Find>
</soapenv:Body>
</soapenv:Envelope>
Response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.generalException</faultcode>
<faultstring>org.xml.sax.SAXException: WSWS3279E: Error: Unable to create JavaBean of type com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference. Missing default constructor? Error was: java.lang.InstantiationException: com.intraware.snetmgr.webservice.data.SubscribeNetObjectReference. Message being parsed:</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Thanks
Anoop -
Issue with calling a method activity before page render
Hi All,
I am using Jdeveloper 11.1.1.7.
I am trying to achieve the approach defined in "1.b. Calling a Method in Backing Bean:" elaborated in the blog - https://blogs.oracle.com/adf/entry/an_epic_question_how_to
As illustrated, I defined a default method activity (binding to a method in managed bean) and a view activity activity in a bounded task flow.
When I launch the application (running the view activity), following error is encountered -
oracle.adf.controller.metadata.ParsingException: ADFC-02020: Cannot find default activity 'check' in task flow definition '/WEB-INF/task-flow-definition.xml#task-flow-definition'.
at oracle.adfinternal.controller.metadata.model.xml.XmlUtil.createAndLogParsingException(XmlUtil.java:474)
at oracle.adfinternal.controller.metadata.model.xml.MetadataResourceXmlImpl.parseTaskFlowDefinition(MetadataResourceXmlImpl.java:507)
at oracle.adfinternal.controller.metadata.model.xml.MetadataResourceXmlImpl.parse(MetadataResourceXmlImpl.java:361)
at oracle.adfinternal.controller.metadata.provider.mds.MdsMetadataResourceProvider.parseResource(MdsMetadataResourceProvider.java:748)
at oracle.adfinternal.controller.metadata.provider.mds.MdsMetadataResourceProvider.getMDSCachedResourceOrParse(MdsMetadataResourceProvider.java:732)
Please advise.
Best Regards,
Ankit GuptaHi Cvele, Timo,
Many thanks for the suggestions.
To avoid confusions, I have created a new application altogether. It seems that the method call is not being called when I run the page.
For your reference I have attached the task flow definition and method code below -
Task Flow Definition
<?xml version="1.0" encoding="windows-1252" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
<task-flow-definition id="task-flow-definition">
<default-activity id="__1">methodCall1</default-activity>
<managed-bean id="__11">
<managed-bean-name id="__13">TestBean</managed-bean-name>
<managed-bean-class id="__10">TestBean</managed-bean-class>
<managed-bean-scope id="__12">request</managed-bean-scope>
</managed-bean>
<view id="view1">
<page>/view1.jspx</page>
</view>
<view id="exception">
<page>/exception.jspx</page>
</view>
<method-call id="methodCall1">
<method>#{requestScope.TestBean.checkURL}</method>
<return-value id="__15">#{TestBean.checkURL}</return-value>
<outcome id="__14">
<to-string/>
</outcome>
</method-call>
<control-flow-rule id="__2">
<from-activity-id id="__3">methodCall1</from-activity-id>
<control-flow-case id="__5">
<from-outcome id="__6">go</from-outcome>
<to-activity-id id="__4">view1</to-activity-id>
</control-flow-case>
<control-flow-case id="__8">
<from-outcome id="__9">error</from-outcome>
<to-activity-id id="__7">exception</to-activity-id>
</control-flow-case>
</control-flow-rule>
</task-flow-definition>
</adfc-config>
Method Code
public String checkURL() {
// Add event code here...
System.out.println("method activity called");
return "error";
Best Regards,
Ankit Gupta -
Problem calling a method in a servlet witch returns remote ejb
Hi, I have a problem combining servlets ands ejbs, I expose my problem :
What I have :
1 . I have a User table into a SGBD with two attributes login and pass.
2 . I have a UserBean linked to User table with a remote interface
3 . I have a stateless UserSessionBean with a remote interface
4 . I have a UserServlet linked to a jsp page which allows me to add users
5 . I use Jboss
What is working ?
1 - I have a method newUser implemented in my UserSessionBean :
public class UserSessionBean implements SessionBean {
private SessionContext sessionContext;
private UserRemoteHome userRemoteHome;
public void ejbCreate() throws CreateException {
// Initialize UserRemoteHome
// Method to add a new user
public UserRemote newUser(String login, String password) {
UserRemote newUser = null;
try {
newUser = userRemoteHome.create(login, password);
} catch (RemoteException ex) {
System.err.println("Error: " + ex);
} catch (CreateException ex) {
System.err.println("Error: " + ex);
return newUser;
}2 - When I test this method with a simple client it works perfectly :
public class TestEJB {
public static void main(String[] args) {
Context initialCtx;
try {
// Create JNDI context
// Context initialization
// Narrow UserSessionHome
// Create UserSession
UserSession session = sessionHome.create();
// Test create
UserRemote newUser = session.newUser("pierre", "hemici");
if (newUser != null) {
System.out.println(newUser.printMe());
} catch (Exception e) {
System.err.println("Error: " + e);
e.printStackTrace();
Result : I got the newUser printed on STDOUT and I check in the User table (in the SGBD) if the new user has been created.
What I want ?
I want to call the newUser method from the UserServlet and use the RemoteUser returned by the method.
What I do ?
The jsp :
1 - I have a jsp page where a get information about the new user to create
2 - I put the login parameter and the password parameter into the request
3 - I call the UserServlet when the button "add" is pressed on the jsp page.
The Servlet :
1 - I have a method doInsert which call the newUser method :
public class UserServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
// EJB Context
InitialContext ejbCtx;
// Session bean
UserSession userSession;
public void init() throws ServletException {
try {
// Open JNDI context (the same as TestClient context)
// Get UserSession Home
// Create UserSession
userSession = userSessionHome.create();
} catch (NamingException ex) {
System.out.println("Error: " + ex);
} catch (RemoteException ex) {
System.out.println("Error: " + ex);
} catch (CreateException ex) {
System.out.println("Error: " + ex);
protected void service(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException {
* Does insertion of the new user in the database.
public void doInsert(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException {
try {
// Get parameters to create the newUser
String login = req.getParameter("login");
String password = req.getParameter("password");
// Create the newUser
System.out.println("Calling newUser before");
UserRemote user = userSession.newUser(login, password);
System.out.println("Calling newUser after");
} catch (Exception e) {
// Clean up resources
public void destroy() {
Result :
When I run my jsp page and click on the "add" button, I got the message "Calling newUser before" printed in STDOUT and the error message :
ERROR [[userservlet]] Servlet.service() for servlet userservlet threw exception
javax.servlet.ServletException: loader constraints violated when linking javax/ejb/Handle class
at noumea.user.UserServlet.service(UserServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:534)
Constat :
I checked into my SGBD and the new user has been created.
The error appears only when the method return Remote ejbs, if I return simples objects (Strings, int..) it works.
What can I do to resolve this problem ?
Thank you."Why do you want to servlet to gain access to another EJB through the stateless session bean. Why cant the servlet call it directly ?"
Because I want to access to the informations included in the entity bean UserBean (which is remote).
You said that it is a bad design, but how can I access to my UserBean ejbs from the session bean if I don't do that ?
For example I want a List of all users to be seen in a jsp page :
1 - I call the method getUserList which returnsan ArrayList of UserRemote.
2 - I iterate over the ArrayList to get the users parameters to be seen.
As the other example (newUser), when I do
ArrayList users = (ArrayList) userSession.getUserList(); with the simple client it works, but in the servlet I got the same error.
But, if I call directly the findAll method (as you'are saying) in the servlet
ArrayList users = (ArrayList) userRemoteHome.findAll(); it works...
I think that if my servlet calls directly entity ejbs, I don't need UserSession bean anymore. Is that right ?
I precise that my design is this :
jsp -> servlet -> session bean -> entity bean -> sgbd
Is that a bad design ? Do I need the session bean anymore ?
Thank you. -
Browser Dependency when calling a method in backing bean using a javasript.
Hi all,
I have a problem which may look simple but bugging me for quite some time.
The problem is : When I call a method in the backing bean using a Javascript, (the method can alternatively be invoked by clicking on a command link) I am facing an exception (stack printed below).
The strange part is that...I am getting this exception only when I use Internet Explorer. It works absolutely fine when I use Mozilla or Netscape browsers. Also, even in ie, it is working fine when I click on the link directly. The probem comes only when I invoke the action using a javascript.
WARN [lifecycle] executePhase(RENDER_RESPONSE 6,com.sun.faces.cont
ext.FacesContextImpl@16ce9df) threw exception
javax.faces.FacesException
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java
:135)
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.internalDoFilter(Application
FilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
va:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
ationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:
84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnecti
onValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: ClientAbortException: java.net.SocketException: Connection reset by
peer: socket write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:
358)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:309)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288)
at org.apache.catalina.connector.Response.flushBuffer(Response.java:542)
at org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java
:279)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:20
2)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java
:101)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:
222)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java
:106)
... 24 more
Caused by: java.net.SocketException: Connection reset by peer: socket write erro
r
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWri
te(InternalOutputBuffer.java:764)
at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFi
lter.java:124)
at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.j
ava:570)
at org.apache.coyote.Response.doWrite(Response.java:560)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:
353)
... 33 more
13:54:42,805 ERROR [STDERR] ClientAbortException: java.net.SocketException: Con
nection reset by peer: socket write error
13:54:42,805 ERROR [STDERR] at org.apache.catalina.connector.OutputBuffer.realW
riteBytes(OutputBuffer.java:358)
13:54:42,805 ERROR [STDERR] at org.apache.tomcat.util.buf.ByteChunk.flushBuffer
(ByteChunk.java:434)
13:54:42,805 ERROR [STDERR] at org.apache.catalina.connector.OutputBuffer.doFlu
sh(OutputBuffer.java:309)
13:54:42,805 ERROR [STDERR] at org.apache.catalina.connector.OutputBuffer.flush
(OutputBuffer.java:288)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.connector.Response.flushBuff
er(Response.java:542)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.connector.ResponseFacade.flu
shBuffer(ResponseFacade.java:279)
13:54:42,820 ERROR [STDERR] at com.sun.faces.application.ViewHandlerImpl.render
View(ViewHandlerImpl.java:202)
13:54:42,820 ERROR [STDERR] at org.ajax4jsf.framework.ViewHandlerWrapper.render
View(ViewHandlerWrapper.java:101)
13:54:42,820 ERROR [STDERR] at org.ajax4jsf.framework.ajax.AjaxViewHandler.rend
erView(AjaxViewHandler.java:222)
13:54:42,820 ERROR [STDERR] at com.sun.faces.lifecycle.RenderResponsePhase.exec
ute(RenderResponsePhase.java:106)
13:54:42,820 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.phase(Life
cycleImpl.java:251)
13:54:42,820 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.render(Lif
ecycleImpl.java:144)
13:54:42,820 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesSer
vlet.java:245)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.
internalDoFilter(ApplicationFilterChain.java:290)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.
doFilter(ApplicationFilterChain.java:206)
13:54:42,820 ERROR [STDERR] at com.hds.vc.common.infrastructure.AIMFilter.doFil
ter(AIMFilter.java:27)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.
internalDoFilter(ApplicationFilterChain.java:235)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.
doFilter(ApplicationFilterChain.java:206)
13:54:42,820 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.d
oFilter(ReplyHeaderFilter.java:96)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.
internalDoFilter(ApplicationFilterChain.java:235)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.
doFilter(ApplicationFilterChain.java:206)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.in
voke(StandardWrapperValve.java:230)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.in
voke(StandardContextValve.java:175)
13:54:42,820 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociatio
nValve.invoke(SecurityAssociationValve.java:179)
13:54:42,820 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.i
nvoke(JaccContextValve.java:84)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invok
e(StandardHostValve.java:128)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invo
ke(ErrorReportValve.java:104)
13:54:42,820 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectio
nValve.invoke(CachedConnectionValve.java:156)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.inv
oke(StandardEngineValve.java:109)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.serv
ice(CoyoteAdapter.java:241)
13:54:42,820 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:844)
13:54:42,820 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11Co
nnectionHandler.process(Http11Protocol.java:580)
13:54:42,820 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.ru
n(JIoEndpoint.java:447)
13:54:42,820 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
13:54:42,820 ERROR [STDERR] Caused by: java.net.SocketException: Connection rese
t by peer: socket write error
13:54:42,820 ERROR [STDERR] at java.net.SocketOutputStream.socketWrite0(Native
Method)
13:54:42,820 ERROR [STDERR] at java.net.SocketOutputStream.socketWrite(Unknown
Source)
13:54:42,820 ERROR [STDERR] at java.net.SocketOutputStream.write(Unknown Source
13:54:42,820 ERROR [STDERR] at org.apache.coyote.http11.InternalOutputBuffer$Ou
tputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:764)
13:54:42,820 ERROR [STDERR] at org.apache.coyote.http11.filters.ChunkedOutputFi
lter.doWrite(ChunkedOutputFilter.java:124)
13:54:42,820 ERROR [STDERR] at org.apache.coyote.http11.InternalOutputBuffer.do
Write(InternalOutputBuffer.java:570)
13:54:42,820 ERROR [STDERR] at org.apache.coyote.Response.doWrite(Response.java
:560)
13:54:42,820 ERROR [STDERR] at org.apache.catalina.connector.OutputBuffer.realW
riteBytes(OutputBuffer.java:353)
13:54:42,820 ERROR [STDERR] ... 33 more
Please throw some light on this issue.This is the Java script I am using
function submitForm(e){
var characterCode
if(e && e.which){
e = e
characterCode = e.which
}else{
e = event characterCode = e.keyCode
if (characterCode== 13){
document.getElementById('mainform:submitForm:search').onclick();
Regards,
Jagadeesh
Edited by: Jagadeesh.Pala on Oct 1, 2007 3:59 AM -
Calling a method, some help please
Hi, I'm trying to run or call a method in my main Class which has received a StringBuffer value from another method in a separate class. I'm unsure about how to call this particular method. The way the method works is receiving some XML packets from a ConnectionBean. I'm just testing it so far to output the stuff in my Terminal window.
//Method to call in <body> of XML contained in a StringBuffer
public StringBuffer updateEditor( StringBuffer body ) {
StringBuffer sbuff;
sbuff = communicate.incomingBody( body );
System.out.println( "main received" + sbuff );
return sbuff;
How would I call this method which is already in my main Class (that has all the GUI elements). I just want this method to run when a value is received/passed into it. So really it needs to be running all the time - in effect listening to received StringBuffers.
Thanks :)I wasn't clear, sorry I'll show you what I have:
A Class named Comms that has two methods sorting out the XML stuff:
Class Comms {
//Handles history of incoming <body> XML from receievedPacket
protected void addToHistory( Message msg ) {
//Build String to append
StringBuffer sb = new StringBuffer();
sb.append( msg.getBody() );
incomingBody( sb );
System.out.println( sb );
//Stores the StringBuffer value from addToHistory
public StringBuffer incomingBody( StringBuffer sb ) {
StringBuffer body;
body = sb;
if( body != null ) {
System.out.println( body );
return body;
....//End Class
And the main Class ( Exchange) that does the GUI stuff and I've a method that calls in the incomingBody(); method. I've already created a new instance of that class:
Class Exchange {
Comms communicate = new Comms();
//And then the method that I want to be called
//Method to call in <body> of XML contained in a StringBuffer
public StringBuffer updateEditor( StringBuffer body ) {
StringBuffer sbuff;
sbuff = communicate.incomingBody( body );
System.out.println( "main received" + sbuff );
return sbuff;
I'm not sure how to call/run this method in the main Class (Exchange) all the time so that it checks the other Class' method incomingBody?
Thanks -
Calling a method after 10 seconds
Hello,
I need to call a method after 10 seconds. That is to make sure that if one particular field is updated, say 3 times in a window of 10 seconds, I should just be able to take the last value and process it, in my ajax app. I am so far using the Timer class, but the problem is, it ticks off a thread for every single request to be processed after 10 seconds and processes all the 3 requests, where as I should just be running that method once for the last request. Could you please help me with this ?
Cant do this at the client level, for the page may be closed within those 10 seconds of the event and the setTimeout wont work then.
This is what I made so far.:
final Map<String, Object> mp = new HashMap<String, Object>();
if(form.getEmpId() != null )
mp.put(form.getEmpId().toString(), form);
new java.util.Timer().schedule(new java.util.TimerTask()
public void run()
EmpForm form1 = (EmpForm)mp.get(empId.toString());
String empId = form1.getempId().toString();
String value1Changed = form1.getValue1Changed().toString();
String value2Changed = form1.getValue2Changed().toString();
myService.changeData(empId, value1Changed, value2Changed),
}, 10000);
}Thanks for replying
tjacobs01 wrote:
My recommendation is that you share an AtomicReference between your timer and the listener that is receiving the updates. This way, the listener can just update the value, and the timer uses the latest one when it wakes upOk, out of my limited understanding, I looked up AtmoicReference and found it a class. I think I cant use that since I am maintaining a list of empIds against the object that holds their data in a hashmap, expecting the map to override the empId on the second request. So, I made a final map and thought Id just push the timer scheduler method in another method, but the problem is, for me to ask that thread (which I expect to run after 10 seconds of my calling) to run, I need to call it somewhere, and as soon as I get a request I am calling the method which runs/ticks off the thread.
I was thinking that since I am passing and using a final map (that I declared as a class level variable), I will be able to put update the map object and whenever the thread runs, will fetch the latest value (of the empId) in the map. But I guess I am doing it wrong. :( -
Calling a method ---please help
Hi everyone, I'm new to the forums, and completely new to java,. I've been searching for hours (online and in books) on how to call a method while passing parameters. I still haven't figured it out. I'm sure it's really easy, but I need some help.
This program is for evaluating the quadratic formula. I can't seem to return x1 and x2 from lines 73 and 78 (labeled in code) from method quad to lines 39, 40, and 46. It will compile and run, but it will not display x1 and/or x2.
Please help, and thanks in advance.
Am I even close?
import java.util.*;
import java.lang.*;
import javax.swing.JOptionPane;
public class test
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
//Declare variables
double a = 0;
double b = 0;
double c = 0;
double d = 0;
//Asking the user for input
inputA = JOptionPane.showInputDialog(null, "enter number for x^2");
inputB = JOptionPane.showInputDialog(null, "enter number for x";
inputC = JOptionPane.showInputDialog(null, "enter number for constant");
//Parsing string to double
a = Double.parseDouble(inputA);
b = Double.parseDouble(inputB);
c = Double.parseDouble(inputC);
//calculating discriminant
d = (Math.pow(b,2) - (4 * a * c));
//Checking to see if the discriminant is less than zero - has two imaginary roots
if (d < 0)
JOptionPane.showMessageDialog(null, "There are two imaginary roots.");
}//end checking to see if the discriminant is less than zero - has two imaginary roots
//calling method quad
if (d > 0)
quad(a, b, c, 1); //line 39
quad(a, b, c, 2); //line 40
JOptionPane.showMessageDialog(null, "There are two real roots. They are root 1 = "
+ x1 + " , and root 2 = " + x2 + ".");
else if (d == 0)
quad(a, b, c, 1); //line 46
JOptionPane.showMessageDialog(null, "There is a single (repeated) root. It is " + x1);
//starting method quad
public static double quad (double a, double b, double c, int n)
double d = 0; //value for d - discriminant
double x1 = 0; //value for x - solving for x
double x2 = 0; //value for -x - solving for negative x
//Checking if discriminant equals zero or is larger than zero
if (d == 0)
n = 1;
else
n = 2;
//Checking if n equals zero
if (n == 1)
x1 = ((-b) + (Math.sqrt((Math.pow(b,2))-(4 * a* c))) / (2 * a));
return x1; //line 73
else
x2 = ((-b) - (Math.sqrt((Math.pow(b,2))-(4 * a* c))) / (2 * a));
return x2; //line 78
}//end method quadMan, you guys/gals are great! You notice everything...I sure appreciate all the help so far. I've updated a few things, but I still can't get x1 in the method to pass the right input to line 39. For instance, if I set a=2, b=4, and c=-30, then x1 should = 3 and x2 should =-5, but both keep showing -5. They are always equal for some reason, even when they are not supposed to be.
I see what you were saying with d always equalling zero. I was looking in the main where it doesn't always = zero, but in the method it was always set to zero. Thanks...good eye!
num1 = quad(a, b, c, 1); //line 39
num2 = quad(a, b, c, 2); //line 40
JOptionPane.showMessageDialog(null, "There are two real roots. They are root 1 = "+ num1 + " , and root 2 = " + num2 + ".");I also added this to the method so d won't always = zero
d = (Math.pow(b,2) - (4 * a * c));I also have all of the variables declared at the top, but I forgot to copy and paste all of them and I updated the System.exit(0) to close the JOptionPane along with extra } 's to close the program correctly.
Again, thanks a bunch.
Maybe you are looking for
-
Adobe Bridge 1.0.3 displays white boxs after 10.4.6 update
After the update Bridge displays white boxes in the window. I have done all the standard stuff like delete prefs, rebuild caches, I even reinstalled it. I also ran the Adobe security update that was mentioned on another thread no luck. I have posted
-
Hi, I am trying to write a SQL query which returns the % difference between 2 columns in a table, in sorted descending order, based on the absolute value. The statement goes like this: SELECT ((col1 - col2)/col2)*100 FROM table1 WHERE col2 > 0 UNION
-
�� I have a java applet program (yanhua.java) need help!!!
�� I have a java applet program (yanhua.java) that use mouse click a area show a fireworks, the applet program that a java fan mail me. Now i find some bug in the program, can you help me? thank in advance! The backdrop of the question: The yanhua.ja
-
Lightroom 5 crashing frequently
I have installed lightroom 5 on my wife's computer (27" iMac w/ quad-core 2.8GHz i7, 16gb RAM, ML 10.8.4) and it crashes frequently. My wife will try to import pictures from her card, and get an error something like this: Internal Error Occurred, ins
-
Log and capture files start out in sync and drift out of sync over the length of the clip. Could dissimilar Sequence, capture and device control presets cause this problem? Seq Preset is set to DV50 48 Khz which has 16 bit 48 Khz audio Capture Preset