[JBoss Seam] - Re: Seam Security Question - Tomcat Valve
by bsmithjj
The problem is that the Seam security model is tightly coupled to a JAAS model of security - i.e. the Subject class and friends. With CAS and our custom Tomcat Valve, the servlet container associates/manages a copy of the authenticated Principal (a.k.a. userPrincipal in Seam) with the HttpServletRequest and in the Valve, it's possible for us to make isUserInRole() work as expected as well. It would be ideal for us if Seam allowed us to provide or override the Principal and roles for a user (and even permissions too but we're not using permissions directly) to the Identity component.
I would be reluctant to use the approach you show in the previous post because that's sure to be outdated or broken with any future release of Spring - especially since there are JIRA task(s) for the Identity component now.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033813#4033813
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033813
18 years, 7 months
[JBoss Seam] - Problem:
by ASavitsky
The environment is Tomcat 5.5.20 + Hibernate EM 3.3 + Seam 1.2.0 + Microcontainer. I'm trying to build a simple clickable list with editing, everything works fine (querying, updating), except when adding a new record:
UserBean.java
@Name ("userBean")
| @Scope (ScopeType.CONVERSATION)
| public class UserBean extends EntityController implements Serializable {
| @DataModelSelection
| @Out (required = false)
| private User selectedUser;
| @DataModel
| private List<User> users;
|
| public void addUser() {
| selectedUser = new User();
| }
| public void cancelEdit() {
| selectedUser = null;
| }
| @Factory ("users")
| @Begin (flushMode = FlushModeType.MANUAL)
| public void createRecords() {
| users = createQuery("SELECT u FROM User u").getResultList();
| }
| @Transactional (TransactionPropagationType.REQUIRED)
| public void saveUser() {
| persist(selectedUser);
| flush();
| addFacesMessage("User #{selectedUser.username} succesfully saved");
| createRecords();
| }
| public void selectUser() {
| }
| }
|
users.xhtml (I'm using Facelets):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
| xmlns:s="http://jboss.com/products/seam/taglib">
| <head>
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
| <title>Manage Users</title>
| </head>
| <body>
| <h:form>
| <h:dataTable id="table" var="user" value="#{users}">
| <f:facet name="footer">
| <h:commandButton action="#{userBean.addUser}" value="Add New" />
| </f:facet>
| <h:column>
| <f:facet name="header">
| <h:outputText value="ID" />
| </f:facet>
| <h:commandLink value="#{user.id}" action="#{userBean.selectUser}" />
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Username" />
| </f:facet>
| <h:outputText value="#{user.username}" />
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Role" />
| </f:facet>
| <h:outputText value="#{user.role}" />
| </h:column>
| </h:dataTable>
| <h:panelGrid columns="2" rendered="#{not empty selectedUser}">
| <f:facet name="header">
| <h:messages />
| </f:facet>
| <f:facet name="footer">
| <h:panelGroup>
| <h:commandButton action="#{userBean.saveUser}" value="Save" />
| <h:commandButton action="#{userBean.cancelEdit}" immediate="true"
| value="Cancel" />
| </h:panelGroup>
| </f:facet>
| <h:outputLabel value="Username" for="username" />
| <h:inputText id="username" value="#{selectedUser.username}" required="true">
| <f:validateLength maximum="20" />
| </h:inputText>
| <h:outputLabel value="Password" for="password" rendered="#{selectedUser.new}" />
| <h:inputText id="password" value="#{selectedUser.password}" required="true"
| rendered="#{selectedUser.new}">
| <f:validateLength minimum="6" maximum="20" />
| </h:inputText>
| <h:outputLabel value="Role" for="role" />
| <h:selectOneMenu id="role" value="#{selectedUser.role}" required="true">
| <s:convertEnum />
| <s:enumItem enumValue="ROLE_USER" label="User" />
| <s:enumItem enumValue="ROLE_MGR" label="Manager" />
| <s:enumItem enumValue="ROLE_ADMIN" label="Administrator" />
| </h:selectOneMenu>
| </h:panelGrid>
| </h:form>
| </body>
| </html>
|
User.java:
@Entity
| @Table (name = "USERS")
| @SequenceGenerator (name = "SEQ_GEN", sequenceName = "SEQ_USER")
| public class User implements Serializable {
| public static enum Role {
| ROLE_ADMIN, ROLE_MGR, ROLE_USER
| }
|
| @Column (name = "CREATED_BY", nullable = false, updatable = false)
| private String createdBy = "ADMIN";
| @Temporal (TemporalType.TIMESTAMP)
| @Column (name = "CREATED_ON", nullable = false, updatable = false)
| private Date createdOn = new Date();
| @Id
| @GeneratedValue (strategy = GenerationType.AUTO, generator = "SEQ_GEN")
| private Long id;
| @Column (name = "MODIFIED_BY", nullable = false)
| private String modifiedBy = "ADMIN";
| @Temporal (TemporalType.TIMESTAMP)
| @Version
| @Column (name = "MODIFIED_ON", nullable = false)
| private Date modifiedOn = new Date();
| private String password;
| @Enumerated (EnumType.STRING)
| private Role role;
| private String username;
|
| public String getCreatedBy() {
| return createdBy;
| }
| public Date getCreatedOn() {
| return createdOn;
| }
| public Long getId() {
| return id;
| }
| public String getModifiedBy() {
| return modifiedBy;
| }
| public Date getModifiedOn() {
| return modifiedOn;
| }
| public String getPassword() {
| return password;
| }
| public Role getRole() {
| return role;
| }
| public String getUsername() {
| return username;
| }
| public boolean isNew() {
| return id == null;
| }
| public void setCreatedBy(String createdBy) {
| this.createdBy = createdBy;
| }
| public void setCreatedOn(Date createdOn) {
| this.createdOn = createdOn;
| }
| public void setId(Long id) {
| this.id = id;
| }
| public void setModifiedBy(String modifiedBy) {
| this.modifiedBy = modifiedBy;
| }
| public void setModifiedOn(Date modifiedOn) {
| this.modifiedOn = modifiedOn;
| }
| public void setPassword(String password) {
| this.password = password;
| }
| public void setRole(Role role) {
| this.role = role;
| }
| public void setUsername(String username) {
| this.username = username;
| }
| }
|
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="visitsDatabase" transaction-type="JTA">
| <jta-data-source>java:comp/env/DataSource</jta-data-source>
| <properties>
| <property name="hibernate.show_sql" value="true" />
| <property name="hibernate.jdbc.batch_size" value="0" />
| <property name="hibernate.transaction.manager_lookup_class"
| value="org.hibernate.transaction.JBossTransactionManagerLookup" />
| </properties>
| </persistence-unit>
| </persistence>
|
components.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <components xmlns="http://jboss.com/products/seam/components"
| xmlns:core="http://jboss.com/products/seam/core"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xmlns:security="http://jboss.com/products/seam/security"
| xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.2.xsd
| http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.2.xsd
| http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.2.xsd">
| <core:init debug="true" />
| <core:manager conversation-timeout="120000"
| concurrent-request-timeout="500" />
| <core:entity-manager-factory name="visitsDatabase" />
| <core:managed-persistence-context name="entityManager" auto-create="true"
| entity-manager-factory="#{visitsDatabase}" />
| <core:microcontainer installed="true" />
| <security:identity authenticate-method="#{authenticator.authenticate}" />
| </components>
|
jboss-beans.xml and jndi.properties have been copied from the Seam-JPA examples (Seam 1.2.0 distribution)
And here's the stack trace I'm getting:
ERROR [org.jboss.seam.web.ExceptionFilter] - uncaught exception
| javax.servlet.ServletException: Error calling action method of component with id _id2:_id33
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
| at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
| at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
| at java.lang.Thread.run(Thread.java:595)
| ERROR [org.jboss.seam.web.ExceptionFilter] - exception root cause
| javax.faces.FacesException: Error calling action method of component with id _id2:_id33
| at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
| at javax.faces.component.UICommand.broadcast(UICommand.java:109)
| at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
| at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
| at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
| at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
| at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
| at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
| at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
| at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: javax.faces.el.EvaluationException: /users.xhtml @42,67 action="#{userBean.saveUser}": javax.persistence.TransactionRequiredException: no transaction is in progress
| at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
| at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
| ... 31 more
| Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
| at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:294)
| at org.jboss.seam.persistence.EntityManagerProxy.flush(EntityManagerProxy.java:81)
| at org.jboss.seam.framework.EntityController.flush(EntityController.java:52)
| at test.UserBean.saveUser(UserBean.java:41)
| at test.UserBean$$FastClassByCGLIB$$48b4ac17.invoke(<generated>)
| at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
| at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
| at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:37)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:63)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:32)
| at org.jboss.seam.util.Work.workInTransaction(Work.java:37)
| at org.jboss.seam.interceptors.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:27)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
| at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:154)
| at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:89)
| at test.UserBean$$EnhancerByCGLIB$$ca960d22.saveUser(<generated>)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at com.sun.el.parser.AstValue.invoke(AstValue.java:130)
| at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
| at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
| at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
| ... 32 more
Has anyone been encountering similar problems before? Am I using the beans correctly?
Thanks,
Alex
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033811#4033811
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033811
18 years, 7 months
[JBoss Portal] - Re: JBoss Portal 2.6 Beta 1 release
by anuprash
In getting the workflow to work I modified the /portal-cms.sar/portal-workflow.sar/META-INF/jboss-service.xml. Specifically, I uncommented the JBPM Process Definition part so that I could extend it to include a more detailed workflow. On restarting the app server, I see the following error lines:
--- MBeans waiting for other MBeans ---
ObjectName: portal:service=ApprovePublish,type=Workflow
State: FAILED
Reason: org.xml.sax.SAXParseException: Premature end of file.
I Depend On:
portal:service=Workflow,type=WorkflowService
portal:service=Module,type=IdentityServiceController
Depends On Me:
portal:service=CMS
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: portal:service=ApprovePublish,type=Workflow
State: FAILED
Reason: org.xml.sax.SAXParseException: Premature end of file.
I Depend On:
portal:service=Workflow,type=WorkflowService
portal:service=Module,type=IdentityServiceController
Depends On Me:
portal:service=CMS
I have tried to look for the Workflow Service at all levels of the installation but cannot locate it. Can someone please let me know if this is something that I am doing wrong or is it a bug.
Thank you
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033809#4033809
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033809
18 years, 7 months
[JBoss Seam] - Re: Contexts.getApplicationContext() loses Components
by Lundegaard
I lied with
anonymous wrote : After increasing the initial capacity of org.jboss.seam.init.Initialization#properties the startup worked with all components in my components.xml.
since this didnt'solve the issue, rather i posted and tested with the wrong META-INF/components.xml
I'll try to figure out some solution.
Here's the non-working file (Last two components added)
| <?xml version="1.0" encoding="UTF-8"?>
| <components xmlns="http://jboss.com/products/seam/components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="
| http://jboss.com/products/seam/components
| http://jboss.com/products/seam/components-1.2.xsd">
|
| <!-- Action -->
| <component name="authenticator" class="com.example.action.Authenticator" scope="conversation" auto-create="true" />
| <component name="mailAction" class="com.example.action.MailAction" scope="conversation" auto-create="true" />
| <component name="userAction" class="com.example.action.UserAction" scope="conversation" auto-create="true" />
| <component name="userBranchAction" class="com.example.action.UserBranchAction" scope="conversation" auto-create="true" />
| <component name="userQuestionnaireAction" class="com.example.questionnaire.action.UserQuestionnaireAction" scope="conversation" auto-create="true" />
| <component name="exportAction" class="com.example.action.ExportAction" scope="conversation" auto-create="true" />
|
| <!-- Util -->
| <component name="configuration" class="com.example.util.Configuration" scope="application" auto-create="true">
| <property name="path">${configuration.path}</property>
| <property name="url">${configuration.url}</property>
| </component>
|
| <!-- Entity -->
| <component name="user" class="com.example.entity.User" scope="conversation" auto-create="true" />
|
| <!-- DAO -->
| <component name="userDao" class="com.example.dao.UserDao" scope="stateless" auto-create="true" />
| <component name="userBranchDao" class="com.example.dao.UserBranchDao" scope="stateless" auto-create="true" />
| <component name="roleDao" class="com.example.dao.RoleDao" scope="stateless" auto-create="true" />
| <component name="questionnaireDao" class="com.example.questionnaire.dao.QuestionnaireDao" scope="stateless" auto-create="true" />
| <component name="questionDao" class="com.example.questionnaire.dao.QuestionDao" scope="stateless" auto-create="true" />
| <component name="answerDao" class="com.example.questionnaire.dao.AnswerDao" scope="stateless" auto-create="true" />
| <component name="userQuestionnaireDao" class="com.example.questionnaire.dao.UserQuestionnaireDao" scope="stateless" auto-create="true" />
| <component name="userQuestionDao" class="com.example.questionnaire.dao.UserQuestionDao" scope="stateless" auto-create="true" />
| <component name="userAnswerDao" class="com.example.questionnaire.dao.UserAnswerDao" scope="stateless" auto-create="true" />
|
| <!-- Framework -->
| <component name="questionnaireHome" class="com.example.questionnaire.home.QuestionnaireHome" scope="conversation">
| <property name="entityClass">com.example.questionnaire.entity.Questionnaire</property>
| </component>
| <component name="questionHome" class="com.example.questionnaire.home.QuestionHome" scope="conversation">
| <property name="entityClass">com.example.questionnaire.entity.Question</property>
| </component>
| <component name="answerHome" class="com.example.questionnaire.home.AnswerHome" scope="conversation">
| <property name="entityClass">com.example.questionnaire.entity.Answer</property>
| </component>
| <component name="recommendationHome" class="com.example.home.RecommendationHome" scope="conversation">
| <property name="entityClass">com.example.entity.Recommendation</property>
| </component>
| <component name="contactHome" class="com.example.home.ContactHome" scope="conversation">
| <property name="entityClass">com.example.entity.Contact</property>
| </component>
|
| </components>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033804#4033804
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033804
18 years, 7 months
[Persistence, JBoss/CMP, Hibernate, Database] - Unable to update record
by suneetshah2000
hello,
I have a persistent object that I generated using the Hibernate tools eclipse. I am able to insert a record, but I am not able to update a record. When I call that method, it always seems to issue in insert.
Any ideas would be greatly appreciated.
DAO Code ---
@Transactional( propagation = Propagation.REQUIRED, readOnly = false )
| public void persist(Service transientInstance) {
| log.debug("persisting Service instance");
| try {
| entityManager.persist(transientInstance);
| log.debug("persist successful");
| } catch (RuntimeException re) {
| re.printStackTrace();
| log.error("persist failed", re);
| throw re;
| }
| }
|
Object ----
| @Entity
| @Table(name = "service", uniqueConstraints = {})
| public class Service implements java.io.Serializable {
|
| // Fields
|
| private String serviceId;
|
| private String serviceName;
|
| private String status;
|
| private String locationIpAddress;
|
| private String companyOwnerId;
|
| private Date startDate;
|
| private Date endDate;
|
| private String licenseKey;
|
| private String serviceType;
|
| private String parentServiceId;
|
| private String rootResourceId;
|
| private String accessControlModel;
|
| private String param1;
|
| private String param2;
|
| private String param3;
|
| private String param4;
|
| private String param5;
|
| private Set<RequestApprover> requestApprovers = new HashSet<RequestApprover>(0);
|
| private Set<ServiceConfig> serviceConfigs = new HashSet<ServiceConfig>(0);
|
| private Set<RequestForm> requestForms = new HashSet<RequestForm>(0);
|
| // Constructors
|
| /** default constructor */
| public Service() {
| }
|
| /** minimal constructor */
| public Service(String serviceId) {
| this.serviceId = serviceId;
| }
|
| /** full constructor */
| public Service(String serviceId, String serviceName, String status,
| String locationIpAddress, String companyOwnerId, Date startDate,
| Date endDate, String licenseKey, String serviceType,
| String parentServiceId, String rootResourceId,
| String accessControlModel, String param1, String param2,
| String param3, String param4, String param5,
| Set<RequestApprover> requestApprovers,
| Set<ServiceConfig> serviceConfigs, Set<RequestForm> requestForms) {
| this.serviceId = serviceId;
| this.serviceName = serviceName;
| this.status = status;
| this.locationIpAddress = locationIpAddress;
| this.companyOwnerId = companyOwnerId;
| this.startDate = startDate;
| this.endDate = endDate;
| this.licenseKey = licenseKey;
| this.serviceType = serviceType;
| this.parentServiceId = parentServiceId;
| this.rootResourceId = rootResourceId;
| this.accessControlModel = accessControlModel;
| this.param1 = param1;
| this.param2 = param2;
| this.param3 = param3;
| this.param4 = param4;
| this.param5 = param5;
| this.requestApprovers = requestApprovers;
| this.serviceConfigs = serviceConfigs;
| this.requestForms = requestForms;
| }
|
| // Property accessors
| @Id
| @Column(name = "SERVICE_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
| public String getServiceId() {
| return this.serviceId;
| }
|
| public void setServiceId(String serviceId) {
| this.serviceId = serviceId;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033799#4033799
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033799
18 years, 7 months