[JBoss Seam] - Trouble calling Stateless Bean
by sjmenden
I have a page to show the groups in my system. There are a series of links to allow the user to modify the group. I am having trouble implementing the first of those links where the user clicks to edit the group itself.
| <h:commandLink value="Edit Information" action="#{editGroup.update}">
| <f:param name="groupId" value="#{groupUsers.group.groupId}"/>
| </h:commandLink>
|
| @Name("editGroup")
| @Stateless
| public class EditGroup implements IEditGroup {
|
| @RequestParameter
| private Long groupId;
|
| @Logger
| private Log log;
|
| private EntityManager em;
|
| @In(create=false) @Out
| Group group;
|
| public String update() {
| //Verify groupId is set
| if(groupId == null || groupId.equals("")){return null;}
|
| Map<String, Object> parameters = new HashMap<String, Object>();
|
| log.info("\n\nFinding Group with groupId: " + groupId + "\n\n");
|
| Query query = em.createQuery("from Group group where group.groupId = :groupId");
| parameters.put("groupId", groupId);
|
| for (Entry <String, Object> param : parameters.entrySet()) {
| query.setParameter( param.getKey(), param.getValue() );
| }
| log.info("Querying for group");
| Group attachedGroup = (Group) query.getSingleResult();
| log.info("Found group object: " + group);
|
| if(group == null) {
| group = attachedGroup;
| } else {
| log.info("group was not null, attempting to update the attached group");
| attachedGroup.setName(group.getName());
| attachedGroup.setAddress(group.getAddress());
| attachedGroup.setAddress2(group.getAddress2());
| ...
| ...
| ...
| }
|
| return "editGroup";
| }
| }
|
|
The error when I click on the link is as follows:
| WARNING: Component _id13 just got an automatic id, because there was no id assigned yet. If this component was created dynamically (i.e. not by a JSP tag) you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!
| 14:14:09,411 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
| javax.faces.FacesException: Error calling action method of component with id _id1
| 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)
|
I'm probably doing my @Stateless bean completely against convention, but all I want is to load the group on demand and update on demand, I dont' think it needs to be statefull.
I thought I could just create a @Stateless bean and invoke it from anywhere, but I must be missing something, help is needed with that *something*.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3965345#3965345
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3965345
19 years, 10 months
[JBoss Seam] - Injection woes
by texan
How about adding a "@Singleton" annotation to Seam?
Right now, I use this pattern:
@In(create = true)
| @Out(scope = APPLICATION)
| private SomeClass myClass;
Obviously, the target class itself isn't implemented as a singleton in this case, since it needs a public constructor.
My point is, why perform an "outjection" every time when I'll only ever create it once? That is, the "@Out" (and create=true) is only truly needed once. I have no interest in reassigning "myClass" to a new instance and have that one pushed into the context. In fact, I'd like an error if I tried, preferably even a compiler error. [side note, can an annotation cause an instance variable to be redefined as "final?"]
I'm being picky, but it would be nice to be able to do this:
@Singleton
| private SomeClass myClass;
or even
@Singleton (method="getInstance")
| private SomeClass myClass;
or possibly
@Singleton
| private final SomeClass myClass;
(if the annotation itself can't enforce the "final" notion)
I would be quite content to do this myself, if I knew how. I'm assuming that, in addition to creating the annotation interface, I'd need to create an interceptor that is always called when my session beans are instantiated, and that interceptor would need to scan the member variables for this annotation and do the work of checking for an existing instance in the app context, etc.
Presumably it would use the fully qualified class name as the context key rather than the instance variable name.
Sadly, I haven't delved into interceptor creation just yet... Besides, this seems (in my selfish opinion) to be a Seam-worthy annotation.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3965343#3965343
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3965343
19 years, 10 months
[Tomcat, HTTPD, Servlets & JSP] - JBoss/Thread [WebappClassLoader] Illegal access issue, PLEAS
by ihunter@chaffee.com
Ok, I'm so fried on this issue. First off, I get little to no debugging info from JBoss on this, so I can't track it to a single line.
Quick info:
Release ID: JBoss [Zion] 4.0.1sp1 (build: CVSTag=JBoss_4_0_1_SP1 date=200502160314)
Apache Tomcat/5.0.28
First off, here's the JBoss error I get:
2006-08-15 13:50:08,971 INFO [WebappClassLoader] Illegal access: this web application instance has been stopped already (the eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact)
Filter trigger matched. Restarting JVM.
2006-08-15 13:50:09,818 INFO [Server] JBoss SHUTDOWN: Undeploying all packages
2006-08-15 13:50:09,819 INFO [TomcatDeployer] undeploy, ctxPath=/, warUrl=file:/web/deploy/tomato.war/
...
<yada yada yada, normal JBoss resource undeploy restart stuff>
It seems David has already put in a filter for this with JSW, so it does the restart. (BTW: Is this something you see on your production machines as well?)
Consider the situation where we have ONE Servlet for the deployed webapp. This servlet spawns an instance of PagePropertiesEngine which in turn will spawn the PagePropertiesEngineUpdater thread.
PagePropertiesEngine.init() is called during Servlet.init() and PagePropertiesEngine.destroy() is called during Servlet.destroy().
The problem arises when the webapp is undeployed and redeployed. Both System.out.println() are reached:
2006-08-15 13:49:48,736 INFO [TomcatDeployer] undeploy, ctxPath=/, warUrl=file:/web/deploy/tomato.war/
2006-08-15 13:49:48,760 INFO [STDOUT] PageEngine.destroy()
2006-08-15 13:49:57,968 INFO [STDOUT] FINISHED PagePropertiesEngineUpdater.run()
2006-08-15 13:49:57,969 INFO [STDOUT] FINISHED PagePropertiesEngine.destroy()
2006-08-15 13:49:59,464 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=file:/web/deploy/tomato.war/
Wait about 10 seconds, then I get the error up above. I can't seem to fathom what's happening because it seems like the Thread is kaput.
Here is the code for the two classes, they really couldn't be simpler:
public class PagePropertiesEngineUpdater extends Thread
{
private long updateSeconds = 10;
boolean stop = false;
public PagePropertiesEngineUpdater()
{
super();
}
public void run()
{
super.run();
while (!stop)
{
if (stop) return;
try
{
sleep(updateSeconds * 1000);
}
catch (InterruptedException ie)
{
}
}
System.out.println("FINISHED PagePropertiesEngineUpdater.run()");
}
}
public class PagePropertiesEngine
{
private PagePropertiesEngineUpdater updater = new PagePropertiesEngineUpdater();
public PagePropertiesEngine()
{
super();
}
public void init()
{
updater.start();
}
public void destroy()
{
updater.stop = true;
try
{
updater.join();
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
System.out.println("FINISHED PagePropertiesEngine.destroy()");
}
}
Any wisdom or ideas are appreciated. I'm totally shot.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3965341#3965341
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3965341
19 years, 10 months