riya s

Ranch Hand
+ Follow
since Feb 28, 2003
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 riya s

Even after writing a was.policy to I get the following error.


************************************************************************
SecurityManag W SECJ0314W: Current Java 2 Security policy reported a potential violation of Java 2 Security Permission. Please refer to Problem Determination Guide for further information.

Permission:

myfile.ser : access denied (java.io.FilePermission myfile.ser write)

**************************************************************************


I have the following in my was.policy

grant codeBase "file:${application}" {
permission java.io.FilePermission "<>", "read, write, delete, execute";
};

Is the was.policy file okay ?
15 years ago
The client code is pretty much the same as the chapter 1 code I think except that I changed the name of the method from getAdvice to getTheHint because the errata said it can cause problems.

import headfirst.Advice;
import headfirst.AdviceHome;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;


public class AdviceClient {

public static void main(String[] args) {
new AdviceClient().go();
}

public void go(){

try {
Context ct = new InitialContext();
Object o = ct.lookup("ejb/headfirst/Advice");
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o,AdviceHome.class);
Advice advisor = home.create();
System.out.println(advisor.getTheHint());

} catch (ClassCastException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}

}
}
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at AdviceClient.go(AdviceClient.java:21)
at AdviceClient.main(AdviceClient.java:10)
I was able to compile the client java file. But when I run it I get this error now.

com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)

Any idea what this is ?
Hello I created the Session beans from the Cahpter 1 and the ear file sucessfully and while using the deploytool The Client jar was also created...

Now I have my Client java file which needs to use the Client jar file but its not compiling...

My project structure is as follows

projects\advice which has classes, src (used while creating the Session bean), ear file created, Client jar file and the Client java file I am trying to compile ...

The AppClient.jar file has the headfirst folder in it..

How do i compile the AdviceClient.java file ?

From the advice folder I tried to say javac -classpath entirepath\AdviceAppClient.jar AdviceClient.jar and it gives me errors like

AdviceClient.java:5: package javax.ejb does not exist
import javax.ejb.*;
^
AdviceClient.java:24: cannot access javax.ejb.EJBHome
file javax\ejb\EJBHome.class not found
Advice advisor = home.create();
^
AdviceClient.java:27: cannot access javax.ejb.EJBObject
file javax\ejb\EJBObject.class not found
System.out.println(advisor.getAdvice());

I have setup the J2EE_HOME and the JAVA_HOME and j2ee.jar is also in the classpath...

I am not sure what the {CLASSPATH}: means in the book
Can someone who ran this example before help me get some advice from the bean ?
Hello I need to write to a file from a servlet but the server policy doesnt permit that.. I am not sure which policy file to change? java.policy, server.policy ?
15 years ago
sorry this was for the post "How to enable sessions in WS3.5 "
15 years ago
Make sure cookies are turned on, on the server
15 years ago
Since you said this -- > "We obtain the data source connection through thin client"

I suspect that the thin driver isnt the one you should be using... use the XA driver and see.
15 years ago
I wanted to know which policy file should be changed in WAS 5 so that my servlet can write to a file? java.policy? was.policy, app.policy ? There are also more than one policy file with same name under the WAS installation so which one should be changed?

Should the policy file be kept where it is or if I change say was.policy then should I place it under meta-inf of war?

I saw on a website that I should use the policytool but I am not sure how to use "grant codebase... etc" with the servlet of a particular application which is installed already. Do I need a jar or a class file is okay?

Please do let me know if you have any idea about this..

Thank you.
15 years ago
Thanks sam...Thank you you did lead me in the right direction.

Actually the client had cookies enabled but there was a option in WSAD which was under the WAS test server's web tab which has options for container... The enable URL Writing and Enable cookies were both disabled... I wonder why they do this?

In the Java Blueprints they recommend HTTPSession and so websphere should have atleast the Cookies option open by default ... But I guess we have to check that everytime...

Thank you again
15 years ago
This is in my servlet
--------------------------------------------------------------
if(rs.next()){

HttpSession mySession = request.getSession(true);
mySession.setAttribute("user",user);

RequestDispatcher rd = null;
rd = getServletConfig().getServletContext().getRequestDispatcher("/MM.jsp");

if (rd!=null)
rd.forward(request,response);
}
-------------------------------------------------------------------------

On the MM.jsp I have this... I cant display the <@

page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
session="true"


I tried removing the above... using just session instead of mySession..


HttpSession mySession = request.getSession(true);
String user = (String)mySession.getAttribute("user");
if(user == null) {
response.sendRedirect("LoginPage.jsp");
return;
}


-- HTML FORM HERE IS DISPLAYED AND I am not reredirected to LoginPage

--------------------------------------------------------------------
When the form is submitted ... It goes to Post Method of the servlet that the form calls...

I dont want a new session so I have this...

System.out.println("Prints this");

HttpSession mySession = request.getSession(false);
if(mySession != null)
{
System.out.println("Got session");
user = (String) mySession.getAttribute("user");
}
It doesnt print Got Session... If I set HttpSession mySession = request.getSession(true); -- It gives me a brand new session not the one from the previous page...

I have no idea why its doing this in WSAD...
15 years ago
There is no particular place...Its happening on everyother page...
I set it and the next page it works but it doesnt work in the next to next page when I do getAttribute even though I dont change it or set it to null...

Like in the servlet I say session.setAttribute("user",name); and the next pahe when I do String user = (String) session.getAttribute("user"); it works but the page after that it gives null...
15 years ago
I have absolutely nothing wrong with my code and I checked a 100 times but I am still loosing sessions from one page to other...

I am getting the session okay on one jsp page which has a html form. Once that form is submitted ... I am not changing anything in the session and I just cant get the session in the next Servlet which is called when the form is submitted?

I am using WAS 5 test server under WSAD.

Any ideas?
15 years ago
Hi I am loosing my session in between jsp and servlet while using test WAS 5 from WSAD.

ANyone having the same problem?
15 years ago