Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
getUserProperties giving errors.
Bhargav Coca
I am setting up my IDE for CSSDK, I did copy all the Jar Files as needed on local machine. I am trying to Run this java file which gets the UserProperties. (OOTB example)
[html]
package cssdk_test;
import java.util.Locale;
import java.util.Properties;
import com.interwoven.cssdk.access.CSUser;
import com.interwoven.cssdk.common.CSClient;
import com.interwoven.cssdk.common.CSException;
import com.interwoven.cssdk.common.CSNameValuePair;
import com.interwoven.cssdk.factory.CSFactory;
public class GetUserProperties
{
public static void main(String[] args)
{
boolean success = false;
String factoryType = null, username = null, password = null, userNameToGetProperties = null;
do
{
System.out.println("Success Variable : " + success);
if( args.length < 4 )
break;
factoryType = args[0];
if( "JAVA".equalsIgnoreCase(factoryType) &&
args.length < 5)
break;
if( !"JAVA".equalsIgnoreCase(factoryType) &&
!"SOAP".equalsIgnoreCase(factoryType))
break;
success = true;
}
while( false );
if( !success )
{
printUsage();
System.exit(0);
}
Properties properties = new Properties();
if( "JAVA".equalsIgnoreCase(factoryType))
{
///////////////// Define Config Properties for CSJavaFactory ///////////////////
properties.setProperty(
"com.interwoven.cssdk.factory.CSFactory",
"com.interwoven.cssdk.factory.CSJavaFactory");
properties.setProperty(
"defaultTSServer",
args[1]);
properties.setProperty(
"ts.server.os",
args[2]);
username = args[3]; password = args[4]; userNameToGetProperties = args[5];
///////////////////////////////////////////////////////////////////////////////
}
else
{
///////////////// Define Config Properties for CSSOAPFactory ///////////////////
properties.setProperty(
"com.interwoven.cssdk.factory.CSFactory",
"com.interwoven.cssdk.factory.CSSOAPFactory");
properties.setProperty(
"serviceBaseURL",
args[1]);
username = args[2]; password = args[3]; userNameToGetProperties = args[4];
///////////////////////////////////////////////////////////////////////////////
}
CSFactory factory = CSFactory.getFactory( properties );
System.out.println("Factory initialized: " + factory );
try
{
// Construct the CSClient object.
CSClient client = factory.getClient(
username, // UserName
"", // Roles: No-Op
password, // Password
Locale.getDefault(), // Locale
"Example", // Application Context
null ); // TeamSite HostName [ will be read from properties object ]
CSUser user = client.getUser(userNameToGetProperties, true);
CSNameValuePair[] props = user.getProperties(null);
for( int i=0 ; props != null && i < props.length ; i++ )
{
System.out.println(props
.getName() + " = " + props
.getValue());
}
}
catch( CSException e )
{
System.out.println("Exception occured while retrieving CSClient object!");
e.printStackTrace();
}
}
private static void printUsage()
{
System.out.println("Usage for CSJavaFactory: \n" +
"\t$JAVA_HOME/bin/java com.interwoven.cssdk.examples.access.GetUserProperties JAVA ");
System.out.println("\n");
System.out.println("Usage for CSSOAPFactory: \n" +
"\t$JAVA_HOME/bin/java com.interwoven.cssdk.examples.access.GetUserProperties SOAP ");
System.out.println("Java CSSDK Code");
}
}
[/html]
When I run this as anticipated, I get this error
[html]
Exception in thread "main" java.lang.NoClassDefFoundError: com/interwoven/cssdk/
examples/access/GetUserProperties
Caused by: java.lang.ClassNotFoundException: com.interwoven.cssdk.examples.acces
s.GetUserProperties
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: com.interwoven.cssdk.examples.access.GetUserPrope
rties. Program will exit.
[/html]
I even ran this from a command prompt as follows:
com.interwoven.cssdk.examples.access.GetUserProperties JAVA
still the same error.
1.What is right way of making this work?
2. Should my .jar file reside in /com/interwoven/cssdk folder?
3. In my IDE i can just add the libraries from picking up a folder so all my Jars reside in folder called Libraries,
4. how should i mention this in my code?
Please advice?
Thank You
Find more posts tagged with
Comments
There are no comments yet