Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Cssdk client java code.(Factory initialization failed)
ravisankar
Hi
I am new to cssdk, i am trying a sample java code for CreateClient
but i am getting errors.
com.interwoven.cssdk.factory.CSFactoryInitializationException: (Factory initialization failed)
at com.interwoven.cssdk.factory.CSFactory.getFactory(CSFactory.java:132)
Root cause:
java.lang.ClassNotFoundException: com.interwoven.cssdk.factory.CSSOAPFactory
this is my java code.
CSFactory factory = null;
CSClient client = null;
String username, password, role;
String name = null;
Properties props=new Properties();
try {
props.load(new FileInputStream("samples.properties"));
}
catch ( FileNotFoundException fo ) {
System.out.println( "The properties file was not found" );
}
catch ( IOException io ) {
System.out.println( "Some type of I/O exception has occurred" );
}
try {
factory=CSFactory.getFactory(props);
name = factory.getClass().getName();
System.out.println( "Tin try" );
} catch (CSFactoryInitializationException fie) {
System.out.println("The factory cannot be initialized");
fie.printStackTrace();
}
System.out.println( "Factory of type " + name + " created" );
System.out.println("Factory object created!");
System.out.println("Type read from properties file");
username="master";
password="master";
role="master";
try {
System.out.println( "Getting client with username " + username + ", password " + password + ", and role " + role );
client = factory.getClient( username, role,
password, Locale.getDefault(),
"mydemo", null );
System.out.println( "Client object obtained" );
} catch ( CSException e ) {
System.out.println( "An exception occurred" );
e.printStackTrace();
} finally {
if ( client != null ) {
client.endSession();
}
}
}
can anyone help me what might be the cause of these error.
Find more posts tagged with
Comments
Rick Poulin
"Factory initialization failed" tells me that your code failed on CSFactory.getFactory(props); because your properties were insufficient. What's in your properties file? For local CSClients (within the UITK), all you need is property "cssdk.cfg.path" set to {iwhome}/cssdk/cssdk.cfg, although there's usually ways of getting the CSClient without instantiating a CSFactory. If you're writing a remote client, I believe you need
serviceBaseURL=
http://{server}
com.interwoven.cssdk.factory.CSFactory=com.interwoven.cssdk.factory.CSJavaFactory
You can also check how they implemented CSClientUtil in the WFM guide appendices.
Graph.jpg
ravisankar
my properties file contains
..............................
# creates a CS JNI factory
com.interwoven.cssdk.factory.CSFactory=com.interwoven.cssdk.factory.CSJavaFactory
cssdk.cfg.path=D:/cssdk.cfg
# creates a CS SOAP factory
com.interwoven.cssdk.factory.CSFactory=com.interwoven.cssdk.factory.CSSOAPFactory
# use the machine name and HTTP port of the ContentServices SOAP server
serviceBaseURL=
http://172.16.3.86:80
................
but i had placed all.but getting error..
can you now tell me wat the case of this error
Manik2012
Looking at the root cause, did you include all jars and make sure they are visible to the class?
Rick Poulin
You can't have a properties file specifying two different values for the same key. That's probably why it's unable to create a CSFactory. Use CSJavaFactory if your code runs on the TeamSite server within the UITK, and the CSSOAPFactory if you're running from anywhere else. Also, as Manik mentioned, it does indeed look like you're running from outside TeamSite and are missing the CSSDK client JAR in your classpath.
ravisankar
Thanks for your reply.