cancel
Showing results for 
Search instead for 
Did you mean: 

debug and log Web Service

Former Member
0 Kudos

Hello,

i have a problem regarding web service. I wrote a web service (adapted to my needs) as described in the tutorial for java. But when it comes to testing, the web service throws an exception. The method itself is fine (tested and debugged with a local test client).

The question is, is there a way to debug the web service or is there a logfile in which the exception is described in detail?

Thanks in advanced for all replies

regards,

Rene

Accepted Solutions (1)

Accepted Solutions (1)

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi,

I think we have to debug using Local client program. Are you debugging like this.

I hope you created web service from EJB. deploy J2EE application with JNDI name.

Create simple java applcation do the following steps:

public class SSample {

public static void main(String[] args) {

SampleEJB remote = null;

try {

Context ctx = new InitialContext();

SampleEJBHome home = (SampleEJBHome) ctx.lookup("SampleJNDI");

remote = home.create();

} catch (Exception e) {

System.out.println("Exception:" + e.getLocalizedMessage());

}

String result = remote.add(aFirst,aSecond,);

System.out.print("Result:" + result);

} catch (Exception ex) {

System.out.println("Exception:" + ex.getLocalizedMessage());

}

}

}

Go To Run > choose your program(client program to call ejb method) >

Arguments : VM Environment

paste the following code

-Djava.naming.factory.initial=com.sap.engine.services.jndi.InitialContextFactoryImpl -Djava.naming.provider.url=192.168.0.100:50004

replace the server IP address with your server IP address where your ejbs are running.

Under Class path settings for the program put the following jar files.

You can search for them from net weaver soruce folders

or copy from c:\usr\... (search under this folder)

connector.jar

activation.jar

ejb20.jar

ogging.jar

exception.jar

sapj2eeclient.jar

sapj2eenginedeploy.jar

and RUN >>>

this makes testing of your client programs easier, you can find the error trace on which line and saves lot of time.

Regards, Suresh KB

Former Member
0 Kudos

Hello Suresh KB,

sorry that it took me so long to answer this post and thank you for you answer, but i have some question regarding your post.

As i understand so far you try to run the application via the remote interface of the ejb and you print all exceptions, am i right?

So i changed your code for my needs. Please correct me if i did a mistake. I applied JNDI to my bean. I changed the SampleEJBHome and Interface to my home interface. And i substituted "String result = remote.add(aFirst,aSecond,); System.out.print("Result:" + result);" with my code.

But even thought with this changes i get a JNDI exception (java.lang.NoClassDefFoundError: com/sap/tc/logging/LogController) at line: Context ctx = new InitialContext();

so what is wrong?

Regards,

Rene

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Rene,

Exception sounds like your application was not deployed on server. login via visual admin cross check whether your JNDI name registered in Server(You can see all deployed JNDI names).

I suspect 2 step did you gave P4 Port number(50104)

when you try yo get an initial context you have to use P4 Port no of your server.

2. Click next tab ->(x)=Arguments

paste the following code in VM Arguments

-Djava.naming.factory.initial=com.sap.engine.services.jndi.InitialContextFactoryImpl -Djava.naming.provider.url=localhost:50104

replace the server IP address with your server IP address where your ejbs are running.

Under Class path settings for the program put the following jar files.

P4 Port number you can find

Go to http://<servername:port>/index.html

Click on System informattion -> login with administrator and passowrd.

there you will find full details about server and port number(message server port , P4 and enqueue server etc).

Let me know if u want more details

Regards, Suresh KB

Former Member
0 Kudos

hi Suresh,

thanks again for you post, but it didn't work even after double check the P4 port and the JNDI name in visual admin. I still get the exception. I will post it in here, maybe you can figure out what it means:

java.lang.NoClassDefFoundError: com/sap/tc/logging/LogController

at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:290)

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.init(InitialContext.java:219)

at javax.naming.InitialContext.<init>(InitialContext.java:175)

at classes.LocalTestClient.main(LocalTestClient.java:29)

Exception in thread "main"

Thank you for your help,

regards,

Rene

Former Member
0 Kudos

Hi Suresh,

i solved the problem. The logging.jar was missing in the class path. But (as usual) i am facing a new problem. Now, i get a exception called: "Exception:Object not found in lookup of TestArrayJNDI". I assume that the client can not lookup the JNDI name. But when i check it in visual admin i can see an entrance for my bean.

so do you have an idea?

thanks a lot,

Rene

Answers (1)

Answers (1)

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

Sure there is.

Please go to the <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/66/547f09281d464b951c9a3a6b06a12d/frameset.htm">Debug example</a> and follow this one. As your webservice is just an EJB with an extension it works the same way for you!

Regards,

Benny

Former Member
0 Kudos

Hi Benny,

Thanks for your post, if i could make it like this i would be grateful.

As I wrote in my first post i build my service based on a tutorial (Building Web Services with Java, Part I). The problem i am facing with your suggestion is that i can't choose any ear file when it comes to choosing one. The project is deployed, the server is up and running and in debug mode. the only difference i see that i use a remote J2EE engine...

So what am i doing wrong??

thanks,

Rene

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rene,

Almost always with Java you will deploy an ear. The only other case I can think about at the moment is Web Dynpro, but that wouldn't allow you to build a webservice.

Please let me know where this example comes from.

Regards,

Benny

Former Member
0 Kudos

Hi Benny,

The tutorial comes from sdn ( [original link is broken]). My web service is build after this example using the webservice wizard in NWDS. The service itself is a stateless session bean and is deployed via an ear. I just can't choose any ear in the debug window.

thanks for the help,

regards,

Rene

Former Member
0 Kudos

Hello,

nobody an idea what my problem is????

thanks,

Rene

Former Member
0 Kudos

Hi Rene,

There is quite a bit of posting in this thread, and as described in the forum hints, that could discourage some people from reading. Maybe if you post the most recent problem in a new post, that will attract more attention.

To your problem, or more likely to the several problems you are having in this thread - the exceptions and its stacktrace should be seen in the server log files.

These are found at something like

:\usr\sap\<sid>\<id>\j2ee\cluster\server<number>\log

It's hard to say where exactly the exception would go without knowing your application, but I would guess that the likely candidate should be the latest defaultTrace.trc file.

If it's not there you may try to copy everything from there in a new location, reproduce the exceptions and check what files have increased their size. There you should see some information what is wrong.

The other way you could deal is to attach via debugger like Benny has suggested, if you have the server already in a debug mode, just connect with the IDE, put a breakpoint in your code before you have invoked the web service, then trigger your code somehow and trace the execution.

The IDE has also the possibility to make a breakpoint on any unhandled exception, there is such button in the debug view. You may try switching it on.

If you want to invoke your bean from a standalone client and see the result, but you are unable to lookupi the JNDI name, then you should double check what exactly JNDI name you are supplying and under what name is your bean. The easiest way is to login at the server telnet administration (telnet 127.0.0.1 50008)

(The telnet port should be the same as the HTTP on your server but with 8 as last digit), then execute those commands :

jump 0

add naming

lsn > c:\my_naming.txt

you should see in a nice way the JNDI tree on your server and you can check where is your bean and how it should be invoked. However I would personally not go to writing standalone program to see the exception. It sounds like less efforts to try some of the other suggestions.

Btw, ideally, you should be able to code your application so that exceptions are reported in a nice way and you are sure where they are going. For example if your front end is a HTML, then a classic approach is to have an error page where the exceptions will be printed so that you don't have to search logs or debug the server.

HTH

Peter