cancel
Showing results for 
Search instead for 
Did you mean: 

JCo and NetWeaver Application Server

Former Member
0 Kudos

Hi JCo expert,

I am trying to deploy a Web app which includes JCo3.0 library to Netweaver 7.1. In my web app, I want to register my own DestinationProvider. But it will result in:


java.lang.IllegalStateException: DestinationDataProvider already registered [com.sap.security.core.server.destinations.provider.DestinationsProviderFrame]
               at com.sap.conn.jco.rt.RuntimeEnvironment.setDestinationDataProvider(RuntimeEnvironment.java:132)
               at com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(Environment.java:216)

I understand that Netweaver must ship its own JCo as well. But I just want my web app to use the JCo in the WEB-INF lib. How can I resolve this ClassLoading issue?

I've tried that deploy multi webapps with their own JCo on Tomcat, everything runs fine. I am wondering if I can do it on Netweaver as well.

Thanks,

Jian

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

The issue was discussed in the forum before. You can follow [this link|; for a more detailed explanation.

Former Member
0 Kudos

Hello Jian,

did you solve this issue? If yes, can you please respond to this thread how you solved it?

Thanks and best regards,

Sigi

Former Member
0 Kudos

The solution is very simple, just have to check if the data provider already exist.

Here we go!

private MyDestinationDataProvider myProvider = null;

public Connection(SapSystem system) {

myProvider = new MyDestinationDataProvider(system);

if(!com.sap.conn.jco.ext.Environment.isDestinationDataProviderRegistered())

com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(myProvider);

try {

dest = JCoDestinationManager.getDestination(SAP_SERVER);

repos = dest.getRepository();

} catch (JCoException e) {

throw new RuntimeException(e);

}

}

Gustavo Estrada.

Technical Consultant

TanesT Soft

Former Member
0 Kudos

Here is the update:

Basically, I've got application running by using the NetWeaver AS Java embedded JCo service. I've given up running my own one. Here are some pros and cons

Pros:

1. NetWeaver AS Java 7.1 or above supports both JCo2 and JCo3. (I just need JCo3)

2. NetWeaver out of box supports RFC destination configuration, RFC provider configuration and JCo monitoring service in its web based administrator console. (I really like them.)

Cons:

1. The JCo3 embedded by NetWeaver AS Java probably not the latest one and can't upgrade it.

2. NetWeaver AS Java register it own SessionReferenceProvider which means you can't use your own. And more important is that there is no document about it. What session it bind underlying RFC session to. (Actually, I am still fighting on it. If anyone knows anything about this, please respond me on another [thread|;, I'd appreciate you).

Former Member
0 Kudos

Hello

Yes you are right, NetWeaver is a parent-first classloader Application Server. That is, the libraries you package within your application will be loaded at the end, giving you the error you mention.

So to solve this problem, you will have to make NetWeaver to load your library first and then your application. You will have to follow this guide [over here.|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60642a88-95fe-2b10-d387-a245d48fc257?quicklink=index&overridelayout=true]

Please let me know if this helps

Kind regards

Alejandro

Former Member
0 Kudos

Hi Alejandro,

Thanks for your guide, but I still unable to run JCo 3.x on NetWeaver 7.2. I've even tried deploy JCo as a library, but still no luck. NetWeaver 7.2 seems like bundle a JCo 3.x interface library(\J00\j2ee\cluster\bin\ext\tc~com.sap.conn.jco\lib\private) which just like a place holder, every time I load a class under the com.sap.conn.jco.rt. package, I load it from there. Except for one class - com.sap.conn.jco.About which is only contained by latest JCo 3.0.5 and above will loaded from my manually deploy library.

I guess NetWeaver must have some sort of ClassLoading filter mechanism behind the scense.:(

Edited by: jian.liao on Dec 2, 2010 11:41 AM

Former Member
0 Kudos

Hello Jian:

Are you positive you created the hard reference as the manual states? The app server might have some optimizations regarding SAP functionality but all in all, it's still 100% J2EE compliant so it must follow the ground rules.

Can you try to force the classloading by dinamically load the class you need on run time?:



    public MyClassLoader(ClassLoader parent) {
        super(parent);
    }

    public Class loadClass(String name) throws ClassNotFoundException {
        if(!"reflection.MyObject".equals(name))
                return super.loadClass(name);

        try {
            String url = "file:C:/data/projects/tutorials/web/WEB-INF/" +
                            "classes/reflection/MyObject.class";
            URL myUrl = new URL(url);
            URLConnection connection = myUrl.openConnection();
            InputStream input = connection.getInputStream();
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            int data = input.read();

            while(data != -1){
                buffer.write(data);
                data = input.read();
            }

            input.close();

            byte[] classData = buffer.toByteArray();

            return defineClass("reflection.MyObject",
                    classData, 0, classData.length);

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace(); 
        }

        return null;
    }

}