Hi Guys
I have a problem with Spring integration developing a TeamCity plugin.
I'm using IntelliJ 12 Ultimate (build 123.139) and developing TeamCity plugin. I'm using Spring librabry that comes packed with TeamCity 7.1.3. (the one in TeamCity\webapps\ROOT\WEB-INF\lib). The librabry spring.jar is set as my dependency (in Project Structure -> Modules -> Dependencies) along with spring-webmvc.jar. When I'm trying to build the project I get this error:
java: C:\Dev\Projects\blahblah\src\main\java\foo\bar\FooBarController.java:13: cannot access org.springframework.beans.factory.Aware
class file for org.springframework.beans.factory.Aware not found
The class org.springframework.beans.factory.Aware appears since Spring 3.x. The spring.jar that is bundled in TeamCity is old Spring 2.5.x and the only thing it has is BeanFactoryAware.
Something is not right and I cannot put a finger on it.
My FooBarController.java looks like this:
package foo.bar;
import jetbrains.buildServer.controllers.BaseController;
import jetbrains.buildServer.web.openapi.WebControllerManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.Charset;
public class FooBarController extends BaseController {
public FooBarController (WebControllerManager webControllerManager) {
logger.info("Registering new controller at URL");
webControllerManager.registerController(SYNC_CONTROLLER, this);
}
@Nullable
protected ModelAndView doHandle(@NotNull HttpServletRequest httpServletRequest, @NotNull HttpServletResponse httpServletResponse) throws Exception {
httpServletResponse.setStatus(HttpServletResponse.SC_OK);
httpServletResponse.setContentType("text/plain");
httpServletResponse.setCharacterEncoding("UTF-8");
httpServletResponse.getOutputStream().write("OK".getBytes(Charset.forName("UTF-8")));
return null;
}
}
Any help would be appriciated.
Greg
Could you zip and put online your project some place? This will be the easiest way to diagnose the cause. Thanks.
Hi Yann
Thanks for your replay.
I've zipped the project and attached to this post.
You will need Gradle 1.x, Java 1.6 and TeamCity (ideally the same that I have TC 7.1.3) on your machine to be able to set it up.
Instructions on setting it up:
repositories {
mavenCentral()
}
C:\Dev\projects\teamcity-crowd-integration>gradle idea
:ideaModule
:ideaProject
:ideaWorkspace
:idea
BUILD SUCCESSFUL
Enjoy your *.ipr file with IntelliJ.
It is possible you'll have to setup project level SDK once opened in IntelliJ.
Let me know if that works and how I can fix the issue.
Cheers, Greg
I followed your steps but got stuck with some issues yet, so here's a couple of questions first:
- servlet-api.jar should not be in compile, but provided scope
- https://getsatisfaction.com/sonatype/topics/invalid_version_in_xmlschema_1_1_pom_xml XmlSchema 1.1 seems completely broken, for Atlassian stuff have to add Maven repo https://maven.atlassian.com/repository/public
- why do you generate "gradle idea" project files? did you try importing the build.gradle and let JetGradle plugin create/sync IDEA project from there?
Maybe other plugin authors shared their experience/setup with Gradle in TeamCity forum: http://devnet.jetbrains.com/community/teamcity ? Just a suggestion.
Hi Yann
It seems that IntelliJ Spring Integration plugin tries to use Spring 3.x despite the fact that dependency is for 2.5.6.
It also makes no difference if I use JetGradle plugin integration. Same issue.
What I was able to do is this:
Once the IDEA project and modules files are generated by Gradle when I start IntelliJ it detects Spring files. There is a way to configure which xml files to take, but it never asks about Spring version or which Spring jars to use.
Let me know your thoughts.
Greg
Spring plugin will use whatever Spring library version is configured in your project, unless you tell it to download and create a new Spring library. Could you please double-check your Libraries in Project Structure and dependencies in your module for such duplicate Spring library?
When you generate with gradle idea, the only spring entries that are there are in *.iml file. Those are pointing to Spring in TeamCity distribution (which is 2.5.x).
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
<root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/spring.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
Once you open the project in IntelliJ the only new entry that appears is:
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration>
<fileset id="fileset1" name="XML Application Context" removed="false">
<file>file://$MODULE_DIR$/src/test/resources/test-build-server-plugin-TeamCityCrowdIntegration.xml</file>
<file>file://$MODULE_DIR$/src/main/resources/build-server-plugin-TeamCityCrowdIntegration.xml</file>
<file>file://$MODULE_DIR$/src/spring-config.xml</file>
</fileset>
</configuration>
</facet>
</component>
Nothing else other than MODULE dependency is configured for Spring.
It looks like $TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/spring.jar is ignored and IntelliJ falls into using whatever Spring version is default.
Greg
Ok, both config files look good indeed. Since I can't get your gradle build running here completely I can only second-guess, but is there a chance that from some other jar another Spring library is referenced or even re-packaged? IDEA will never attempt to use some default or create any such library unless told to do so, so it must be configured in your project somehow.
There is no other Spring references or repackeged classes. Also, there is no more traces of Spring config other than the one I posted in previouspost.
Let me know what Gradle stuff is not working for you?
Greg
This might be the underlying cause:
From the POM it looks like Atlassian Crowd has a dependency to Spring Framework 3.1.2
Hm ...
It could be, however, generated *.iml file doesn't reference this version of Spring anywhere :/
Greg
I'm not familiar with gradle:idea target, but I'd guess it does not include/show transitive dependencies. So I guess this issue is now resolved (at least from a what-caused-this perspective)?
Hi Yann
Thanks for still trying to nail it.
I've attached the 3 files generated by gradle idea target.
There is no transitive dependencies for Spring 3.x. Have a look yourself.
Greg
What I meant was the transitive dependency on Spring 3 comes from the fact that your code references crowd-classes which in turn need Spring 3.x in classpath to compile.The fact the gradle:idea does not resolve/include those dependencies is another issue.
At least that's what I think happens in your project (still can't get it up and running here).
The error I got when trying to import your project (http://youtrack.jetbrains.com/issue/IDEA-100968) is fixed in 12.1. Please try upcoming EAP.
Hi Yann
Thank you ![]()
Greg