1

I'm trying to use Gigaspaces with Spring! I have two eclipse projects. A spring rest-service that consumes a space of Gigaspaces (the other eclipse project). I have a master eclipse project where I have both projects.

My problem is that I want to deploy my rest-service on my Tomcat v7.0 it crashes and show me:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.payulatam.prototype.services.IClientService com.payulatam.prototype.controllers.ClientController.clientService; nested exception is java.lang.NoClassDefFoundError: Lorg/openspaces/core/GigaSpace;
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Seems that tomcat can't found gigaspace's jars. But I'm including them on my pom.xml:

<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.payulatam.prototype</groupId>
<artifactId>rest-service</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>rest-service</name>
<url>http://maven.apache.org</url>

<parent>
    <groupId>com.payulatam.prototype</groupId>
    <artifactId>PayUBank</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<properties>
    <gsVersion>9.6.2-9900-RELEASE</gsVersion>
    <spring.version>3.2.2.RELEASE</spring.version>
    <jackson.version>1.9.10</jackson.version>
    <jdk.version>1.6</jdk.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.gigaspaces</groupId>
        <artifactId>gs-openspaces</artifactId>
        <version>${gsVersion}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.payulatam.prototype</groupId>
        <artifactId>common</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <!-- Spring 3 dependencies -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <!-- Jackson JSON Mapper -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
</dependencies>

<build>
    <finalName>rest-service</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>false</downloadJavadocs>
                <wtpversion>2.0</wtpversion>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Any idea how to fix it?

Antonio
  • 11,413
  • 6
  • 34
  • 48

2 Answers2

1

You specified that com.gigaspaces will be provided by the server or executor service you are using when you put <scope>provided</scope> in the dependency declartion for com.gigaspaces, which you are missing on the classpath as per the stacktrace said.

The most probable case here is that it is not bieng provided by the server, so try to delete/change the line <scope>provided</scope> to <scope>compile</scope> in your pom for the dependency declaration for the Gigaspaces library; So maven will be the one that provides it.

Help from: Difference between compile and provided scope

Community
  • 1
  • 1
DirkyJerky
  • 1,130
  • 5
  • 10
0

Change this section in your pom.xml

 <dependency>
        <groupId>com.gigaspaces</groupId>
        <artifactId>gs-openspaces</artifactId>
        <version>${gsVersion}</version>
        <scope>provided</scope>
    </dependency>

To

 <dependency>
        <groupId>com.gigaspaces</groupId>
        <artifactId>gs-openspaces</artifactId>
        <version>${gsVersion}</version>
        <scope>compile</scope>
    </dependency>

Just for your own understanding before you make the changes check in your deployed war file if you have the gs-openspaces.xxx.jar file. You will not see it there. Now make the changes rebuild and redeploy and again check this time you should see the jar file.

Maven Dependency Scope explained

Also see the links provided by DirkyJerky in his answer.

vkg
  • 1,839
  • 14
  • 15