on 01-04-2013 2:04 PM
Hi everybody,
I'm testing some stuff with jersey to generate JSON output. Everything seems to be fine.
Now I want to access an operation of an existing CAF application (NW 7.3) from my jersey java servlet and generate JSON... Is this possible? If yes, is there any tutorial how to access caf from my java servlet to generate JSON using jersey?
Thanks ahead
Yes, this is possible. Did this for my blog: http://scn.sap.com/community/netweaver-gateway/blog/2012/06/27/performance-of-sap-gateway
Just take the EJB, encapsulate it into a Java object with Jersey annotations.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Theoretically yes, somewhere on my HD the files are still saved. Wanted to bring them to github for easy sharing, but I wanted to first make the project run on 7.3.
The actual code is really simple. As states, just create a CAF project and take the EJB created there (JNDI lookup) and expose it via Jersey in a separate Java EAR project.
Would be great if you can share the code (files) or some snippets...
I've created a very simple CAF application service and a simple stand-alone application.
Application:
public class MyMain {
public static void main(String[] args) throws NamingException {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "sapsrv.comp.loc:50004");
props.put(Context.SECURITY_PRINCIPAL, "admin");
props.put(Context.SECURITY_CREDENTIALS, "adminpass");
props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services");
InitialContext ctx = new InitialContext(props);
Object obj = ctx.lookup("ejb:/appName=test.comp.de/remote~ear, jarName=test.comp.de~remote~ejbmodule.jar, beanName=de.comp.test.remote.modeled.appsrv.remoteservice.remoteService, interfaceName=de.comp.test.remote.modeled.appsrv.remoteservice.remoteServiceServiceRemote");
TestEJBLocal test = (TestEJBLocal)obj;
System.out.println(obj);
}
}
Starting this I get the following error message:
Exception in thread "main" javax.naming.NamingException: Error occurs while the EJB Scheme Context Factory trying to resolve an EJB with scheme ejb:/appName=test.comp.de/remote~ear, jarName=test.comp.de~remote~ejbmodule.jar, beanName=de.comp.test.remote.modeled.appsrv.remoteservice.remoteService, interfaceName=de.comp.test.remote.modeled.appsrv.remoteservice.remoteServiceServiceRemote. Check server's trace files for more details. javax.naming.NamingException: Error occurs while the EJB Object Factory trying to resolve JNDI reference Reference Class Name: EJB Reference
and
java.lang.IllegalArgumentException: interface de.comp.test.remote.modeled.appsrv.remoteservice.remoteServiceServiceRemote is not visible from class loader
Any ideas?
Thanks ahead
Hi Bernd,
I just posted a blog with full code samples:
Hope this helps,
Christian
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.