philber fang

Greenhorn
+ Follow
since Dec 30, 2004
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 philber fang

I know the dir is under the application installation dir specified during the installation of the app using websphere admin console. But now my question is, in a cluster environment, the installation dir will be different for different cluster servers, so how my code know where is the "imgdir" directory and generate gif files under it?

thanks....a lot....
15 years ago
Hi Gurus,

I need to generate some gif images files at run time to let the html files access these images files vie the html tag "img src=/imgdir/generated.gif", but don't know how I could write to the dir containing the gif files(where is it after deployed on the unix box?), say, a dir called imgdir under the WebContent folder in a web project.

I did some search research on the web but getting nothing and now I am stuck on this for long.

Really needs some help....

Thanks a millions...
15 years ago
Please note the exactly same piece of code running in the simple server, this could eliminate lots of possibilities.... like networking issue, server name/port number error...

So the only difference is the server configuration. In the second server(not the ejb server) we have https and form authentication setup.
I really need some websphere guru's help, I've stuck on this for long:

I can call a ejb(the method successfully run and gives me correct return value) running in a remote server, a websphere 5.1 cell network deployment environment, from a servlet running in my local server(on a different machine), which is the testing env. server in the WSAD 5.1. This server is a very simple one created quickly with all the default values. It is all good. I run the method (getRole) it gives me value I expected.

But when I copy/pasted the same code(paste below) calling the ejb into another application, which is running inside a different workspace but in the same WSAD 5.1 IDE, same testing env. server but with different server configuration(in another word, this piece of code is running in 2 applications, both inside my WSAD in my local machine), the same piece of code failed on creating an initial context for the lookup.

===================================
in the first simple server it is all good:
**** before lookup ejb...
*********bean got:class com.eistream.sonora.webservices._WsSessionEJB_Stub
[27/06/05 10:36:31:680 EDT] 18f7b7e8 SystemOut O

**********getRole method returns:Admin

====================================
But I got the error msg. on the second server console:

**** before lookup ejb...
[27/06/05 10:46:13:023 EDT] 82ef74e WsnInitCtxFac W NMSV0602E: Naming Service unavailable. A communications error occurred.
[27/06/05 10:46:13:023 EDT] 82ef74e SystemOut O

**********getRole method returns: A communication failure occurred while attempting to obtain an initial context with the

provider URL: "corbaloc:iiop:ejbserver00:8811". Make sure that any bootstrap address information in the URL is correct and

that the target name server is running. A bootstrap address with no port specification defaults to port 2809. Possible

causes other than an incorrect bootstrap address or unavailable name server include the network environment and workstation

network configuration.



===================================

They are all runing exactly the same piece of code:

System.out.println("\n\n********** before lookup ejb... ");
String myserver = "ejbserver00";
String myport = "8811";

java.util.Properties properties = new java.util.Properties();
properties.put(javax.naming.Context.PROVIDER_URL,
"corbaloc:iiop:ejbserver00:8811");
// "corbaloc:iiop:ejbserver00:8811");
// "iiop://ejbserver00:8811/"); use this also works
properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
javax.naming.InitialContext initialContext =
new javax.naming.InitialContext(properties);

Object objHome = initialContext.lookup(
"cell/clusters/Cluster1/com.eistream.sonora.webservices.WsSessionEJBHome");

WsSessionEJBHome myWsHome = (WsSessionEJBHome)
javax.rmi.PortableRemoteObject.narrow
(objHome,WsSessionEJBHome.class);
WsSessionEJB myWsSessionEJB = (WsSessionEJB)myWsHome.create();
System.out.println("\n\n**********bean got:"+myWsSessionEJB.getClass());
String[] aa = myWsSessionEJB.getRoles();
System.out.println("\n\ngetRole method returns:"+ aa[0]);

==================================================================================================

It shouldn't be any network problem since both tries are on my local machine. So the only differenct is the server configuration.

So my question is: what kind of configuration in the second server could prevent me from creating a initial context? In my mind, there shouldn't be anything in the second server prevents me from getting a naming context if the same code works in another server. Please note the remote server name and port(for jndi lookup are the same and correct) are the same when trying on these 2 servers.

And I also specify the Provider URL, which tells the server don't use the default local namespace(port 2809) to lookup the bean.



Any help is appreciated.....
Thanks a million times......
Thanks a Joe Ess. I try your way and it works!!

I am supprised that I got the answer so quickly!!
15 years ago
I tried fileInputStream.reset(), it throws exception says the "mark/reset not supported".

I need to read the file into a byte array, first I have to use a while loop
while ( (currentByte = fin.read() ) != -1) {
fileLength ++; }

to count how many bytes of the file, then using the counter to new a byte array, then use
fin.read(array,0,array.length);
but it doesn't work properly, the file(a pdf) cannot be open. But if I hard code the lengh of the file without a loop, the file generated properly.
So I guess it is the file pointer problem, after the while loop, the pointer is positioned at the end of the file, thus even the subsequent call I specify the beginning position, still doesn't work properly.

I am using websphere 5.1, just support java 1.3, 1.4 has some new features I can use to avoid a while loop.

And I don't want to create another file input stream, looks not good.

Anybody can help? Thanks a lot.......
15 years ago
Hi RR Kumaran and others,

If the client is not a standalone java client, but a servlet running on Websphere 5, is it still the same that I just set the properties you mentioned below in my servlet calling the web services?

All any one knows the steps to set this(client only) up in websphere? Since the JVM is in the container though.

Thanks in advance!!!

Originally posted by RR Kumaran:
there is nothing like ready code.

1. Import the server certificats in ur client truststore,
2. run wsdl2java on https endpoint and generate the stubs
3. set below properties in ur client program

System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");

Security.addProvider (new com.sun.net.ssl.internal.ssl.Provider());

System.setProperty("javax.net.ssl.trustStore", "<trust store location>");
System.setProperty("javax.net.ssl.trustStoreType", "jks | JCEKS");
System.setProperty("javax.net.ssl.trustStorePassword", "??");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore", "<trust store location>");
System.setProperty("javax.net.ssl.keyStorePassword", "??");

15 years ago
Thanks a lot, sergio mendez-rueda! Your first post is helping people rather than ask question, that's good!

Originally posted by Balaji Loganathan:

Inputstream is not serializable, and not interoperable.
bytearray is good choice.



Thanks a lot for your reply Balaji, so you mean the return type needs to implement the Serializable interface.

But I don't understand, what do you mean by "not interoperable"?

thanks
16 years ago
I know that all parameters in the service method needs to implements the Serializable, but not sure about the return data of the method?

I need to create a webservice method which would retruns a pdf file, there are a couple of different ways of doing this, one is that I'll open the pdf file and return an inputStream to the client, and the client can read from the stream. But the question is, the inputStream(or BufferInputStream) doesn't implement the Serialization, is it needed?

Or any other ways, return a byte array?

Thanks in advance.
16 years ago