cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1032
Views
1
Helpful
3
Replies

Importing external jar into NSO project

smansor
Cisco Employee
Cisco Employee

Hi all,

I'm trying to import 3 external jars, in this case they're:

  • javax.servlet-3.0.jar
  • org.springframework.core-3.0.4.release.jar
  • spring-security-web-3.1.4.release.jar

I've confirmed that these jars are working properly, I created independent Java project in Eclipse, added them in the build path library, and tried the class/methods that I need.

So now I want to incorporate these jars into my NSO project. Below are the steps that I've performed:

  1. Created a folder called "lib" under /src/java
  2. I edited build.xml, added these properties:

                <property name="external_libs.dir" value="lib"/>

 

                <path id="external-libs">

                    <fileset dir="${external_libs.dir}">

                     <include name="*.jar"/>

                    </fileset>

               </path>

                   ...

                   ...

               <target name="compile">

                   ...

                   ...

                  <classpath refid="external-libs"/>

               </target>

Then I did "make clean all" and reload packages. It works fine up until the java codes actually invoked (during commit dry-run) with error:

com.tailf.dp.DpCallbackException: org/springframework/security/web/util/IpAddressMatcher

at com.tailf.dp.annotations.ProxyUtils.invocationTargetCheck(ProxyUtils.java:78)

at com.tailf.dp.annotations.ServiceCallbackProxy.create(ServiceCallbackProxy.java:135)

at com.tailf.dp.DpTrans.protoCallback(DpTrans.java:1688)

at com.tailf.dp.DpTrans.read(DpTrans.java:645)

at com.tailf.dp.DpTrans.run(DpTrans.java:374)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

at com.tailf.dp.DpThread.run(DpThread.java:41)

Caused by: java.lang.NoClassDefFoundError: org/springframework/security/web/util/IpAddressMatcher

..

..


So wondering if I missed anything else? How do I make NSO to include my external jars into its build path and see them?


Thanks in advance.

3 Replies 3

alam.bilal
Cisco Employee
Cisco Employee

Hi there,

Have you tried putting them in the private-jar/shared-jar directory?

That is what I had done a while back and seemed to have worked.

Thanks Bilal,

You're right, it worked when I put the jars in shared-jar directory. But they get deleted when I do "make clean all".

Is that the only way you reckon? I cannot have a dedicated folder for my external jars in my package? How would it work when I put my package into NSO server (system install) - do I need to make sure my external jars files being copied over as well? And make sure nobody executes "make clean all" on my package or NSO will delete my external jars..

I'm haven't played around with ANT much. Perhaps you can play around with the following:

  <target name="clean">

    <delete dir="${build.dir}"/>

    <delete file="${sharedjar.dir}/${package}-ns.jar"/>

    <delete file="${privatejar.dir}/${package}.jar"/>

  </target>

If the jars are placed in shared-jar then they shouldn't get deleted. Only the namespace jar is deleted by default. However, I suspect the intention is to not share these jars with other packages.

Other option would be to quality the packages that get deleted from private-jar a little instead of a complete wipe-out.