Very strange issue - Same content different results ?

I am trying to connect to a remote server for folder creation..

I have a file named ProcessTool which uses createFolder() to connect to the server and create folders... I am calling createFolder()

1) from test.java (Simple Java Application file) and

2) CreateAction.java(Struts Action File).

The connection to the server works from the test .java but not from the CreateAction. I have tried almost everything. Please help.

This is my code below

ProcessTool.java

publicstaticboolean createFolder( String newDir, String sid, String unc ){

try{

PCShare share =new PCShare("location","username","password");

[b] System.out.println("Open disk");[/b]

[u]DiskSession disk =SessionFactory.OpenDisk(share);[/u]

[b]System.out.println("Opened disk");[/b]

disk.CloseSession();

}

catch ( Exception e ){e.printStackTrace();

returnfalse;}

returntrue;

test.java file

publicclass test{

publicstaticvoid main(String[] args){

boolean success = ProcessTool.createFolder("abc","xyz","pqr");

System.out.println("process tool "+success);

}}

The above code works and success is true.

CreateAction.java filepublic ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception{

boolean success = ProcessTool.createFolder("abc","xyz","pqr");

System.out.println("process tool "+success);

return mapping.findForward("next");

}

Here an exception is thrown from the ProcessTooljava.net.ConnectException: Operation timed out: connect

CreateAction.java prints only Open disk and then throws an error but from the test.java application it prints both Open disk &Opened disk without errors...

[3232 byte] By [keepswimminga] at [2007-11-26 19:20:00]
# 1
Does the user which is running the web server have permission to create this directory?
ChristopherAngela at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...
# 2
I am just trying to connect to the file server and both test.java and CreateAction.java use the same credentials to connect to the server.. one is able to connect but not the other...
keepswimminga at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...
# 3

> I am just trying to connect to the file server and

> both test.java and CreateAction.java use the same

> credentials to connect to the server.. one is able to

> connect but not the other...

What are you talking about? They are just pieces of Java code, and the code doesn't have anything in it which "connects" to any server.

Test.java is a standalone app, which runs under whatever account you run it under when you type:

java Test

at the command-line (or from a batch/cmd file or IDE or whatever).

The other piece of code runs within a J2EE app server (Tomcat, JBoss, Weblogic, whatever you're using), and that runs under whatever account started up the server.

Those two accounts, if not the same, and/or what machines the processes are running on (if not the same), are what you need to look at.

Edit: Never mind (maybe). I don't know what this class is really doing, since it is not a standard one:

> PCShare share = new PCShare("location","username","password");

Message was edited by:

warnerja

warnerjaa at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...
# 4
> The other piece of code runs within a J2EE app serverIf that is the case then you need to check the application server to see if it is using a security manager that prevents connection to other systems.
DrClapa at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...
# 5

>Test.java is a standalone app, which runs under whatever account you run

>The other piece of code runs within a J2EE app server (Tomcat, JBoss, >Weblogic, whatever you're using), and that runs under whatever account >started up the server.

>Those two accounts, if not the same, and/or what machines the processes >are running on (if not the same), are what you need to look at.

This makes sense... I am not sure what account the websphere studio server is using or how to change that... Any ideas?

Maybe the J2EE server is trying to connect before PCShare... I am also unfamiliar with PCShare... PCShare is a third party (Starlasoft) library file for which I do not have the sourcecode.. http://starlasoft.com/jlan/files.html

I do have the docs though... The http://starlasoft.com/clientagree.html link downloads a jlanclientdemo file which has docs in it which describe PCShare..

>If that is the case then you need to check the application server to see if it is >using a security manager that prevents connection to other systems.

Could it be server security or j2ee security? How do I check the security manager?

This is the full error

java.net.ConnectException: Operation timed out: connect

java.net.PlainSocketImpl.socketConnect(Native Method)

java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:345)

java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:157)

java.net.PlainSocketImpl.connect(PlainSocketImpl.java:144)

java.net.Socket.<init>(Socket.java:294)

java.net.Socket.<init>(Socket.java:148)

com.starla.netbios.NetBIOSSession.openSession(NetBIOSSession.java:1244)

com.starla.netbios.NetBIOSSession.Open(NetBIOSSession.java:1200)

com.starla.smb.client.SessionFactory.connectNetBIOSSession(SessionFactory.java:2407)

com.starla.smb.client.SessionFactory.OpenSession(SessionFactory.java:1783)

com.starla.smb.client.SessionFactory.OpenDisk(SessionFactory.java:1589

ProcessTool.createFolder(ProcessTool.java:23)

keepswimminga at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...
# 6

> Edit: Never mind (maybe). I don't know what this

> class is really doing, since it is not a standard

> one:

> > PCShare share = new

> PCShare("location","username","password");

I assumed it was like a jdbc connection for which u provide the host, username and password... Maybe theres more to it...

keepswimminga at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...
# 7

Oh, so you actually have error messages? That makes things a lot easier.

java.net.ConnectException: Operation timed out: connect

Most likely you have a network issue preventing your application server from connecting. Debug that by trying to ping and telnet from the app server to this other server. Not from a complicated application but just from the command line. If you can do those things then it's probably the application server applying Java security.

DrClapa at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...
# 8

I was unable to ping but got that issue resolved and now I am able to ping and telnet...but the problem did not go away..

The strange thing is that when I try the connection on another server on the network it connects (because its a local account)...

it doesnt connect to the test server I want it to connect to with the domain account... The security settings, server config, everything looks the same.

The difference is local account vs domain account... Could java security make such a distinction and not allow me to connect to domain accounts?

keepswimminga at 2007-7-9 21:37:34 > top of Java-index,Java Essentials,Java Programming...