[JBoss Seam] - java.lang.NoSuchMethodException
by monkeyden
Can't seem to find the problem here. The search() method is defined in the local interface and the session bean, and it's invoked by the JSP/JSF. As you can see, the email field is annotated as @In+@Out, neither required. I recieve as NoSuchMethodException.
Entity
@Local
| public interface UserSearch {
| public String search();
| }
SFSB
| @Stateful
| @Scope(ScopeType.SESSION)
| @Name("usersearch")
| public class UserSearchAction implements UserSearch, Serializable {
|
| @PersistenceContext
| private EntityManager em;
|
| @In(required=false)
| @Out(required=false)
| private String email;
| ...
| public String search() {
| String queryStr = "from UserView where lower(email) = :email";
| Query query = em.createQuery(queryStr);
|
| query.setParameter("email", email.toLowerCase() + "%");
|
| //The complete list of results
| this.searchResults = query.getResultList();
| return "refresh-page";
| }
| ...
| }
JSP
| <f:view>
| <h:form>
| <h:inputText id="email" value="#{email}" />
| <h:commandButton id="search" type="submit" value="Search" action="#{usersearch.search}" styleClass="formButton" />
| </h:form>
| </f:view>
Stacktrace
javax.faces.FacesException: Error calling action method of component with id _id0:search
| at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
| at javax.faces.component.UICommand.broadcast(UICommand.java:106)
| at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
| at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
| at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
| at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| 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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| 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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| at java.lang.Thread.run()V(Unknown Source)
| Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{usersearch.search}
| at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:165)
| at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
| ... 27 more
| Caused by: java.lang.NoSuchMethodException: search
| at java.lang.Class.findMethod(Ljava.lang.String;[Ljava.lang.Class;I)Ljava.lang.reflect.Method;(Unknown Source)
| at java.lang.Class.getMethod(Ljava.lang.String;[Ljava.lang.Class;I)Ljava.lang.reflect.Method;(Unknown Source)
| at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:118)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976193#3976193
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976193
19 years, 7 months
[JBossWS] - NullPointerException deploying JSR 181 EJB3 endpoint
by mrooney
I'm using JBoss 4.0.4 GA with EJB3-RC9-FD and JBossWS 1.0.3. NPE is thrown by org.jboss.ws.tools.schema.SchemaTypeCreator.java:578 during deployment.
After digging through the code I found Introspector, BeanInfo and PropertyDescriptor were causing the problem while analyzing one of my EJB methods. The method signature is:
| public MyComplexType getMyComplexType();
|
This apparently causes the Introspector to analyze the MyComplexType class which contains a method with the signature:
| public int getCodeCount(int type);
|
The BeanInfo then contains a PropertyDescriptor with the name "codeCount" but the PropertyDescriptor.getPropertyType() method returns null. As per the javadoc, this method may return null if this is an indexed property that does not support non-indexed access. However, the return value is not checked before it is used.
In short, SchemaTypeCreator.java line 578 should be changed from:
| if (fieldType.equals(ParameterWrapping.WrapperType.class))
|
to:
| if (fieldType != null && fieldType.equals(ParameterWrapping.WrapperType.class))
| continue;
|
The following is a complete class that demonstrates the problem using the relevant code taken directly from SchemaTypeCreator.java:
| import java.beans.BeanInfo;
| import java.beans.Introspector;
| import java.beans.PropertyDescriptor;
|
| import javax.ejb.SessionBean;
|
| public class TestIt
| {
| public int getCodeCount(int type)
| {
| return 1;
| }
|
| public static void main(String[] args)
| {
| try {
|
| Class javaType = TestIt.class;
|
| // taken from SchemaTypeCreator.java
|
| BeanInfo beanInfo = Introspector.getBeanInfo(javaType, Object.class);
| PropertyDescriptor[] props = beanInfo.getPropertyDescriptors();
| int len = props != null ? props.length : 0;
|
| for (int i = 0; i < len && SessionBean.class.isAssignableFrom(javaType) == false; i++)
| {
| PropertyDescriptor prop = props;
| String fieldname = prop.getName();
| Class fieldType = prop.getPropertyType();
|
| // End of borrowed code...the next line throws NPE
|
| System.out.println(fieldType.getName());
| }
|
| } catch(Exception ex) {
| ex.printStackTrace();
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976192#3976192
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976192
19 years, 7 months
[EJB 3.0] - Safety of retaining references to EntityManagers obtained vi
by evk
Hi,
I have a question about the safety of an EJB 3.0 design pattern that I've evolved during the development of a project. It seems naive to me now in retrospect, but could someone please comment in more detail about its safety?
I have a stateless EJB that obtains an EntityManager via the following injection:
@PersistenceContext(unitName="pid") private EntityManager manager;
I then have some helper POJOs that perform EJB3.0 QL queries for me, and return me results. I instantiate these pojos in an init() method marked with the @PostConstruct annotation like so:
@PostConstruct
| public void init() {
| muHelper = new MatchUnitHelper(manager);
| jobHelper = new JobHelper(manager);
| // ... etc
| }
Note that since this happens "post-construct", the "manager" variable has been instantiated via injection. I set things up this way so that I could easily run my stateless bean outside the container, by simply constructing it with an EntityManager obtained via the standard J2SE EntityManagerFactory pattern.
However, while reading the Hibernate EntityManager documentation, I noted that they say that:
anonymous wrote :
| If the EntityManager throws an exception (including any SQLException), you should immediately rollback the database transaction, call EntityManager.close() (if createEntityManager() has been called) and discard the EntityManager instance. Certain methods of EntityManager will not leave the persistence context in a consistent state. No exception thrown by an entity manager can be treated as recoverable. Ensure that the EntityManager will be closed by calling close() in a finally block. Note that a container managed entity manager will do that for you. You just have to let the RuntimeException propagate up to the container.
Suppose I let an exception from the EntityManager propagate up to the container. Will JBoss then discard and replace the "manager" instance in my stateless bean, thus making all the references that I had passed to the POJOs invalid (pointing to a "dead" EntityManager?) Or is the "manager" variable a safe proxy of some sort that remains valid?
Any help is appreciated, thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976188#3976188
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976188
19 years, 7 months