Gen
Gen

Reputation: 2540

How to send a spring bean from EJB project to Spring MVC project

In my project there are two independent modules those are EJB with dao layer and Spring mvc with controller. Beans are there in the commons project, the commons project jar is there in the EJB and MVC projects. There is a bean called user.java, for this user bean i am setting some values in the ejb and i connot able to get in the spring mvc controller.

It is show an Exception

Caused by: java.lang.ClassCastException: com.ex.beans.User cannot be cast to com.ex.beans.User

How can i solve this problem.

appService.java:- in EJB

User user=appDAO.getUser(username);
return user;

In MVC

User user=appService.getUser(username);

Upvotes: 1

Views: 240

Answers (1)

Gen
Gen

Reputation: 2540

The mistake i did is i given ejb project dependency in spring mvc pom.xml. In the dependency i given <scope>provided</scoper>. and i changed that into <scope>compile</scoper>, or we can remove that scope from dependency.

Upvotes: 3

Related Questions