Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transaction present on server in Never call

Tags:

java

hibernate

I'm using hibernate 4 version. Trying to persist an entity using the following code:

    if(surveyUserRequestTO!=null){
        surveyUser = new SurveyUser();

        surveyUser.setAdmin(surveyUserRequestTO.getAdmin());
        surveyOrganization = getEntityManager().find(SurveyOrg.class, surveyUserRequestTO.getOrganizationID());
        if(surveyOrganization !=null){
            surveyUser.setSurveyOrg(surveyOrganization);
        }else{
            return null;
        }
        surveyUser.setUserName(surveyUserRequestTO.getUserName());
        surveyUser.setUserSurveyID(surveyUserRequestTO.getSurveyUserID());

        getEntityManager().persist(surveyUser);

And I'm getting following exception:-

JBAS014134: EJB Invocation failed on component NewUserDataProvider for
 method public
 com.alt.survey.user.transport.output.SurveyUserResponseTO
 com.alt.survey.user.dataprovider.NewUserDataProvider.createNewUser(com.alt.survey.user.transport.input.SurveyUserRequestTO)
 throws java.lang.Exception: javax.ejb.EJBException: Transaction
 present on server in Never call (EJB3 13.6.2.6)

What I believe it's something related to TransactionAttribute property. Any possible help will be highly appreciable.

like image 801
codechefvaibhavkashyap Avatar asked Sep 14 '15 10:09

codechefvaibhavkashyap


People also ask

What is the default transaction attribute to a method in an EJB?

- There is no default transaction attribute for an EJB. - The deployer must specify a value for the transaction attribute for the methods that have container managed transactions.

What will happen if a transactional client invokes an enterprise bean method whose transaction attribute is set to never within a transaction context?

Never Attribute If the client is running within a transaction and invokes the enterprise bean's method, the container throws a RemoteException. If the client is not associated with a transaction, the container does not start a new transaction before running the method.


1 Answers

You have NEVER transaction attribute somewhere in your code (see your stacktrace). You can not start transaction inside EJB method with NEVER transaction attribute

like image 134
sibnick Avatar answered Oct 19 '22 02:10

sibnick