[Beginner's Corner] - Re: ManyToMany problem
by swenu
one step closer :D
i got the problem - at least i think i'm close to!
on roleList.xhtml i got:
| <s:decorate id="functionField" template="layout/edit.xhtml">
| <ui:define name="label">Function</ui:define> <h:selectManyCheckbox id="functions" value="#{roleHome.instance.functions}" layout="pageDirection">
| <s:selectItems value="#{functionList.resultList}" var="function" label="#{function.name}" />
| <s:convertEntity />
| </h:selectManyCheckbox>
| </s:decorate>
and when i save i receive the following error:
23:33:05,776 SEVERE [application] java.lang.ClassCastException: ch.emtm.entity.Function cannot be cast to ch.emtm.entity.RoleFunction
i understood the problem, but for the moment i have no idea how to solve.
i think your code posted above with the new rolefunction() will solve - but i couldn't get.
Do you have a hint for me ;)
Thanks in advance
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4263326#4263326
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4263326
15 years, 1 month
[Beginner's Corner] - Re: ManyToMany problem
by swenu
Sorry :)
I just stuck here and have no idea what the problem is.
Hope someone got input for me!
Here my classes:
package ch.emtm.entity;
|
| import java.io.Serializable;
| import java.util.List;
|
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.Id;
| import javax.persistence.JoinColumn;
| import javax.persistence.OneToMany;
| import javax.persistence.OneToOne;
| import javax.persistence.Version;
|
| import org.hibernate.validator.Length;
| import org.hibernate.validator.NotNull;
| import org.jboss.seam.annotations.Name;
|
| @Entity
| @Name("role")
| public class Role implements Serializable
| {
| /**
| *
| */
| private static final long serialVersionUID = 1L;
|
| @Id
| @GeneratedValue
| private Long id;
| @Version
| private Integer version;
| @Length(max=64)
| @NotNull
| private String name;
| @OneToMany(mappedBy="role")
| private List<RoleFunction> functions;
| @NotNull
| @OneToOne
| @JoinColumn(name = "status")
| private RecordStatus recordStatus = new RecordStatus();
|
| /**
| * @return the id
| */
| public Long getId() {
| return id;
| }
| /**
| * @param id the id to set
| */
| public void setId(Long id) {
| this.id = id;
| }
| /**
| * @return the version
| */
| public Integer getVersion() {
| return version;
| }
| /**
| * @param version the version to set
| */
| public void setVersion(Integer version) {
| this.version = version;
| }
| /**
| * @return the name
| */
| public String getName() {
| return name;
| }
| /**
| * @param name the name to set
| */
| public void setName(String name) {
| this.name = name;
| }
| /**
| * @return the functions
| */
| public List<RoleFunction> getFunctions() {
| return functions;
| }
| /**
| * @param functions the functions to set
| */
| public void setFunctions(List<RoleFunction> functions) {
| this.functions = functions;
| }
| /**
| * @return the recordStatus
| */
| public RecordStatus getRecordStatus() {
| return recordStatus;
| }
| /**
| * @param recordStatus the recordStatus to set
| */
| public void setRecordStatus(RecordStatus recordStatus) {
| this.recordStatus = recordStatus;
| }
|
| }
|
package ch.emtm.entity;
|
| import java.io.Serializable;
| import java.util.ArrayList;
| import java.util.List;
|
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.Id;
| import javax.persistence.JoinColumn;
| import javax.persistence.OneToMany;
| import javax.persistence.OneToOne;
| import javax.persistence.Version;
|
| import org.hibernate.validator.Length;
| import org.hibernate.validator.NotNull;
| import org.jboss.seam.annotations.Name;
|
| @Entity
| @Name("function")
| public class Function implements Serializable
| {
| /**
| *
| */
| private static final long serialVersionUID = 1L;
|
| @Id
| @GeneratedValue
| private Long id;
| @Version
| private Integer version;
| @Length(max = 64)
| @NotNull
| private String name;
| @OneToMany(mappedBy="function")
| private List<RoleFunction> roles = new ArrayList<RoleFunction>();
| @NotNull
| @OneToOne
| @JoinColumn(name = "status")
| private RecordStatus recordStatus = new RecordStatus();
|
| public Long getId() {
| return id;
| }
|
| public void setId(Long id) {
| this.id = id;
| }
|
| public Integer getVersion() {
| return version;
| }
|
| @SuppressWarnings("unused")
| private void setVersion(Integer version) {
| this.version = version;
| }
|
| public String getName() {
| return name;
| }
|
| public void setName(String name) {
| this.name = name;
| }
|
| /**
| * @return the roles
| */
| public List<RoleFunction> getRoles() {
| return roles;
| }
|
| /**
| * @param roles the roles to set
| */
| public void setRoles(List<RoleFunction> roles) {
| this.roles = roles;
| }
|
| /**
| * @return the recordStatus
| */
| public RecordStatus getRecordStatus() {
| return recordStatus;
| }
|
| /**
| * @param recordStatus the recordStatus to set
| */
| public void setRecordStatus(RecordStatus recordStatus) {
| this.recordStatus = recordStatus;
| }
|
| }
|
package ch.emtm.entity;
|
| import java.io.Serializable;
|
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.Id;
| import javax.persistence.ManyToOne;
| import javax.persistence.PrimaryKeyJoinColumn;
|
| import org.jboss.seam.annotations.Name;
|
| @Entity
| @Name("rolefunction")
| public class RoleFunction implements Serializable
| {
| /**
| *
| */
| private static final long serialVersionUID = 1L;
|
| @Id
| @GeneratedValue
| private Long id;
| @ManyToOne()
| @PrimaryKeyJoinColumn(name = "function", referencedColumnName = "id")
| private Function function = new Function();
| @ManyToOne()
| @PrimaryKeyJoinColumn(name = "role", referencedColumnName = "id")
| private Role role = new Role();
| // @OneToMany(mappedBy="roleFunction")
| // private List<Qualification> qualifications = new ArrayList<Qualification>();
|
| /**
| * @return the id
| */
| public Long getId() {
| return id;
| }
| /**
| * @param id the id to set
| */
| public void setId(Long id) {
| this.id = id;
| }
| /**
| * @return the roleId
| */
| public Role getRole() {
| return role;
| }
| /**
| * @param roleId the roleId to set
| */
| public void setRole(Role role) {
| this.role = role;
| }
| /**
| * @return the functionId
| */
| public Function getFunction() {
| return function;
| }
| /**
| * @param functionId the functionId to set
| */
| public void setFunction(Function function) {
| this.function = function;
| }
| // /**
| // * @return the qualifications
| // */
| // public List<Qualification> getQualifications() {
| // return qualifications;
| // }
| // /**
| // * @param qualifications the qualifications to set
| // */
| // public void setQualifications(List<Qualification> qualifications) {
| // this.qualifications = qualifications;
| // }
|
| }
|
So i get an error:
| 21:20:01,733 SEVERE [application] java.lang.NullPointerException
| javax.faces.el.EvaluationException: java.lang.NullPointerException
| at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
| at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
| at javax.faces.component.UICommand.broadcast(UICommand.java:387)
| at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
| at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
| at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
| at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
| at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
| at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:510)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
| at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
| at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
| at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
| at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
| at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
| at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
| at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
| at java.lang.Thread.run(Thread.java:619)
| Caused by: java.lang.NullPointerException
| at ch.emtm.session.RoleHome.update(RoleHome.java:62)
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4263321#4263321
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4263321
15 years, 1 month
[JBoss Portal Users] - Writing a log4j email service
by Fuchs
Hello,
i am using the jboss-portal-2.7.2 bundle and i like to know, how i could write an email service, to be informed, if the server throws any ERRORs.
what i know is that i have to edit the jboss-log4j.xml:
<appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
| <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
| <param name="Threshold" value="ERROR"/>
| <param name="To" value="myemail(a)gmail.com"/>
| <param name="From" value="nobody(a)myhost.domain.com"/>
| <param name="Subject" value="JBoss Sever Errors"/>
| <param name="SMTPHost" value="localhost"/>
| <param name="BufferSize" value="10"/>
| <layout class="org.apache.log4j.PatternLayout">
| <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
| </layout>
| </appender>
|
|
| <root>
| <appender-ref ref="CONSOLE"/>
| <appender-ref ref="FILE"/>
| <appender-ref ref="SMTP"/>
| </root>
|
do i have to edit the jboss-service.xml in the jboss-portal.sar also?
have i something missed?
Thanks for helping!
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4263314#4263314
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4263314
15 years, 1 month