Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Re: @Autowired doesn't work when trying to wire a service
Re: @Autowired doesn't work when trying to wire a service [message #607713] Thu, 19 August 2010 21:15 Go to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Try this for web bundle:


Import-Bundle: com.springsource.org.apache.taglibs.standard;version="[1.1.2,1.3) ",
com.springsource.javax.servlet.jsp.jstl;version="[1.1.2, 1.1.3)",
com.springsource.org.apache.commons.lang;version="[2.4.0,3.0.0) ",
com.springsource.org.apache.velocity;version="[1.6.2,2.0.0) ",

Import-Package:
org.eclipse.virgo.web.dm;version="[2.0.0.RELEASE,3.0.0.RELEASE) "

Import-Library: org.springframework.spring;version="${spring.version.range} "


Do you really have to use log4j? Virgo comes with slf4 + logback already. Much nicer combo by the way.

Instead of importing individual spring bundle start out with import library. Minimized from there. At least add

org.springframework.aop;version="${spring.version.range}",
com.springsource.org.aopalliance;version="1.0.0",
org.springframework.beans;version="${spring.version.range}",
org.springframework.core;version="${spring.version.range}",
org.springframework.context;version="${spring.version.range} ",

as a minimum set and plus all of the web bundles (i.e. web and web.servlet.

I think the reason that you are missing aop imports could be causing issues with Autowire. You might want to check virgo logs to see if there is some info in there

Also, you shouldn't need to import
org.springframework.osgi.core;version="[1.2.1,2.0.0)"
unless you are using classes from there in your code.

Regards,
Dmitry
Re: @Autowired doesn't work when trying to wire a service [message #607723 is a reply to message #607713] Thu, 19 August 2010 22:15 Go to previous messageGo to next message
Kostas Kougios is currently offline Kostas KougiosFriend
Messages: 42
Registered: August 2010
Member
Hi,yes that was it.

Either by importing springframework.beans or the whole lib, @Autowire works! Strange though that it didn't log an error when it wasn't working.

I am now using the library and configured maven & manifest to use springframework 3.0.4 library. There is a drawback though, I've to download the .libd file myself and place it under virgo/repository/usr folder. Do you know if it is possible for maven to do that? I've configured virgo to use my maven repository:

ext.type=external
ext.searchPattern=repository/ext/{artifact}

usr.type=watched
usr.watchDirectory=repository/usr


mavenrepo.type=external
mavenrepo.searchPattern=${user.home}/.m2/repository/**/{bund le}.jar

chain=ext,usr,mavenrepo


Also for anyone that might be reading: I had to clean the virgo/work directory after upgrading spring version (otherwise I was getting errors). And maven sometimes doesn't copy all resources under the MANIFEST folder. Strange...
Re: @Autowired doesn't work when trying to wire a service [message #607725 is a reply to message #607723] Fri, 20 August 2010 13:24 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
In maven you have to add <type>libd</type> to pull down library. Maven by default goes after "jar" type.

You will also want to add this to the plan if you point it to the maven repo:


mavenrepo.type=external
mavenrepo.searchPattern=${user.home}/.m2/repository/**/{bund le}.jar

mavenrepolibd.type=external
mavenrepolibd.searchPattern=${user.home}/.m2/repository/**/{ bundle}.libd

chain=ext,usr,mavenrepo,mavenrepolibd



Word of caution - the larger your app becomes the longer indexing will take and start up might become unacceptable when pointing to maven repo.
Re: @Autowired doesn't work when trying to wire a service [message #607729 is a reply to message #607725] Fri, 20 August 2010 21:47 Go to previous messageGo to next message
Kostas Kougios is currently offline Kostas KougiosFriend
Messages: 42
Registered: August 2010
Member
Hi, yes, type=libd but maven doesn't download the libd file. I use a parent pom with child pom configured for each bundle. My parent pom is this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rits</groupId>
<artifactId>com.rits.virgo</artifactId>
<version>1.0.0</version>
<name>Robust IT Server</name>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding >
<spring.version>3.0.4.RELEASE</spring.version>
<spring.osgi.version>1.2.1</spring.osgi.version>
<jsp.taglibs.version>1.1.2</jsp.taglibs.version>
<logging.version>1.5.10</logging.version>
</properties>
<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.spring-library</artifactId >
<type>libd</type>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>com.springsource.org.codehaus.groovy</artifactId >
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>com.springsource.org.apache.velocity</artifactId >
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>org.springframework.osgi.core</artifactId>
<version>${spring.osgi.version}</version>
<scope>compile</scope>
</dependency>
<!-- <dependency> <groupId>org.springframework.osgi</groupId> <artifactId>org.springframework.osgi.extender</artifactId> <version>${spring.osgi.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.osgi</groupId> <artifactId>org.springframework.osgi.mock</artifactId> <version>${spring.osgi.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.eclipse.osgi</groupId> <artifactId>org.eclipse.osgi</artifactId> <version>3.5.100.v20090629</version> <scope>provided</scope> </dependency> -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.io</artifactId >
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>com.springsource.javax.annotation</artifactId>
<version>1.0.0</version>
</dependency>
<!-- <dependency> <groupId>org.springframework.osgi</groupId> <artifactId>org.springframework.osgi.test</artifactId> <scope>test</scope> <version>1.2.1</version> </dependency> -->
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>com.springsource.javax.ejb</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>javax.xml.rpc</groupId>
<artifactId>com.springsource.javax.xml.rpc</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>com.springsource.javax.mail</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>com.springsource.javax.activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>com.springsource.javax.persistence</artifactId >
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>com.springsource.javax.el</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>com.springsource.javax.servlet</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>com.springsource.javax.servlet.jsp</artifactId >
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>com.springsource.javax.servlet.jsp.jstl</artifactId >
<version>${jsp.taglibs.version}</version>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>com.springsource.org.apache.taglibs.standard</artifactId >
<version>${jsp.taglibs.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.lang</artifactId >
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.api</artifactId>
<version>${logging.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.bridge</artifactId>
<version>${logging.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.logging</artifactId >
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.log4j</groupId>
<artifactId>com.springsource.org.apache.log4j</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.log4j</artifactId>
<version>${logging.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm</artifactId >
<version>3.2.0</version>
</dependency>
<!-- ============================================================ ========================= TESTING DEPENDENCIES ============================================================ ========================= -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>org.springframework.osgi.test</artifactId>
<version>${spring.osgi.version}</version>
<scope>test</scope>
</dependency>
<!-- ============================================================ ========================= /TESTING DEPENDENCIES ============================================================ ========================= -->
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>com.springsource.repository.bundles.snapshot</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Snapshot</name>
<url>http://repository.springsource.com/maven/bundles/snapshot</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundle.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>com.springsource.repository.bundle.milestone</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Milestones</name>
<url>http://repository.springsource.com/maven/bundles/milestone</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/release</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.external</id>
<name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/external</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.milestone</id>
<name>SpringSource Enterprise Bundle Repository - Milestone Library Releases</name>
<url> http://repository.springsource.com/maven/libraries/milestone</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.snapshot</id>
<name>SpringSource Enterprise Bundle Repository - Snapshot Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/snapshot</url>
</repository>
</repositories>
</project>




My gui web bundle pom is:


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.rits</groupId>
<artifactId>com.rits.virgo</artifactId>
<version>1.0.0</version>
<relativePath>../com.rits.virgo/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.rits</groupId>
<artifactId>com.rits.gui.web</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>gui</name>
<dependencies>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.spring-library</artifactId >
<type>libd</type>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.aspects</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.lang</artifactId >
</dependency>
<dependency>
<groupId>org.apache.log4j</groupId>
<artifactId>com.springsource.org.apache.log4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>com.springsource.org.apache.velocity</artifactId >
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>com.springsource.javax.servlet</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
</archive>
<packagingExcludes>WEB-INF/lib/**</packagingExcludes>
<!-- <webappDirectory>../com.rits.virgo/virgo-web-server/pickup/com.rits.gui.web </webappDirectory> -->
<warName>${artifactId}</warName>
<outputDirectory>../com.rits.virgo/virgo-web-server/pickup/ </outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>



But maven doesn't download the libd file. Here are the contents of ~/.m2/org/springframework

org.springframework.aop org.springframework.jms
org.springframework.asm org.springframework.orm
org.springframework.aspects org.springframework.oxm
org.springframework.beans org.springframework.spring-library
org.springframework.context org.springframework.transaction
org.springframework.context.support org.springframework.web
org.springframework.core org.springframework.web.portlet
org.springframework.expression org.springframework.web.servlet
org.springframework.jdbc
Re: @Autowired doesn't work when trying to wire a service [message #607730 is a reply to message #607729] Fri, 20 August 2010 23:12 Go to previous message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
org.springframework.beans org.springframework.spring-library
And it is there
Previous Topic:Packaging existing plugins/bundles in PAR
Next Topic:@Autowired doesn't work when trying to wire a service
Goto Forum:
  


Current Time: Thu Apr 25 00:15:50 GMT 2024

Powered by FUDForum. Page generated in 0.03056 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top