mridul das

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

Recent posts by mridul das

There's a serversocket handling incoming request on a per thread basis. Each request is assigned a new Thread by submitting to the ExecutorService.
For argument sake say I create a ExecutorSevice with pool size 1. Executors.newFixedThreadPool(1). I submit all the incoming request to this.
Now the first request comes in and gets submitted to the Thread pool. During execution of this thread this calls the ServerSocket again. This is the portion
of the server code

When the server receives the second request, it tries to create another runnable object and submit it to the Thread Pool. But since the thread pool size is 1 this new thread never gets a chance to run.
And the first thread which initiated the process is still waiting for this thread to complete. Essentially there is a deadlock.
This is similar to a client calling a remote EJB which in turn will call another remote EJB in the same server.
Is there some way to get rid of this situation
I commented out a peice of code which was
finally{
socket.close();
}
Since then it seems to be working.
But havent found the answer to why was it working in the local machine. The stub was not in the classpath however
17 years ago
I am pretty new to RMI. I have a simple HTTP sever(found in the net) whic serves the classes to the client through a server socket as follows
out.writeBytes("HTTP/1.0 200 OK\r\n");
out.writeBytes("Content-Length: " + bytecodes.length +
"\r\n");
out.writeBytes("Content-Type: application/java\r\n\r\n");
out.write(bytecodes);
out.flush();

While I try this from the same machine
Class cls1 = RMIClassLoader.loadClass(new URL("http://machine-name:2001/"),"className");
the class seems to be loaded.
But the same code on trying from a different machine gives the following exception
java.lang.ClassNotFoundException: jnp.server.Test_Stub
at java.net.URLClassLoader$1.run(URLClassLoader.java:196)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:430)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:631)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:169)
at Main.test(Main.java:55)
at Main.main(Main.java:33)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
at sun.net.www.MeteredStream.read(MeteredStream.java:106)
at java.io.FilterInputStream.read(FilterInputStream.java:111)
at sun.misc.Resource.getBytes(Resource.java:64)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
... 13 more
Could anyone help me understand what the prob is .
17 years ago
We have two applications running on two different Weblogic 8.1 servers. Both are clustered.
There are some points of integration between the two.
We cache the ejbHome references in static variables in the Servicelocator.
Suppose one server goes down and then comes up while the other is running, the cached ejbHome references to that server still exists. Calling ejbHome.create() on that reference is not ausing any problem if <home_is_clusterable> is True. However if it is false it throws an Exception.
Is it a good idea to cache the home references. Why is there no problem if
<home_is_clusterable> is True.
method(String xyz){
PreparedStatement pStmt;
String query= "select * from users where " +
"user_role not in (?)";
pStmt= con.prepareStatement(query);
pStmt.setString(1, xyz);
pStmt.execute();
}

Now the xyz coulb be something like "'guest','admin'"
This doesn't work as xyz is passed as a parameter to the compiled statement.So this doesnot return the correct results.How would I get round this. Is it possible using a PreparedStatement.
Need a quick reply.
We aare using ejbdoclet to generate remote, local, home interfaaces and descriptors for our ejbs. For the entity bean however the primary class is not getting generated and also the <prim-key-class>int</prim-key-class> in the ejb-jar.xml shows int instead of the expected class .
this is the ejbDoclet task.
<target name="ejbDoclet">
<mkdir dir="${ejbDoclet}"/>
<mkdir dir="${services.build}" />
<ejbdoclet destdir="${ejbDoclet}" excludedtags="@version,@author" addedtags="@xdoclet-generated at ${TODAY}" ejbspec="2.0">
<fileset dir="${ejbApp}">
<include name="com/ads/app/property/entity/DataBean.java" />
</fileset>
<entitypk/>
<remoteinterface pattern="{0}"/>
<homeinterface/>
<localinterface pattern="{0}Local" />
<localhomeinterface />
<deploymentdescriptor destdir="${oms.services.build}/META-INF" mergeDir="${descriptorsOMS}" />
<weblogic version="7.0" datasource="XYZ" xmlencoding="UTF-8" destdir="${services.build}/META-INF" />
</ejbdoclet>
</target>

I am not sure what is missing or what else needs to be done.
Thanks.
17 years ago
We have communication between two independent susytems. A user logins from say system A and then through SSO(single sign on) comes to system say B. When he logs out in B he is taken back to A's login page. But when he times out he is taken to B's login page.
The requirement is that when a user comes to B from A through SSO on time out he's suppose to be taken to A's login page where he initially logged in.
How could I implement this to break the container's inplementation.
We are using struts with Weblogic 8.1.
18 years ago
We have communication between two independent susytems. A user logins from say system A and then through SSO comes to system say B. When he logs out in B he is taken back to A's login page. But when he times out he is taken to B's login page.
The requirement is that when a user comes to B from A through SSO on time out he's suppose to be taken to A's login page when he initially logged in.
How could I implement this to break the container's inplementation.
We are using struts with Weblogic.
18 years ago
>The server doesn't store the original request. You would have to write >your servlet to put the request URL in the session and then redirect to >the home page. Upon successful login, you can check in the session to see >the original request.

>So there are three states for the session:
>- no session (new user)
>- session with stored URL
>- logged in session


I cant put the URL in session becoz the server will remove everything from session upon session invalidation. So i wont get back the URL.
I need some way to determine that the user has timed out. And there's a deiiference betwee timed out and logout and opening a new browser to access the application.
Once the user times out the after loggin in the request is the same. But if he logouts or starts a browser than after loggin in he's taken to the home page. So the server has some code which decides that after security check where is the user supposed to be directed.And in all this cases a new session is created.
I want to catch that session timeout event. We are using Weblogic 8.1 SP3.
I am not sure if the SessionListener can tell me why was the session destroyed.Whether the user loggout or a session timed out happened.
18 years ago
When a user times out in an web app. he is directed to the login page. On successfully logging in he's directed to the page he requested beore he timed out.
We require that the user on being timed out should be taken to the home page and not the requested page. But i want to know where the server stores the original request.And how do I modify it so that I can change the URI or whatever required.
Could any one provide a solution.
18 years ago
I am trying to use the Oracle sequence to generate the primary key for my User object. This is my User.hbm.xml
<class name="com.common.web.user.hibernate.User" table="test_user">
<id name="userId" type="integer" column="USER_ID" >
<generator class="sequence">
<param name="sequence">MD_USER_SEQ</param>
</generator>
</id>
<property name="name">
<column name="NAME" not-null="true"/>
</property>
<property name="passwd" column="PASSWORD" not-null="true"/> </class>

But this is the exception I am getting.
net.sf.hibernate.MappingException: could not instantiate id generator
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:82)
at net.sf.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:80)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:631)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:715)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:750)
at com.common.web.user.hibernate.HibernateUtil.<clinit>(Unknown Source)
at com.common.web.user.controller.TestAction.doHibernateStuff(TestAction.java:43)
at com.common.web.user.controller.TestAction.execute(TestAction.java:35)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.hibernate.MappingException: Dialect does not support sequences
at net.sf.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:319)
at net.sf.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:62)
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:78)
... 44 more

Could you tell me whats wrong or how do I use the Oracle database generated sequence for my user object.

Thanks
Where do I remove the token. The process completes when it comes back to the JSP. But if I remove the token in the JSP and then I refresh the page, it generates another request. The token is not found and the DB is hit again.
18 years ago
I am calling a helper class from the servlet which does the database operations. What happens is there is one page which does and insertion in the database. When I refresh that page it causes to insert the values once againg in the database.
A new request is generated and causes DB operations. I want to stop it from hitting the DB but since a new request is generated I cant identify it as the request is becoz the user has refreshed the page or he's clicked the button which causes it to insert the values.
I am using the get method in the form which is supposed to be idempotent
Please help.
18 years ago
we cant have static variables in an inner class but static final variables are allowed.As you can see static final int z = c; compiles.But not
static final int x = a;
static final int y = b;
The problem is with innitiallisation.The way we are initiallising the final static variables x and y.
18 years ago
In the following code
class outer{
static int a;
static final int b;
static final int c=1;
static{
b = 2;
}

class inner{
static final int x = a;
static final int y = b;
static final int z = c;
}
}
I get 2 errors
global.java:10: inner classes cannot have static declarations
static final int x = a;
^
global.java:11: inner classes cannot have static declarations
static final int y = b;
^
Why is it an error to initiallise a static final field in an inner class to a static field or final field in the enclosing class when both are actually accessible from the inner class. Moreover static final int z = c; is ok as I have initiallised the static final field c in its declaration.But static final int y = b; gives an error when I have initiallised the static final field b in the static block of the enclosing class.
Please explain.Could you give me the logical reasoning as to why was this done.I mean the thought behind this design.
18 years ago