Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Web-API examples

Highlighted
Kazarin Alexand
Occasional Visitor

Web-API examples

Hello all. I trying to run one of nine web-api examples for testing web-api mechanism from CLI, but always get java.lang.NoClassDefFoundError. I do it this way: java -cp web-api.jar Example2 [arg0] [arg1] [arg2] [arg3]. There are directory with web-api.jar in classpath.
The question is, what i should do for testing web-api examples?
http://linkedin.com/in/alexanderkazarin
17 REPLIES

Re: Web-API examples

Hi Kazarin,

NoClassDefFoundError obviously points to a problem with your path. It may be easier for you to run the samples in an IDE first (like Eclipse, NetBeans etc) because they take care of your class path when running the examples. You only need to import web-api.jar into your classpath and everything works.
Kazarin Alexand
Occasional Visitor

Re: Web-API examples

Hallo, Mark. Its important for me to decide the problem with my path, because I am going to write my own web-api application based on examples. What I should import in the classpath in addition to web-api.jar?
http://linkedin.com/in/alexanderkazarin

Re: Web-API examples

You need the following on your classpath:
- Java JRE
- web-api.jar
-your custom classes that you build

I think your call to Example2 is wrong. You should call it using com.hp.itsm.api.examples.Example2
Kazarin Alexand
Occasional Visitor

Re: Web-API examples

Thanks, Mark. I have successfully run Example2 this way: java -cp web-api.jar com.hp.itsm.api.examples.Example2 [arg0] [arg1] [arg2] [arg3]
But I couldnt run Example3..8, only examples 2 and 9. Example2 and Example9 classes are imported in web-api.jar. Is it mean that I should include my custom class in web-api.jar for it executing possibility?
http://linkedin.com/in/alexanderkazarin

Re: Web-API examples

only Example 2 and Example9 are actually included in web-api.jar. In order to use the other examples you have to compile the source code by yourself.
If you are developing standalone Java applications for OpenView then you should have a look at the Eclipse Rich Client. Using this framework you can build a nice GUI including some OpenView functionality within hours. (The initial effort to get going is about 1-2 weeks)
Kazarin Alexand
Occasional Visitor

Re: Web-API examples

Ok. Can you describe, how could I run the compiled Example3.class?
http://linkedin.com/in/alexanderkazarin

Re: Web-API examples

after compiling the sourcecode (it is included in the javadoc files from web-api) you have to include the path to the Example3.class file into your -cp argument. Then you call it in the same way as Example2 (including the package name com.hp.itsm.api.examples)
Or you create your own package (e.g. my.package) and call it via my.package.Example3...
lema
Super Collector

Re: Web-API examples

hi guys.

i tried to understand what source docs you are talking about but couldn't. there are only html docs in a javadoc folder i have.

i also am trying to make a program relevant to these examples, especially example3.
i run example2 and example9. i found these two examples only separately in another web-api folder which includes web-api.jar.
but also i have found examples from 1 to 9 in a different folder with sd-webapi.jar. although i have included sd-webapi.jar into eclipse those examples(1-9) are all showing an error regarding OID table, i.e. "The import com.hp.ov.obs.OID; cannot be resolved".
i have extracted web-api.jar and sd-webapi and couldn't find any class regarding OID.
so, is there any other library by which i can run Example3,4,5,6,7,8?
Raman Shcharbak
Frequent Visitor

Re: Web-API examples

On sd5 i had to add this jars to CP:
sd-webapi.jar
OvObsWebApi-Client.jar
You can look at source code of your program to see what packages are imported and find related jars. So, then add them to classpass.
Ð Ð°Ð²ÐµÑ Ð½Ð¾Ðµ можно Ð±Ñ Ð»Ð¾ и на Ñ Ñ Ñ Ñ ÐºÐ¾Ð¼ Ð½Ð°Ð¿Ð¸Ñ Ð°Ñ Ñ .
lema
Super Collector

Re: Web-API examples

hi Roma.

but where do i get this OvObsWebApi-Client.jar?

the error i'm all facing with is the absence of OID class, "The import com.hp.ov.obs.OID cannot be resolved.". in EXAMPLE3 the error appears on already imported class:

import com.hp.ov.obs.OID;

and eclipse itself offered to replace it with "import org.ietf.jgss.Oid;" (it is from JRE System Library jre1.5.0_06). i did so. all went ok but one error is left. it is on this part of code snippet:

if (templates[0].getEntity().getOID().equals(problemHome.getEntityID())) {
templateID = templates[0].getOID();
}

on templates[0].getEntity().getOID(). it says "The type com.hp.ov.webapi.impl.IApiHome cannot be resolved. It is indirectly referenced from required .class files.".

so?? i've also found AppOID from web-api.jar, the same happens when i include this class into sd-webapi.jar and replace OID with it.

how you think what else can i do?

lema
Raman Shcharbak
Frequent Visitor

Re: Web-API examples

What version of SD do you have? com.hp.ov.* classes are (as i think) from SD 5 data model. Where did you get this example files from?
I`ve found com.hp.ov.obs.OID file in OvObsSDK.jar in SD5.1
lema
Super Collector

Re: Web-API examples

we do have SD5.1. and all the docs/libraries i do have are from our System Administrator of SSC group (HP OpenView). where do you get these libraries? i logged in to the server where the HPOV Console is through remote admin, so i did see no similar libraries there.
Raman Shcharbak
Frequent Visitor

Re: Web-API examples

Have you installed web-api package from 5.1 dist or simply copied from some sd45 server(as you mentioned web-api.jar, not as in 5.1 sd-webapi.jar)?
In attachement you can find a list of jars on my windows deployment in Program Files\HP OpenView\java\
lema
Super Collector

Re: Web-API examples

wait wait,i got a little confused.
there is HPOpenview Console on aother server, into where i login through remote admin. there is nothing on my own machine except docs like programmers' guide etc/libraries/examples which our admin has sent to me. i 'm trying to run Examples in Eclipse where i have put those two libraries (web-api.jar, sd-webapi.jar). so, i guess the right library is enough to run any example which are written on java. am i wrong?
lema
Super Collector

Re: Web-API examples

thank you a lot for the list. i found them on that server where the HPOV is.
now, should i run examples on that server with HPOV or i may also run them on my own machine?
Raman Shcharbak
Frequent Visitor

Re: Web-API examples

Raman Shcharbak
Frequent Visitor

Re: Web-API examples

Of course you can run them anywhere, where needed libs exist :), dont forget to use right servername in session object, or to pass it via command line attributes.
//Add this to "OnDomLoad" event