Hi all,
I am trying to integrate EJB3 and Spring. I am using Jboss 5. The following is my ejb bean class
And following is my servletCode: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"; } }
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 .Code: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(); } } }
But while deploying i am getting following exceptionCode:<?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>
If i didn't use the Spring to get the EJB object(using InitialContext) it is working fine.Code: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.


Reply With Quote
