Spring 3.0 and EJB3 integration

I am trying to integrate EJB3 and Spring. I am using Jboss 5. The following is my ejb bean class

import com.HelloWorld;
import javax.ejb.Local;
import javax.ejb.Stateless;

@Stateless
@Local(HelloWorld.class)
public class HelloWorldBean implements HelloWorld {
    public String getMessage() {
        return "Hello EJB World";
    }
}

And following is my servlet

package com;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class TestServlet
 */
import java.io.IOException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.HelloWorld;
/**
 * Used to test EJB 
 * @author ganesdi
 *
 */
public class TestServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    static final long serialVersionUID = 1L;
    private HelloWorld helloWorld;


    /**
     * @param helloWorld the helloWorld to set
     */
    public void setHelloWorld(HelloWorld helloWorld) {
        this.helloWorld = helloWorld;
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            //InitialContext ctx = new InitialContext();
            //HelloWorld hello = (HelloWorld) ctx.lookup("testapplication/HelloWorldBean/remote");
            System.out.println(helloWorld.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

In my servlet i am trying to inject the my Local interface object using Spring. For that i am using .The following is my spring config file

<?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:tx="http://www.springframework.org/schema/tx"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd  http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
    <jee:jndi-lookup id="helloWorld" jndi-name="testapplication/HelloWorldBean/remote">
    </jee:jndi-lookup>
    <bean id="myController" class="com.TestServlet">
        <property name="helloWorld" ref="helloWorld" />
    </bean>
</beans>

But while deploying i am getting following exception

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'helloWorld' of bean class [com.TestServlet]: Bean property 'helloWorld' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

What i am doing wrong ? It is because of any Jar file ? Please help me.

Answers


Need Your Help

Implementing WebHooks with ServiceStack

rest servicestack webhooks redismqserver

I'm currently working on a REST service allowing to control and monitor some physical devices.

How to avoid echo and noise in javascript for webrtc

audio video chat webrtc

I am trying to implement a webrtc-based chat room. And I encountered the following problems in laptop. Without connecting to any other peer, just use getUserMedia(), I can get local video stream.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.