cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with EJB as a Web Service

Former Member
0 Kudos

I developed an EJB that uses the Enterprise Connector to connect to SAP and pull data. I have verified that this EJB works through a console Java application. I then put a Web Service wrapper around this EJB and built the JAR file. Then I create an EAR project in order to deploy it. This is where the weird stuff happens. If I include the library from the EJB project into the Archive Build Information, then try to build the EAR file, it will first delete the JAR file that was created and then throw an error saying it's missing a required resource. Can anyone tell me if I'm doing anything wrong? Why is it deleting my JAR file to include it in the EAR file?

Thanks In Advance

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Stephen,

Did you solve the problem?

Please mark it as closed, then.

If so, don't forget to assign points.

Click on the Yellow Star icon in each reply.

You can give:

1 10 pointer (solves problem)

2 6 pointers (very helpful)

lots of 2 pointers (helpful)

Thanks!

Joan (and Mark Finnern)

Former Member
0 Kudos

No I haven't solved the problem yet. I am still unable to properly deploy an EJB or Java class as a web service using Netweaver Developer Studio. The problem hasn't changed.

zubev
Employee
Employee
0 Kudos

Hi Stephen,

Don't add the EJB project using the EAR project properties, but using the J2EE Explorer -> right click on the EAR project and select Add modules. Then select the EJB project that needs to be added.

Best regards,

Alexander

Former Member
0 Kudos

If I only add the module then generated objects (from the SAP Connectivity Builder) aren't included in the project. I receive an error within the bean call saying it can find the jco files and/or JCB created files.

Former Member
0 Kudos

Stephen,

To add the EJB module to your ear project, go to the J2EE explorer view, right click the ear project, and select Add Modules. In the dialog, select the EJB project and click ok. This will include a <module> entry in your ear application.xml for the jar file.

Hope this helps.

Former Member
0 Kudos

I have done this, and was able to successfully deploy the EAR file, however when I try to run the Web Service I get a NoClassDefFound error because it can find classes that are part of the EJB (the internal classes that are built by the SAP Enterprise Connector). In the Standalone Java Application I was able to add the EJB project to the project references as well as add the JAR in the build information. When I try to do the same with the EAR project, when I build the EAR, the JAR is deleted and then I receie an error saying it can't find the JAR that it just deleted.

I am looking into something I didn't notice before. I noticed in help it talks about a DC project. Do I need one of those to deploy an EJB as a web service? That's the path I'm taking now.

Former Member
0 Kudos

Can you give the first 10 lines of the stack trace of the NoClassDefFound Error? Does it indicate which class is missing ? Is it the Node class?

Thanks

Bhanu

zubev
Employee
Employee
0 Kudos

Hi Stephan,

See if the all required jar files are in the EAR file.

Best regards,

Alexander

Former Member
0 Kudos

I am using Rfc_Customer_Get so it's missing the BRFCKNA object type. And as stated in my previous post I do make sure all the required jar files are in the EAR file, however when I try to build the EAR file, Netweaver first deletes my jar and then throws an error saying it can't find it.

I still haven't figured this out. I have tried 3 different RFCs and none of them deploy. Here is what I do.

I build the EJB project. Then add the appropriate jco jars. Then use the SAP Connectivity Builder and create the EJB using Rfc_Customer_Get. I create a function that will return customers based on customer name. Build it.

At this point I import it into an "EJBTester" project I created and run it in there using "Run -> Run As... -> Java Application." Everything runs great. I get back the expected results.

I then expand the ejb-jar.xml. Right click on the bean and select "New -> Web Service." Then I specify a name and configuration. Then I check the methods that I want to expose (all returning strings). Then select finish. It finishes with the web service building. Then I build the jar file.

Then I create an EAR project, and this is where it gets weird. If I right click on the EAR project and select properties, and add the Project under project references, the EAR build completes with no errors. However, when I deploy it is when I get the NoClassDef error. If I go back into the EAR project properties and select Archive Build Info, and add the project in there as well as project references, then I try to build the EAR file it first deletes the JAR file from the EJB project and then throws an error saying it can find the JAR.

Can anyone explain to me what I'm missing?

Thanks in advance, this is really bugging me.

Former Member
0 Kudos

I think I may have figured out the Netweaver deleting my JAR file issue. In the EAR Project properties -> Archive Build Info there are two projects listed; one is the JAR project and the other is the EAR projet. If I choose to include the JAR project it deletes it. If I choose to include only the jar file that exists in the EAR project it builds the EAR file successfully without deleting the JAR.

It looks like it's having the same NoClassDefFound error though. (Remember, this works when I include this in a console Java application and run the same function)

===========================================

com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception thrown by the GetCustomerByName method.

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.java:197)

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEAN_Stub.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEAN_Stub.java:132)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)

at $Proxy109.GetCustomerByName(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:124)

at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:145)

at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:67)

at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)

at SoapServlet.doPost(SoapServlet.java:51)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:377)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:257)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:322)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:300)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:699)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:224)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:140)

Caused by: java.lang.NoClassDefFoundError

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEANBean.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEANBean.java:74)

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.java:181)

... 32 more

; nested exception is:

java.lang.NoClassDefFoundError</faultstring><detail><ns1:java.rmi.RemoteException xmlns:ns1='http://sap-j2ee-engine/client-runtime-error'>com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception thrown by the GetCustomerByName method.

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.java:197)

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEAN_Stub.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEAN_Stub.java:132)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)

at $Proxy109.GetCustomerByName(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:124)

at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:145)

at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:67)

at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)

at SoapServlet.doPost(SoapServlet.java:51)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:377)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:257)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:322)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:300)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:699)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:224)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:140)

Caused by: java.lang.NoClassDefFoundError

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEANBean.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEANBean.java:74)

at com.Mw.BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.GetCustomerByName(BAPI_RFC_CUSTOMER_GET_BEANObjectImpl0.java:181)

... 32 more

; nested exception is:

java.lang.NoClassDefFoundError

==================================================