Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Code is throwing NoSuchField Error

 
Davidson Rajapal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have ran the below code in java, but it is throwing an error. Can you please help me to correct this code?

code:-

public class try2
{

public static String dispatcherURL = "http://cog8dv01.merck.com:26423/p2pd/servlet/dispa tch";
private static String nameSpaceID = "cogdvldap";
private static String userName = "goodr";
private static String password = "hjghhbh";
public ContentManagerService_Port cmService=null;
private static String reportSearchPath1 = "/content/package[@name='Z_USHH ROME Inventory Reporting']/folder[@name='USHH']/folder[@name='USH H - ROME']/report[@name='ROME Literature Spreadsheet']";
private static String saveLocation1 = "C:/Report";
public ReportService_Port reportService = null;


public static void main(String args[])
{

try
{

try2 mainClass = new try2(); // instantiate the class

// Step 1: Connect to the Cognos services
mainClass.connectToCognos(dispatcherURL);

// Step 1: Connect to the Cognos services

}
catch(Exception e)
{
}
}

public void connectToCognos(String dispatcherURL)
{
ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator();
try
{
URL url = new URL(dispatcherURL);
cmService = cmServiceLocator.getcontentManagerService(url);
}
catch (Exception e)
{
e.printStackTrace();
}
}

}


ERROR:-


C:\Program Files\Java\jdk1.6.0_27\bin>java try2

Exception in thread "main" java.lang.NoSuchFieldError: RPC
at com.cognos.developer.schemas.bibus._3.ContentManag erServiceStub.<clin
it>(ContentManagerServiceStub.java:25)
at com.cognos.developer.schemas.bibus._3.ContentManag erService_ServiceLo
cator.getcontentManagerService(ContentManagerServi ce_ServiceLocator.java:43)
at try2.connectToCognos(try2.java:100)
at try2.main(try2.java:78)
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That problem isn't caused by that code. It's a configuration error -- you are running version X of something which expects to be version Y. Where in this case, version Y would have a field named 'RPC' but version X doesn't.

 
Kiran Yadav
Ranch Hand
Posts: 35
Eclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Davidson,

Please give the complete error logs.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this error because I added a jar in my software code but the JBoss already had another version of that jar.

Are you not with the same problem?
 
Davidson Rajapal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,yadav and Herbert for your reply.

@ Paul

Can you please tell me How to Eradicate this configuration Error.

I am using Java jdk1.6.0_27


I am following the instructions to run the above java code which was given in the below link

http://www.ibm.com/developerworks/data/library/cognos/development/how_to/page565.html?ca=drs-

@yadav

The below is the complete Error log. It is compiling successfully but throwing below Error while running

ERROR:-

C:\Program Files\Java\jdk1.6.0_27\bin>java try2

Exception in thread "main" java.lang.NoSuchFieldError: RPC
at com.cognos.developer.schemas.bibus._3.ContentManag erServiceStub.<clin
it>(ContentManagerServiceStub.java:25)
at com.cognos.developer.schemas.bibus._3.ContentManag erService_ServiceLo
cator.getcontentManagerService(ContentManagerServi ce_ServiceLocator.java:43)
at try2.connectToCognos(try2.java:100)
at try2.main(try2.java:78)

@ Herbert

I have added all the below jar files. I have set the classpath for this jar files in the Environment variable. Is any other Jar file I have to add?

axis.jar;
activation.jar;
commons-discovery-0.2.jar;
commons-logging-1.1.jar;
commons-logging-adapters-1.1.1.jar;
commons-logging-api-1.1.jar;
jaxen-1.1.1.jar;
jaxrpc.jar;
mail.jar;
resolver.jar;
saaj.jar;
serializer.jar;
xml-apis.jar;
xercesImpl.jar;
wsdl4j-1.5.1.jar;
axisCognosClient.jar;
saaj-api.jar;.


Please help me to Eradicate this Error.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Davidson Hosannah and Kiran Yadav.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can not tell you which jar it is. Add the Server library to your project and remove all of them. After you do that, add only the one that break your compilation.
 
Davidson Rajapal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ritchie

@Herbert

I am not able to get you.How can I get Server library? Pl help me
 
Davidson Rajapal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Herbert

It seems Server library can be found only in Eclipse. Is it? I am not using Eclipse. I just downloaded all the jar files from net and pointed in environment variable. is there any other to rectify the error? Can we access it through command prompt?

 
Kiran Yadav
Ranch Hand
Posts: 35
Eclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Davidson,

The rt.jar is missing here. You need to add this rt.jar
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rt.jar will be added automatically... no need to add that....
 
Davidson Rajapal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yadav,

I have downloaded this jaxws rt.jar file and pointed in environment variable..Still the Same Error is showing.

Can anybody help me to rectify the error?

I am waiting for the response

I should run the code successfully.



 
Kiran Yadav
Ranch Hand
Posts: 35
Eclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here, one thing is clear that the error is due to cognos, the classpath or environment or coding issue is not there.

Give me the jar names from which you have imported the following files
1. ContentManagerService_Port
2. ReportService_Port

Seems that, the version used for these files have some issue.

You can also try with cognos-axis.jar and cognosClient.jar jar files.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don’t think this is a “beginning” question any more. It might never have been a “beginning” question at all. Not sure where to move it; let’s try “other products”.
 
Michael Mann
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Upon reading the Cognos document "IBM Cognos Proven Practices: Hands-on IBM Cognos Software Development Kit Programming"
and looking at your post i think the problems is that the posted code is for Cognos 10.1 and you are using version 8 where the api and the classes
to import and use are different.

Quote from the cognos document

This document has been written using IBM Cognos BI version 10.1 as the reference version. However, the concepts presented also apply to versions 8.3 and greater of IBM Cognos 8 BI. The code sample supplied with
this document will need to be adapted to work with IBM Cognos 8 BI.


My advise would be to write a mail to Claudiu Popescu - the author of the document - and ask him for the code for Cognos 8
 
Davidson Rajapal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

Thanks for all your reply..

My Error is disappeared now by following the instructions from the below link

https://www-304.ibm.com/support/docview.wss?uid=swg21441931

I will get back to you ..if i get the same error again

I got some new Error now "cannot find symbol method getResponseHeader"..I have posted in this forum..Please help me in it.

Thanks for your reply..I am thankful to you...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic