Re: Classpath somehow different between develop and deploy? Solved?

2009-05-27 Thread Johan Henselmans


On 28 mei 2009, at 00:10, Johan Henselmans wrote:

I am having troubles, and I would like to share it with you, my  
fellow WA'ers (Webobjects Anonymous). I am sure without your support  
I will have serious relapses...




It always helps to describe what your problem is. After I had  
described what the problem was I head a serious look at  
MacOSXServerClasspath.txt in the App.woa/Contents/MacOS folder.


It noticed that the folder Resources was not available as class path,  
but APPROOT/Resources/Java/ was indeed.


So I took the liberty of adding APPROOT/Resources/ to  
MacOSXServerClassPath.txt. That solved it, my resources were found,  
but that meant I would have to add this line every time I redeployed.  
(Remember the old java credo, Write Once Deploy Often?)


Another way I found was to add a folder Java to the Resources  
folder in the Eclipse Projects, and moved the config files and the  
keystores from the Resources into the Resources/Java  folder.


During the deployment ant-task the stuff is now copied into APPROOT/ 
Resources/Java/, and so the java class finds the resources in its  
classpath.


I am a bit worried about this solution, as it seems that the  
application jar is also added at the same location during deployment.  
Will one folder overwrite the other, so in future times this will lead  
to a partial install? Any chance that this will happen?


How do other people add resources that a Java class assumes is  
somewhere available in a folder describe by the classpath?


I have to use some third party jars that are used to make a  
connection to a secure website, which is taken care of by an SSL  
connection with a certificate which is stored in a java keystore.  
(the java keychains that you can create  with keytool). The class  
that uses this keystore knows which one to use it via a file called  
config.properties. The jar class that uses this data assumes the  
data is all available somewhere in the classpath: it is searching  
for this specific information via


ClassLoader loader =  
Thread.currentThread().getContextClassLoader();

Enumeration p = loader.getResources(keystoreFile);

as I found out via JD-GUI (great app!).

I thought it might be a good idea to store the the keystores and the  
config file in Resources. I have added that file to the Resources  
too. Then I added the Resources folder as a class folder to the  
Library path of the application, so that it is available in the Java  
Build Path.


In Development Everything works, the keystores get loaded, the  
connection is made and the whole world rejoices.


Then I install the Application, and somehow it does not work any more.

I tried to find out if the classpath that contained the  
configuration and the keystores were loaded, but I did not get any  
messages whatsoever about the classpath:


This is the code I tried to find out the classpath:
==
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
Util.log.info(\nClassPath Follows\n);

URL[] urls = ((URLClassLoader) classLoader).getURLs();
for (int i = 0; i  urls.length; i++) {
Util.log.info(urls[i].toString() + \n);
}
==

and this is the output.
==

ClassPath Follows

May 27 23:13:38 WOIdealTestApp[2002] DEBUG IdealConnector  - file:/ 
Library/WebObjects/Applications/WOIdealTestApp.woa/WOBootstrap.jar

==


WOLips 3.4.5800
Eclipse 3.5RC2.
WebObject 5.4.3



Regards,

Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6279159



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/johan%40netsense.nl

This email sent to jo...@netsense.nl


Regards,

Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6279159



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Classpath somehow different between develop and deploy? Solved?

2009-05-27 Thread Chuck Hill


On May 27, 2009, at 4:35 PM, Johan Henselmans wrote:



On 28 mei 2009, at 00:10, Johan Henselmans wrote:

I am having troubles, and I would like to share it with you, my  
fellow WA'ers (Webobjects Anonymous). I am sure without your  
support I will have serious relapses...




It always helps to describe what your problem is. After I had  
described what the problem was I head a serious look at  
MacOSXServerClasspath.txt in the App.woa/Contents/MacOS folder.


It noticed that the folder Resources was not available as class  
path, but APPROOT/Resources/Java/ was indeed.


So I took the liberty of adding APPROOT/Resources/ to  
MacOSXServerClassPath.txt. That solved it, my resources were found,  
but that meant I would have to add this line every time I  
redeployed. (Remember the old java credo, Write Once Deploy Often?)


Another way I found was to add a folder Java to the Resources  
folder in the Eclipse Projects, and moved the config files and the  
keystores from the Resources into the Resources/Java  folder.


During the deployment ant-task the stuff is now copied into APPROOT/ 
Resources/Java/, and so the java class finds the resources in its  
classpath.


I am a bit worried about this solution, as it seems that the  
application jar is also added at the same location during  
deployment. Will one folder overwrite the other, so in future times  
this will lead to a partial install? Any chance that this will happen?


How do other people add resources that a Java class assumes is  
somewhere available in a folder describe by the classpath?


Put them under Sources, I think.


Chuck


I have to use some third party jars that are used to make a  
connection to a secure website, which is taken care of by an SSL  
connection with a certificate which is stored in a java keystore.  
(the java keychains that you can create  with keytool). The class  
that uses this keystore knows which one to use it via a file called  
config.properties. The jar class that uses this data assumes the  
data is all available somewhere in the classpath: it is searching  
for this specific information via


   ClassLoader loader =  
Thread.currentThread().getContextClassLoader();

   Enumeration p = loader.getResources(keystoreFile);

as I found out via JD-GUI (great app!).

I thought it might be a good idea to store the the keystores and  
the config file in Resources. I have added that file to the  
Resources too. Then I added the Resources folder as a class folder  
to the Library path of the application, so that it is available in  
the Java Build Path.


In Development Everything works, the keystores get loaded, the  
connection is made and the whole world rejoices.


Then I install the Application, and somehow it does not work any  
more.


I tried to find out if the classpath that contained the  
configuration and the keystores were loaded, but I did not get any  
messages whatsoever about the classpath:


This is the code I tried to find out the classpath:
==
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
Util.log.info(\nClassPath Follows\n);

URL[] urls = ((URLClassLoader) classLoader).getURLs();
for (int i = 0; i  urls.length; i++) {
Util.log.info(urls[i].toString() + \n);
}
==

and this is the output.
==

ClassPath Follows

May 27 23:13:38 WOIdealTestApp[2002] DEBUG IdealConnector  - file:/ 
Library/WebObjects/Applications/WOIdealTestApp.woa/WOBootstrap.jar

==


WOLips 3.4.5800
Eclipse 3.5RC2.
WebObject 5.4.3



Regards,

Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6279159



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/johan%40netsense.nl

This email sent to jo...@netsense.nl


Regards,

Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6279159



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net

This email sent to ch...@global-village.net



--
Chuck Hill Senior Consultant / VP Development

Come to WOWODC'09 in San Fran this June!
http://www.wocommunity.org/wowodc09/

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing