cancel
Showing results for 
Search instead for 
Did you mean: 

MDM Java API 2 NoClassDefinitionFound Error

Former Member
0 Kudos

Hello Friends:

UserSessionContext usrSessCnxt = wdThis.getUserSessionContext();
AttributeSchema  attrSchema = MetadataManager.getInstance().getAttributeSchema(usrSessCnxt);

When I am executing the above two lines, I got this error today while working on a Web Dynpro iview using MDM Java API. The code

was failing exactly at the second line. First line, UserSessionContext

is initializing perfectly.

java.lang.NoClassDefFoundError: com/sapportals/connector/connection/ConnectionFailedException

at com.sap.mdm.internal.session.JcaConnectionAccessor.reserveConnection(JcaConnectionAccessor.java:70)

at com.sap.mdm.internal.session.JcaConnectionAccessor.reserveConnection(JcaConnectionAccessor.java:59)

atom.sap.mdm.schema.commands.GetRepositoryDimensionsCommand.execute(GetRepositoryDimensionsCommand.java:73)

at com.sap.mdm.extension.MetadataManager.getRepositoryDimensions(MetadataManager.java:277)

at com.bse.po.mdm.cat.helper.AttributeHelper.getAttributeValues AttributeHelper.java:86)

at com.bse.po.mdm.cat.helper.ProductHelper.getProducts(ProductHelper.java:210)

Yes, I decompiled the MDM Java API classes and found the class JcaConnectionAccessor class with reserverConnection method. It only can throw ConnectionException. Apparently, the program wants to

throw Connection FailedException, which could not be found so, it is an irrevocable error so the Java

VM is crashing.

But there is one interesting thing. When I ran the same code pieces in a stand-alone Java program, it

runs perfectly ????

One more side fact, the Java MDM API jars I have, when I tested with "Java -jar mdm-core.jar"

command gives me 5.5.62.66 as version.When run the same command on the MDM Server Jar files, I

get 5.5.35.42. Also, when I check the version of the repository in MDM Console it is shown as

5.5.62.51. I beleive this doesn't cause the problem, because the last digits only represents some hot

fixes.

The reason why does the Java code works and not the Web Dynpro application ???

Appreciate your help,

Prasad Nutalapati

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Dear All,

I know its too late to replay this post... but I am just replying for the readers who are and will face this problem...

The problem is because of missing setConnectionType(ConnectionTypes.LOCAL_POOL_CONNECTION); call on UserSessionContext object.

By default UserSessionContext uses ConnectionTypes.AUTO_DEFINE_CONNECTION as connection type.

In the NetWeaver J2EE environment, it uses JCA_CONNECTION because of presence of JCA libraries.

But in standalone java since JCA libs are not available, hence it uses LOCAL connection.

For avoiding this error call setConnectionType(..) by specifying connection type

either ConnectionTypes.LOCAL_POOL_CONNECTION

or ConnectionTypes.LOCAL_SIMPLE_CONNECTION.

By doing this it will work in both Standalone Java and NetWeaver environment.

Thanks,

- Shailesh Surve.

Former Member
0 Kudos

Hi,

Please check the following two things:

1. LIbrary references are given under Properties - Webdynpro references for the external library DC

2. Always do a DC build and DC deploy if there are any dependent components.

This will solve your problem as many times we used to face the same problem because any one of the above reasons.

Regards,

Ponraj M

Former Member
0 Kudos

I am using Ext Lib project for the mdm jar files, and I am using that DC as dependent in WD DC. (Local DCs)

When I use the following command

UserSessionContext sessionContext = new UserSessionContext(serverName, repositoryName, regionName, userName);

sessionManager = SessionManager.getInstance();

sessionManager.createSession(sessionContext, SessionTypes.USER_SESSION_TYPE, userPass);

its giving me the errors

java.lang.ClassNotFoundException: com.sapportals.connector.connection.ConnectionFailedException -


Loader Info -


ClassLoader name: [demo.sap.com/testtable] Loader hash code: 10d69a68 Living status: alive Direct parent loaders: [system:Frame] [interface:webservices] [interface:cross] [interface:security] [interface:transactionext] [library:webservices_lib] [library:opensql] [library:jms] [library:ejb20] [service:p4] [service:ejb] [service:servlet_jsp] [sap.com/tcwdapi] [library:tcblexceptionlib] [library:tcblloggingapi] Resources: D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\demo.sap.com~testtable.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\dom4j-1.6.1.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\geronimo-stax-api_1.0_spec-1.0.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\mdm-admin.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\mdm-common.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\mdm-core.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\mdm-data.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\mdm-extension.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\mdm-protocol.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\mdm-publishing.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\poi-3.7-beta3-20100924.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\poi-contrib-3.7-beta3-20100924.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\poi-examples-3.7-beta3-20100924.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\poi-ooxml-3.7-beta3-20100924.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\poi-ooxml-schemas-3.7-beta3-20100924.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\poi-scratchpad-3.7-beta3-20100924.jar D:\usr\sap\C2S\J50\j2ee\cluster\apps\demo.sap.com\testtable\servlet_jsp\webdynpro\resources\demo.sap.com\testtable\root\WEB-INF\lib\xmlbeans-2.3.0.jar -


at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:272)

at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:241)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)

at com.sap.mdm.internal.session.JcaConnectionAccessor.reserveConnection(JcaConnectionAccessor.java:73)

at com.sap.mdm.internal.session.JcaConnectionAccessor.reserveConnection(JcaConnectionAccessor.java:62)

... 61 more

Former Member
0 Kudos

I got this resolved by adding the following lines of code in application-j2ee-engine.xml ofmy ear project.

<reference reference-type="hard">

<reference-target target-type="library" provider-name="sap.com">com.sap.mdm.tech.mdm4j

</reference-target>

</reference>

Former Member
0 Kudos

Hi Prashant,

We are also facing same problem.How did you solve this problem? could you please reply back as soon as possible?

Thanks & Regards,

Veera.

Former Member
0 Kudos

As Prashanth mentioned just add the MDM4J reference in webdynpro library reference and it should solve the problem. we had same issue couple months back and adding the reference in webdynpro properties solved the issue.

Former Member
0 Kudos

Hi Prasad.

You asked "The reason why does the Java code works and not the Web Dynpro application ???"

Is it that the Standalone java code is using MDM Jars of version 5.5.62.66 and your Web Dynpro application is using some different version jars (like 5.5.35.42) ?

If this is the case then, that's a problem. Try using jars whose version is same as your MDM Console Version. Also make sure that all the MDM jars are of same version and there is no duplicate jar entries in your classpath.

Former Member
0 Kudos

Hi,

Try putting the MDM4J Library references in the webdynpro application.

i.e go to the Webdynpro references of the project, go to the Library references tab and add "sap.com/com.sap.mdm.tech.mdm4j"

Hope this solves ur error.

Thanks and Best Regards,

-Prashant.

Former Member
0 Kudos

Hi Prasad,

Accoring to me you cannot use WdThis instead try using the below statement for creating User Session.

UserSessionContext sessionContext = new UserSessionContext(serverName, repositoryName, userName);

then you can use your code just replace

UserSessionContext usrSessCnxt = wdThis.getUserSessionContext(); with the above statement.

Regards,

Jitesh Talreja

DeeptiChavare
Active Participant
0 Kudos

Hi Prasad,

Have you copied MDM .jar files into the lib folder of Web Dynpro project? If not, try doing so.

Former Member
0 Kudos

Hello Deepti:

Thanks for your reply.

I added the MDM libraries in to a external libraries DC and gave the reference.

I have done all the usual steps. The WDP is working fine, except when I try to do the code, where I use

	UserSessionContext usrSessCnxt = wdThis.getUserSessionContext();
	RepositorySessionContext repSessCnxt = wdThis.getRepoSessContext();
	MetadataManager.getInstance().getRepositorySchema(repSessCnxt);

User Session Context is getting created fine. The problem is the third line.

Thanks,

Prasad