Can anyone offer up a "standalone" (i.e., uses "main", not an applet) java source code sample that remotely authenticates a user with a password and uses server side code via helper objects (eventually looking towards walking product structure, e.g., from what I understand, using wt.fc.PersistenceHelper.manager, wt.vc.struct.StructHelper.service, ...)
Thank you, Antonio.
How do you point this client at the Windchill server?
I'm also looking for a way to have this program submit the login credentials without user interaction.
How does it locate codebase/wt.properties on the server? I'm trying to run this on a client machine with no Windchill installed on it.
There must be someinitialization that I'm missing.
For instance, the following example program generates the same exception that I'm getting in the main program I'm trying to create.
All it does is instantiate a "QuerySpec", something that your program appears to do without any special initialization.
package org.hphc.mdr.play;
import wt.query.QueryException;
import wt.query.QuerySpec;
public class GetQuerySpec {
public static void main(String[] args) throws QueryException {
QuerySpec querySpec = new QuerySpec();
}
}
When I run the above, I get:
Exception in thread "main" java.lang.ExceptionInInitializerError
at wt.query.QuerySpec.<clinit>(<u>QuerySpec.java:129</u>)at org.hphc.mdr.play.GetQuerySpec.main(<u>GetQuerySpec.java:9</u>)Caused by: <u>java.lang.NullPointerException</u>
at wt.services.applicationcontext.ApplicationContextFactory.createAdapter(<u>ApplicationContextFactory.java:258</u>)at wt.services.applicationcontext.ApplicationContextFactory.createNamedApplicationContext(<u>ApplicationContextFactory.java:242</u>)at wt.services.applicationcontext.ApplicationContextFactory.getDefaultApplicationContextServices(
<u>ApplicationContextFactory.java:164</u>)at wt.dataservice.DataServiceFactory.<init>(<u>DataServiceFactory.java:68</u>)at wt.dataservice.DataServiceFactory.<init>(
<u>DataServiceFactory.java:63</u>)at wt.dataservice.DataServiceFactory.getDefault(<u>DataServiceFactory.java:37</u>)at wt.pom.DBProperties.<clinit>(
<u>DBProperties.java:224</u>)... 2 more
Interesting!
I found out that if I copy ALL properties from the server to the client, things start working (though the following code fragment takes a LONG time to load everything from the server before it returns! - I'll be looking to pare this down to the bare minimum required, or to find an alternate method):
WTProperties remoteWTProperties = WTProperties.getServerProperties(new URL(WT_INSTANCE_URL));WTProperties localWTProperties = WTProperties.getLocalProperties();localWTProperties.putAll(remoteWTProperties);
Also, Prathap's suggestion about how to enter user credentials without user interaction apparently requires:
Authentication.setAllowUserInteraction(false);
FYI, when it comes to copying properties files to client machines, you should be aware that there may be information in those files that can be used to compromise system and data security. You're playing with fire.
Russ