0

I have used EMC Documentum Foundation Classes to perform some actions in documentum repository. The code was working fine. I exported the project as a runnable JAR and then tried to run it. However I got following error and I am not able to understand it.

enter image description here

And here is the code for DocMovementHandler.getSession() Actually this is no new code but regular code for obtaining documentum session

public IDfSession getSession(String userName, String password)
{
    DfClientX clientx = null;
    IDfClient client = null;
    IDfSession session = null;
    try {
        // create a client object using a factory method in DfClientX
        clientx = new DfClientX();
        client = clientx.getLocalClient();   //takes time

        // call a factory method to create the session manager
        IDfSessionManager sessionMgr = client.newSessionManager();

        // create an IDfLoginInfo object and set its fields
        IDfLoginInfo loginInfo = clientx.getLoginInfo();
        loginInfo.setUser(userName);
        loginInfo.setPassword(password);

        // set single identity for all docbases
        sessionMgr.setIdentity("xyz_repo", loginInfo);
        session = sessionMgr.getSession("xyz_repo");   //takes time 
        //sessionMgr.beginTransaction();
        System.out.println("Session obtaied.");         
    }
    catch (DfServiceException dse)
    {
        DfLogger.debug(this, "Error while beginning transaction. ", null, dse);
        dse.printStackTrace();
    }

    catch (Exception e) 
    {
        DfLogger.debug(this, "Error while creating a new session. ", null, e);
        e.printStackTrace();
    } 
    return session;
}

And that line 38 is client = clientx.getLocalClient();

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Mahesha999
  • 22,693
  • 29
  • 116
  • 189
  • 2
    You need to ask documentum support unless you can post the code for that line. – Peter Lawrey Nov 15 '13 at 15:02
  • ref: http://stackoverflow.com/questions/6020719/what-could-cause-java-lang-reflect-invocationtargetexception – codeMan Nov 15 '13 at 15:04
  • Why do you have some of the console text struck out? We can't help you solve your issues if you can't tell us what they are. – AJMansfield Nov 15 '13 at 15:06
  • Apparently you put null value to a collection (map, set or something like that). Maybe some properties are missing? – agad Nov 15 '13 at 15:08
  • @AJMansfield actually those are my org-specific package names that I dont want to reveal. But trust me they are mere method names where exception is occuring – Mahesha999 Nov 15 '13 at 15:08
  • update original question – Mahesha999 Nov 15 '13 at 15:10
  • The same question is http://stackoverflow.com/questions/16525570/documentum-npe-when-running-as-jar ..., but not answered. – agad Nov 15 '13 at 15:20
  • @Mahesha999 Yes, **they are methods in which the exception is occurring**. But seriously, there is no reason that you would need to hide the names, unless its to comply with some overprotective company policy thing. (And if so, just say 'its company policy', not 'I don't feel comfortable revealing it'.) – AJMansfield Nov 15 '13 at 15:48
  • Yes thats company policy un fortunately, but I provided the required stack trace I guess, what I marked out is mere call chain. And it seems that as poined out by @agad , there seems no easy solution to this. – Mahesha999 Nov 15 '13 at 15:59
  • @Mahesha999 What version of *DFC* (*Documentum CS*) are you using? – Alex K Nov 17 '13 at 09:16
  • possible duplicate of [NoClassDefFoundError while running app exported as JAR (related to EMC Documentum)](http://stackoverflow.com/questions/19999890/noclassdeffounderror-while-running-app-exported-as-jar-related-to-emc-documentu) – Alex K Nov 17 '13 at 09:17

6 Answers6

3

InvocationTargetException is a wrapper. It says, "an exception occurred behind this reflection call", and you use getCause() to get at the inner exception.

The stack trace contains the inner exception. It's an ExceptionInInitializerError. That's another wrapper. It says, "whatever you did caused a new class to be loaded, and that class's static initializer threw an exception".

The final exception in this chain is the NullPointerException. That's the one you need to solve. Which means you need to debug this com.documentum thing. As the comments pointed out, that's not going to be easy.

Sebastian Redl
  • 69,373
  • 8
  • 123
  • 157
  • well that `com.documentum` thing is JAR. I dont understand why is not caused when I run project through eclipse. Packaging it in JAR gives hell of problems – Mahesha999 Nov 15 '13 at 15:29
  • I will in that case like to know the best/not so error prone steps to export project as runnable JAR – Mahesha999 Nov 15 '13 at 15:35
1

Here is the most likely problem:

The static initializer in one of the classes whose names you have struck is adding an entry with either a null key or a null value to a Hashtable, which does not allow null keys or values.

It is using the Hashtable as a place to store a bunch of persistent properties and all that, and my guess is that the value for one of the entries was the null (which is a perfectly reasonable way to indicate that some feature is unavailable or something like that).

The now deprecated Hashtable needs to be replaced with the more modern HashMap.

If it is a library, that you can't just modify, you should replace the whole library with an updated version.

AJMansfield
  • 4,039
  • 3
  • 29
  • 50
  • BTW, I know, `Hashtable` isn't officially `@Depricated`. But the javadoc makes it very clear that you shouldn't be using it anymore. – AJMansfield Nov 15 '13 at 15:51
0

Here are some clues may be helpful. The NullPointerException is thrown by Hashtable#put, and this is normally because either the key or the value is null.

Hashtable#put is called by PreferenceManager.readPersistenceProperties, so most likely it's because something is missing in a properties file so the value is null.

This NPE caused the DfClient class could not be loaded.

Changgeng
  • 578
  • 2
  • 8
0

DfPreferences is the class loading the DFC configuration file dfc.properties. There must be something wrong with it.

David Pierre
  • 9,459
  • 4
  • 40
  • 32
0

Ohkay I did not pin pointed the root cause, but found the solution that will definitely work everytime. EMC provides a flavor of Eclipse called Documentum Composer to work with Documentum Projects. Since Eclipse variation we can create other types of projects like normal Java project, dynamic web project, web services in this. So I recreated my project in Documetnum Composer and exported it as JAR and whoaaaa it worked.

I tried this many times and this worked all time.

Some points to note:

  • You have to replace dfc.properties file in Composer installation folder with one in Content Server
  • The Export to JAR wizard in Composer is a bit different than one in Eclipse
Mahesha999
  • 22,693
  • 29
  • 116
  • 189
0

This is usually caused by dfc.properties being incorrect.

Preferences are stored on the global registry repository and the connection details should be specified in dfc.properties. If not, this (or a similar error can occur).

Also, always try to clear cache and use the correct version of the dfc jar's (v6.7 content server requires 6.7 jars, etc...).

B.T.
  • 132
  • 2
  • 15