How to get TeamCity / Spring to recognize 3rd party libraries called within Agent code

Hello,

Please forgive what could end up being a Spring 101 question - I'm only now picking it up with teamcity plugin development.

Within an agent plugin's code, I'm attempting to call a 3rd party library.  More specifically, I'm instantiating an object for which the source is not available.  With what I've done, I keep getting a NoClassDefFoundError.

With the following spring wiring:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop"        xmlns:context="http://www.springframework.org/schema/context"        xsi:schemaLocation="http://www.springframework.org/schema/beans                            http://www.springframework.org/schema/beans/spring-beans-2.0.xsd                            http://www.springframework.org/schema/lang                            http://www.springframework.org/schema/lang/spring-lang-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"        default-autowire="constructor">   <bean id="conanCommandLineProcessor" />   <bean id="kwcitcpluginAgentListener" />   <bean id="projectBuilder" /> </beans>


The first two beans are a part of the agent code and work as designed.  The AgentListener tries to create an instance of ProjectBuilder without success.
I've tried what's shown in the 3rd bean line with no success.  I've also modified the agent's agent.bat file and added ProjectBuilder's containing jar file to the classpath.  As well, I've looked at 'depends' attributes on the beans and a few other options but I just haven't hit upon the success path.

How can I get my agent plugin to find and the external classes?

Thank you very much in advance,
Nic

1 comment
Comment actions Permalink

Hi Nic,

If you are just creating a usual calss instance af a library, you do not need Sping here. Just create it as uaul, via "new ProjectBuilder(...)", you obviously need to make the class available to the JVM and the most simple way to do that is to put the library jar near the jar holding your plugin's classes. In the final packaged agent plugin, that is under "lib" of the agent part. You can go explore existing plugins packaging for examples.

0

Please sign in to leave a comment.