[JBoss Seam] - Multiple component instances or how to use a component multi
by patrickr
Hi all,
I really love bijection; it makes things so much easier. However, I have a requirement that makes it somehow hard to use contextual components.
Let's suppose we have a Checkout page, were you can enter shipping and a payment addresses. These addresses obviously belong to a model of the same type. Let us further assume, that entering an address triggers some logic (beyond validation) so we need a controller, say:
@Name("checkoutAddressController")
| public class CheckoutAddressController {
|
| // maybe a persistence manager
| @In SomeService service
|
| // our model
| private Address address;
|
| // [...]
| // some logic, getter / setter etc
|
| }
Now on my checkout page, I want my address forms to have the above controller as a backing bean. So I need two instances of the same component on the same page. From the manual I read that maybe @Role could help here. But if the designer chooses to add another address form, I would have to add another Role. What if the designer wants to add 100 addresses? (yes, he's a maniac)
Can composition help? I thought something like this?
@Name("checkoutPage")
| public class CheckoutPage
| {
| @In(scope=ScopeType.STATELESS, create=true)
| CheckoutAddressController c1;
|
| @In(scope=ScopeType.STATELESS, create=true)
| CheckoutAddressController c2;
|
| // or even
| List<CheckoutController> ctls;
|
| @Create public void create() {
| ctls = new ArrayList...
| ctls.add(Component.getInstance("checkoutAddressController", ScopeType.STATELESS, true))
| }
| }
Will this work?
Are there other solutions?
Am I making things to complicated?
Regards
Patrick
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068226#4068226
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068226
18Â years, 9Â months
[JNDI/Naming/Network] - ClassCastException on remote calling of an EJB3.0
by broneo
Hello,
i`m relativly new to Java and working on a project in which i`d like to call an EJB from a Desktop client. UNfortunately now i'm stuck. As far as i can tell the connection works fine. I' getting also something back from the server. As i understand it is the reference object of the searched bean. The problem is, that i get a ClassCastException if i try to cast this object to an BeanRemote object. This is my client code:
public static void main(String args[]) throws NamingException, RemoteException {
|
| Hashtable env = new Hashtable();
| env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
| env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
|
| final Context ic = new InitialContext(env);
| Object client = ic.lookup("ClientBean");
| ClientLocal home = (ClientLocal)client; //This line causes The error
| System.out.println("ClientBean is bound to: " + client);
|
| java.awt.EventQueue.invokeLater(new Runnable() {
| public void run() {
| new Client().setVisible(true);
| }
| });
| }
|
| // Variables declaration - do not modify
| private javax.swing.JLabel jLabel1;
| private javax.swing.JButton showButton;
| private javax.swing.JTextField textFieldClient;
| private javax.swing.JButton updateButton;
| // End of variables declaration
|
| }
|
The output i get:
compile:
run:
2007-07-27 10:29:46.504 java[363] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0x10303, name = 'java.ServiceProvider'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2007-07-27 10:29:46.505 java[363] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider)
Exception in thread "main" java.lang.ClassCastException: org.jnp.interfaces.NamingContext
at com.planetactive.ejb.client.Client.main(Client.java:106)
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
If i uncomment the described line, this is my output. As you can see i get
org.jnp.interfaces.NamingContext@2cc95d
back from my lookup.
compile:
run:
2007-07-27 10:31:03.198 java[364] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0x10303, name = 'java.ServiceProvider'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2007-07-27 10:31:03.198 java[364] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider)
ClientBean is bound to: org.jnp.interfaces.NamingContext@2cc95d
BUILD SUCCESSFUL (total time: 5 seconds)
I've searched many forums for this problem. Seems te be an often seen problem. Unfortunately i couldn't find a solution. I hope you can help me to fix this.
I'm using Jboss 4.2.0 GA and Netbeans.
Thanks in advance
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068224#4068224
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068224
18Â years, 9Â months
[JBoss Seam] - Re: Lost the ability to debug - timeout...
by henrik.lindberg
Aaaargh - the problem is back!
Have no clue as to what caused it to come back - and the steps I took last time did not help this time.
When running outside the microcontainer JBoss starts upp in between 40 seconds to 1:20. When running the microcontainer it takes 9-10 minutes!
Things are reasonably fast up to the point when the boot reaches this section:
| 15:55:22,921 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
| 15:55:22,921 INFO [UpdateTimestampsCache] starting update timestamps cache at region: cssite_ear,cssite_jar,cssite.org.hibernate.cache.UpdateTimestampsCache
| 15:55:22,937 INFO [StandardQueryCache] starting query cache at region: cssite_ear,cssite_jar,cssite.org.hibernate.cache.StandardQueryCache
| 15:55:30,859 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateful.StatefulContainer
| 15:55:30,953 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=cssite.ear,jar=cssite.jar,name=BillOfMaterialsHome,service=EJB3 with dependencies:
| 15:55:37,015 INFO [EJBContainer] STARTED EJB: com.cloudsmith.cssite.entityctrl.BillOfMaterialsHome ejbName: BillOfMaterialsHome
| 15:55:37,906 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateful.StatefulContainer
| 15:55:37,921 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=cssite.ear,jar=cssite.jar,name=ComponentHome,service=EJB3 with dependencies:
| 15:55:42,125 INFO [EJBContainer] STARTED EJB: com.cloudsmith.cssite.entityctrl.ComponentHome ejbName: ComponentHome
|
i.e. right after schema export.
One earlier suspicion was that it had something to do with ports being blocked/used and that it was fighting with some firewall, or other software. Could that theory be true? Or, can you think of something else that would keep the boot very very busy - the cpu is at 100% load and my machine is on its knees when this happens.
Suggestions anyone? I really need to solve this problem.
I am on JBoss 4.2.1.GA, Seam 2.0 Beta, and on a Windows XP machine.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068221#4068221
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068221
18Â years, 9Â months
[JBoss Seam] - Null value sent by s:link in dataTable
by chawax
Hi,
I have a problem when using dataTable tag, I think it's a newbie error but I can't find it ...
What I want :
- A list of employees
- A link to go to a detailed page of the employee
To do this, I have this JSF page :
<f:view>
| <div class="section">
| <h:outputText value="Aucun employé" rendered="#{employes != null and employes.rowCount==0}"/>
| <h:dataTable id="employes" value="#{employes}" var="emp" rendered="#{employes.rowCount>0}">
| <h:column>
| <f:facet name="header">ID</f:facet>
| #{emp.id}
| </h:column>
| <h:column>
| <f:facet name="header">Nom</f:facet>
| #{emp.nom}
| </h:column>
| <h:column>
| <f:facet name="header">Prénom</f:facet>
| #{emp.prenom}
| </h:column>
| <h:column>
| <f:facet name="header">Action</f:facet>
| <s:link id="viewEmploye" value="Voir" action="#{employeCrud.selectEmploye(emp)}"/>
| </h:column>
| </h:dataTable>
| </div>
| </f:view>
|
Here's the method selectEmploye in component employeCrud (CONVERSATION scope) :
/**
| *
| */
| public void selectEmploye(fr.horoquartz.t4.core.employe.VOEmploye selectedEmploye)
| {
| if (selectedEmploye == null)
| {
| throw new IllegalArgumentException(
| "fr.horoquartz.t4.gui.employe.EmployeCrudActionBean.selectEmploye(fr.horoquartz.t4.core.employe.VOEmploye selectedEmploye) - 'selectedEmploye' can not be null");
| }
| try
| {
| this.handleSelectEmploye(selectedEmploye);
| }
| catch (Throwable th)
| {
| throw new fr.horoquartz.t4.gui.employe.EmployeCrudActionException(
| "Error performing 'fr.horoquartz.t4.gui.employe.EmployeCrudAction.selectEmploye(fr.horoquartz.t4.core.employe.VOEmploye selectedEmploye)' --> " + th,
| th);
| }
| }
|
The list of employees works, but when I click on the action link to select an employee, the selectedEmploye parameter is null !
What am I doing wrong ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068220#4068220
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068220
18Â years, 9Â months
[Installation, Configuration & DEPLOYMENT] - Sharing the server/default/deploy directory
by loumaus
Lets assume we have an application which should run on n instances each of them configurable individually.
In my understanding it would be enough to have one
server/default
directory if you could cut off the work, log & data directory.
This way my proposed directory structure would look like
p1
| -- run.sh, run.jar, run.conf, shutdown.sh
| -- log
| -- work
| -- data
p2
| -- run.sh, run.jar, run.conf, shutdown.sh
| -- log
| -- work
| -- data
p3
| -- run.sh, run.jar, run.conf, shutdown.sh
| -- log
| -- work
| -- data
server
| -- default
| -- deploy
| -- config
| -- ...
The p stands for process. Important to understand is that Im not talking about a CLUSTER but several process simply sharing the same data having different configurations.
Does jboss allow this kind of configuration ???
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068218#4068218
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068218
18Â years, 9Â months
[JBoss Tools (users)] - How to lookup EJB 3 session bean from servlet?
by maximuszen
I get a NullPointException at the save line.
public class Test extends HttpServlet {
private static final long serialVersionUID = -1L;
@EJB
private T2Facade t2fl;
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
T2 t2 = new T2("hello");
t2fl.save(t2);
LogUtil.log("t2.getId() = "+t2.getId(),Level.INFO,null);
LogUtil.log("t2.getX() = "+t2.getX(),Level.INFO,null);
}
@Stateless
public class T2Facade implements T2FacadeLocal {
@PersistenceContext
private EntityManager em;
public void save(T2 t2) {
// em.persist(t2);
}
@Entity
@SequenceGenerator(name="t2_sequence", sequenceName = "t2_seq")
public class T2 {
private static final long serialVersionUID = -2L;
private Long id;
private String x;
public T2(String x) {
this.x = x;
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "t2_sequence")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068216#4068216
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068216
18Â years, 9Â months