BeanNotOfRequiredTypeException with PlatformTransactionManagerAutowired bean is null in MVC ControllerSpring 3 and JUnit 4 (autowiring)Cannot instantiate Spring Bean from managed bean , Spring + JSFSpring Transaction Doesn't RollbackHibernate: ManyToMany inverse DeleteSpring JPA Auditing empty createdByProblems with Spring Java Config and @EnableTransactionManagement“Write operations are not allowed in read-only mode” error : confused with Spring @Service @transaction @Repository and HibernateSpring BeanCreationException : Bean instantiation via factory method failed nested exceptionSpring MVC form validation does't work for nested complex types
Is it possible to take a database offline when doing a backup using an SQL job?
How can I visualize an ordinal variable predicting a continuous outcome?
How to study endgames?
How deep is the liquid in a half-full hemisphere?
Why aren't faces sharp in my f/1.8 portraits even though I'm carefully using center-point autofocus?
Booting Ubuntu from USB drive on MSI motherboard -- EVERYTHING fails
How does Monks' Improved Unarmored Movement work out of combat?
How to identify whether a publisher is genuine or not?
How do we know neutrons have no charge?
Convert a string of digits from words to an integer
Earliest time frog can jump to the other side of a river in C#. Codility's task
How to stop the death waves in my city?
Is there an in-universe explanation of how Frodo's arrival in Valinor was recorded in the Red Book?
Realistically, how much do you need to start investing?
What are one's options when facing religious discrimination at the airport?
Can the President of the US limit First Amendment rights?
How many stack cables would be needed if we want to stack two 3850 switches
Smallest PRIME containing the first 11 primes as sub-strings
Why isn't there armor to protect from spells in the Potterverse?
Why do Russians sometimes spell "жирный" (fatty) as "жырный"?
Worlds with different mathematics and logic
Windows 10 deletes lots of tiny files super slowly. Anything that can be done to speed it up?
GPLv3 forces us to make code available, but to who?
Can you cure a Gorgon's Petrifying Breath before it finishes turning a target to stone?
BeanNotOfRequiredTypeException with PlatformTransactionManager
Autowired bean is null in MVC ControllerSpring 3 and JUnit 4 (autowiring)Cannot instantiate Spring Bean from managed bean , Spring + JSFSpring Transaction Doesn't RollbackHibernate: ManyToMany inverse DeleteSpring JPA Auditing empty createdByProblems with Spring Java Config and @EnableTransactionManagement“Write operations are not allowed in read-only mode” error : confused with Spring @Service @transaction @Repository and HibernateSpring BeanCreationException : Bean instantiation via factory method failed nested exceptionSpring MVC form validation does't work for nested complex types
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm new to Spring and I did a login/register applicaton following a youtube tutorial but I want to add a new functionality that allows to delete a student. I used @Transactional on my delete method and modified accordingly the xml file but I get this error:
Message Request processing failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'platformTransactionManager' is expected to be of type 'org.springframework.transaction.PlatformTransactionManager' but was actually of type 'com.infotech.service.impl.StudentServiceImpl'
my Service class
@Service("studentService")
public class StudentServiceImpl implements StudentService
@Autowired
private StudentDAO studentDAO;
public void setStudentDAO(StudentDAO studentDAO)
this.studentDAO = studentDAO;
public StudentDAO getStudentDAO()
return studentDAO;
//other methods
@Override
public void delete(String email)
getStudentDAO().delete(email);
my DAO class
@EnableTransactionManagement
@Repository("studentDAO")
public class StudentDAOImpl implements StudentDAO
@Autowired
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate)
this.hibernateTemplate = hibernateTemplate;
public HibernateTemplate getHibernateTemplate()
return hibernateTemplate;
@Autowired
private SessionFactory sessionFactory;
protected Session getSession()
return (Session) sessionFactory.getCurrentSession();
//other methods
@Transactional("platformTransactionManager")
public void delete(String email)
Student student = (Student) ((HibernateTemplate) getSession()).get(Student.class, email);
((HibernateTemplate) getSession()).delete(student);
In the dispatcher servlet I have defined InternalResourceViewResolver, dataSource, hibernateTemplate, sessionFactory beans and then I added another bean
<tx:annotation-driven transaction-manager="platformTransactionManager"/>
<bean id= "platformTransactionManager"class="com.infotech.service.impl.StudentServiceImpl">
</bean>
Finally, this is the controller
@Controller
public class MyController
@Autowired
private StudentService studentService;
public void setStudentService(StudentService studentService)
this.studentService = studentService;
public StudentService getStudentService()
return studentService;
//...RequestMappings...
@RequestMapping(value = "/delete/email", method = RequestMethod.GET)
public ModelAndView delete(@PathVariable("email") String email)
studentService.delete(email);
return new ModelAndView("redirect:/view/home");
...
Now, how can I make my bean of PlatformTransactionManager type?
But most of all I think there's a simpler way to delete a field from my table, maybe without using @Transaction at all so can anyone help me understand why I get the error and explain me what is @Transactional and if I really should use it in this case?
Remember that I'm NEW to Spring, I still don't have many notions so sorry if I wrote something totally stupid :-)
spring spring-mvc exception transactions autowired
add a comment
|
I'm new to Spring and I did a login/register applicaton following a youtube tutorial but I want to add a new functionality that allows to delete a student. I used @Transactional on my delete method and modified accordingly the xml file but I get this error:
Message Request processing failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'platformTransactionManager' is expected to be of type 'org.springframework.transaction.PlatformTransactionManager' but was actually of type 'com.infotech.service.impl.StudentServiceImpl'
my Service class
@Service("studentService")
public class StudentServiceImpl implements StudentService
@Autowired
private StudentDAO studentDAO;
public void setStudentDAO(StudentDAO studentDAO)
this.studentDAO = studentDAO;
public StudentDAO getStudentDAO()
return studentDAO;
//other methods
@Override
public void delete(String email)
getStudentDAO().delete(email);
my DAO class
@EnableTransactionManagement
@Repository("studentDAO")
public class StudentDAOImpl implements StudentDAO
@Autowired
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate)
this.hibernateTemplate = hibernateTemplate;
public HibernateTemplate getHibernateTemplate()
return hibernateTemplate;
@Autowired
private SessionFactory sessionFactory;
protected Session getSession()
return (Session) sessionFactory.getCurrentSession();
//other methods
@Transactional("platformTransactionManager")
public void delete(String email)
Student student = (Student) ((HibernateTemplate) getSession()).get(Student.class, email);
((HibernateTemplate) getSession()).delete(student);
In the dispatcher servlet I have defined InternalResourceViewResolver, dataSource, hibernateTemplate, sessionFactory beans and then I added another bean
<tx:annotation-driven transaction-manager="platformTransactionManager"/>
<bean id= "platformTransactionManager"class="com.infotech.service.impl.StudentServiceImpl">
</bean>
Finally, this is the controller
@Controller
public class MyController
@Autowired
private StudentService studentService;
public void setStudentService(StudentService studentService)
this.studentService = studentService;
public StudentService getStudentService()
return studentService;
//...RequestMappings...
@RequestMapping(value = "/delete/email", method = RequestMethod.GET)
public ModelAndView delete(@PathVariable("email") String email)
studentService.delete(email);
return new ModelAndView("redirect:/view/home");
...
Now, how can I make my bean of PlatformTransactionManager type?
But most of all I think there's a simpler way to delete a field from my table, maybe without using @Transaction at all so can anyone help me understand why I get the error and explain me what is @Transactional and if I really should use it in this case?
Remember that I'm NEW to Spring, I still don't have many notions so sorry if I wrote something totally stupid :-)
spring spring-mvc exception transactions autowired
add a comment
|
I'm new to Spring and I did a login/register applicaton following a youtube tutorial but I want to add a new functionality that allows to delete a student. I used @Transactional on my delete method and modified accordingly the xml file but I get this error:
Message Request processing failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'platformTransactionManager' is expected to be of type 'org.springframework.transaction.PlatformTransactionManager' but was actually of type 'com.infotech.service.impl.StudentServiceImpl'
my Service class
@Service("studentService")
public class StudentServiceImpl implements StudentService
@Autowired
private StudentDAO studentDAO;
public void setStudentDAO(StudentDAO studentDAO)
this.studentDAO = studentDAO;
public StudentDAO getStudentDAO()
return studentDAO;
//other methods
@Override
public void delete(String email)
getStudentDAO().delete(email);
my DAO class
@EnableTransactionManagement
@Repository("studentDAO")
public class StudentDAOImpl implements StudentDAO
@Autowired
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate)
this.hibernateTemplate = hibernateTemplate;
public HibernateTemplate getHibernateTemplate()
return hibernateTemplate;
@Autowired
private SessionFactory sessionFactory;
protected Session getSession()
return (Session) sessionFactory.getCurrentSession();
//other methods
@Transactional("platformTransactionManager")
public void delete(String email)
Student student = (Student) ((HibernateTemplate) getSession()).get(Student.class, email);
((HibernateTemplate) getSession()).delete(student);
In the dispatcher servlet I have defined InternalResourceViewResolver, dataSource, hibernateTemplate, sessionFactory beans and then I added another bean
<tx:annotation-driven transaction-manager="platformTransactionManager"/>
<bean id= "platformTransactionManager"class="com.infotech.service.impl.StudentServiceImpl">
</bean>
Finally, this is the controller
@Controller
public class MyController
@Autowired
private StudentService studentService;
public void setStudentService(StudentService studentService)
this.studentService = studentService;
public StudentService getStudentService()
return studentService;
//...RequestMappings...
@RequestMapping(value = "/delete/email", method = RequestMethod.GET)
public ModelAndView delete(@PathVariable("email") String email)
studentService.delete(email);
return new ModelAndView("redirect:/view/home");
...
Now, how can I make my bean of PlatformTransactionManager type?
But most of all I think there's a simpler way to delete a field from my table, maybe without using @Transaction at all so can anyone help me understand why I get the error and explain me what is @Transactional and if I really should use it in this case?
Remember that I'm NEW to Spring, I still don't have many notions so sorry if I wrote something totally stupid :-)
spring spring-mvc exception transactions autowired
I'm new to Spring and I did a login/register applicaton following a youtube tutorial but I want to add a new functionality that allows to delete a student. I used @Transactional on my delete method and modified accordingly the xml file but I get this error:
Message Request processing failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'platformTransactionManager' is expected to be of type 'org.springframework.transaction.PlatformTransactionManager' but was actually of type 'com.infotech.service.impl.StudentServiceImpl'
my Service class
@Service("studentService")
public class StudentServiceImpl implements StudentService
@Autowired
private StudentDAO studentDAO;
public void setStudentDAO(StudentDAO studentDAO)
this.studentDAO = studentDAO;
public StudentDAO getStudentDAO()
return studentDAO;
//other methods
@Override
public void delete(String email)
getStudentDAO().delete(email);
my DAO class
@EnableTransactionManagement
@Repository("studentDAO")
public class StudentDAOImpl implements StudentDAO
@Autowired
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate)
this.hibernateTemplate = hibernateTemplate;
public HibernateTemplate getHibernateTemplate()
return hibernateTemplate;
@Autowired
private SessionFactory sessionFactory;
protected Session getSession()
return (Session) sessionFactory.getCurrentSession();
//other methods
@Transactional("platformTransactionManager")
public void delete(String email)
Student student = (Student) ((HibernateTemplate) getSession()).get(Student.class, email);
((HibernateTemplate) getSession()).delete(student);
In the dispatcher servlet I have defined InternalResourceViewResolver, dataSource, hibernateTemplate, sessionFactory beans and then I added another bean
<tx:annotation-driven transaction-manager="platformTransactionManager"/>
<bean id= "platformTransactionManager"class="com.infotech.service.impl.StudentServiceImpl">
</bean>
Finally, this is the controller
@Controller
public class MyController
@Autowired
private StudentService studentService;
public void setStudentService(StudentService studentService)
this.studentService = studentService;
public StudentService getStudentService()
return studentService;
//...RequestMappings...
@RequestMapping(value = "/delete/email", method = RequestMethod.GET)
public ModelAndView delete(@PathVariable("email") String email)
studentService.delete(email);
return new ModelAndView("redirect:/view/home");
...
Now, how can I make my bean of PlatformTransactionManager type?
But most of all I think there's a simpler way to delete a field from my table, maybe without using @Transaction at all so can anyone help me understand why I get the error and explain me what is @Transactional and if I really should use it in this case?
Remember that I'm NEW to Spring, I still don't have many notions so sorry if I wrote something totally stupid :-)
spring spring-mvc exception transactions autowired
spring spring-mvc exception transactions autowired
asked Mar 28 at 19:42
NanaNana
11 bronze badge
11 bronze badge
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
Spring is looking for transaction manager - it requires a concrete implementation of the PlatformTransactionManager
interface. It's being given your service implementation, which isn't a PlatformTransactionManager
and not what it needs. If you're using JDBC, org.springframework.jdbc.datasource.DataSourceTransactionManager
should work.
Try changing:
<bean id= "platformTransactionManager" class="com.infotech.service.impl.StudentServiceImpl">
To:
<bean id= "platformTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405694%2fbeannotofrequiredtypeexception-with-platformtransactionmanager%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Spring is looking for transaction manager - it requires a concrete implementation of the PlatformTransactionManager
interface. It's being given your service implementation, which isn't a PlatformTransactionManager
and not what it needs. If you're using JDBC, org.springframework.jdbc.datasource.DataSourceTransactionManager
should work.
Try changing:
<bean id= "platformTransactionManager" class="com.infotech.service.impl.StudentServiceImpl">
To:
<bean id= "platformTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
add a comment
|
Spring is looking for transaction manager - it requires a concrete implementation of the PlatformTransactionManager
interface. It's being given your service implementation, which isn't a PlatformTransactionManager
and not what it needs. If you're using JDBC, org.springframework.jdbc.datasource.DataSourceTransactionManager
should work.
Try changing:
<bean id= "platformTransactionManager" class="com.infotech.service.impl.StudentServiceImpl">
To:
<bean id= "platformTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
add a comment
|
Spring is looking for transaction manager - it requires a concrete implementation of the PlatformTransactionManager
interface. It's being given your service implementation, which isn't a PlatformTransactionManager
and not what it needs. If you're using JDBC, org.springframework.jdbc.datasource.DataSourceTransactionManager
should work.
Try changing:
<bean id= "platformTransactionManager" class="com.infotech.service.impl.StudentServiceImpl">
To:
<bean id= "platformTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
Spring is looking for transaction manager - it requires a concrete implementation of the PlatformTransactionManager
interface. It's being given your service implementation, which isn't a PlatformTransactionManager
and not what it needs. If you're using JDBC, org.springframework.jdbc.datasource.DataSourceTransactionManager
should work.
Try changing:
<bean id= "platformTransactionManager" class="com.infotech.service.impl.StudentServiceImpl">
To:
<bean id= "platformTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
answered Mar 28 at 23:10
Robert BainRobert Bain
4,2004 gold badges22 silver badges43 bronze badges
4,2004 gold badges22 silver badges43 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405694%2fbeannotofrequiredtypeexception-with-platformtransactionmanager%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown