[JBoss Seam] - Re: Developing with Seam 2 and deploying on WebSphere
by kryl99
There appears to be some incompatibility (namely a missing getELContext() method) between the JSF library supplied by IBM with Websphere and the JSF 1.2 RI version utilised by Seam:
Here is the stacktrace:
Uncaught exception thrown in one of the service methods of the servlet: Faces Servlet. Exception thrown : java.lang.NoSuchMethodError: javax/faces/context/FacesContext.javax/el/ELContext;
By manipulating the class loading sequence we can ensure that Seam uses the JSF 1.2 RI bundled in the war, however a different exception is thrown, this time a ClassCastException.
Here is the PARENT_LAST classloader stacktrace:
Exception caught while initializing context
javax.faces.FacesException: java.lang.ClassCastException: org.jboss.seam.jsf.SeamApplicationFactory incompatible with javax.faces.application.ApplicationFactory
Has anyone reproduced this problem, and are there any suggestions for how it might be addressed?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113245#4113245
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113245
18 years, 4 months
[JBoss Seam] - Re: [newbie] Problem passing parameters
by pete.muir@jboss.org
"german.otero" wrote : Ok, In this example, we have a MessageManagerBean that is Session scopped. so it has the reference, is the same as the entityHome. or any Session Bean then holds the reference. this session bean, will have the reference to my selected object, until the end of my session.. or i need to say to him Hey destroy anything because i finish my work..
A conversation provides an implementation of this idea and allows you to scope your "session" to the natural length of the user's interaction
anonymous wrote : On the other hand suppouse that when i click the view/edit button, open a popUp window, so a single user, with single session, can open 2 AType for edit.... 2 windows, 1 session bean... ERR.... it must be other way to pass object form one page to other.. thinking that i do not have a conversation...
| i'm starting a conversation, with an object.
Use a conversation :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113243#4113243
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113243
18 years, 4 months
[JNDI/Naming/Network] - Multiple database JNDI calls in single EJB
by anacarda
Hi,
I have some code in an EJB that I want to open up two different database connections (using JNDI) to two different datasources... so...
Context loContext = (Context) new InitialContext().lookup("java:");
| DataSource loDataSource1 = (DataSource)loContext.lookup("Prophet_Data");
| Connection loConnection1 = loDataSource1.getConnection();
| try {
| DataSource loDataSource2 = (DataSource)loContext.lookup("Prophet_Cube");
| // Issue when this getConnection() is called
| Connection loConnection2 = loDataSource2.getConnection();
| try {
| //
| } finally {
| if (!(loConnection2 == null)) {
| loConnection2.close();
| }
| }
| } finally {
| if (!(loConnection1 == null)) {
| loConnection1.close();
| }
| }
|
When I call loDataSource2.getConnection(), the following exception is raised:
11:21:35,475 WARN [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] Adding multiple last resources is disallowed. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@1b6ac25
| 11:21:35,476 ERROR [STDERR] org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: a090101:c463:47658705:2467 status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: a090101:c463:47658705:2467 status: ActionStatus.ABORT_ONLY >))
| 11:21:35,477 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
| 11:21:35,478 ERROR [STDERR] at nz.co.mcpond.test.ejb.helloejb.HelloEJB.getText(HelloEJB.java:23)
| 11:21:35,478 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| 11:21:35,478 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
If I set com.arjuna.ats.jta.allowMultipleLastResources to true, within jbossjta-properties.xml, then I can use the second connection, however, I have read that this is not really safe to do so.
So, I am just wondering, what is the best way to use two seperate database connections within the same EJB (using JNDI)?
I am using two seperate database connections, because I want to read data from both databases (and update both databases) depending on values from each table within each database...
Antonio Broughton
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113240#4113240
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113240
18 years, 4 months
[JBoss Seam] - FlushModeType.MANUAL in conversation
by kai222
Hi,
I cannot control the synchronization from a persistent object to the database. The more I read and the more I try out the more I get confused. I hope that somebody can give me a helping hint.
For testing I generated a simple ear project with seam-gen (Seam 2.0.0.GA) and added an entity class and a stateful session bean.
The use case:
A logged in user wants to change his email address (unique field in table).
A server-side validation with a database selection is effected and fails if the new email address exists in the database.
What happens:
If I enter a new email and press Save, a synchronization (flush) takes place just before the selection of the existing email addresses has been started. In FlushMode.AUTO this is normal, but not in FlushMode.MANUAL. The effect is that EVERY new email is known to the system and the validation does not work as it should.
The entity class MyUser is:
| package some.model;
|
| // imports...
|
| @Entity
| @Table
| @Name("user")
| public class MyUser implements Serializable {
|
| @Id @GeneratedValue
| private Long id = null;
|
| // username is the business key
| @Column(name="username", nullable = false, unique = true)
| private String username;
|
| @Email
| @Column(name="email", nullable = false, unique = true)
| private String email;
|
| private String firstname;
| private String lastname;
|
| public MyUser() {
| }
|
| //... getter and setter ...
|
| }
|
The stateful session bean implementation is:
| package some.controller;
|
| // imports ...
|
| @Name( "userAction" )
| @Scope( ScopeType.CONVERSATION )
| @Stateful
| public class UserActionBean implements Serializable, UserAction {
| private static final long serialVersionUID = 1L;
|
| @PersistenceContext(type=PersistenceContextType.EXTENDED)
| private EntityManager entityManager;
|
| @In(create=true)
| private transient FacesMessages facesMessages;
|
| @In( value = "user", required = false )
| @Out( value = "user", required = false )
| private MyUser selectedUser;
|
| @In
| private Identity identity;
|
| private String backupEmail;
|
| @Begin(flushMode=FlushModeType.MANUAL, join=true)
| public String selectLoggedInUser() {
| System.out.println( "Selected logged in User: " + identity.getUsername() );
| List<MyUser> existing = (List<MyUser>) entityManager
| .createQuery("from MyUser u where u.username = :uname)")
| .setParameter("uname", identity.getUsername())
| .getResultList();
| if (existing.size() == 1) {
| selectedUser = (MyUser) existing.get(0);
| backupEmail = selectedUser.getEmail();
| System.out.println( "Redirecting to /editLoggedInUser.xhtml" );
| return "/editLoggedInUser.xhtml";
| } else {
| return "/home.xhtml";
| }
| }
|
| @End
| public String saveLoggedInUser() {
|
| // Try if email exists
| // There should NOT be a flush before the query is effected
| // But there IS a flush before the query is effected
| if (emailExists()) {
| selectedUser.setEmail(backupEmail);
| return null;
| }
|
| // Normal flush (success case)
| entityManager.flush();
|
| FacesMessages.instance().add( "#{user.username} has been saved." );
| return "/home.xhtml";
| }
|
| private boolean emailExists() {
| List<String> existing = (List<String>)
| entityManager.createQuery("from MyUser u where u.email = :email)")
| .setParameter("email", selectedUser.getEmail())
| .getResultList();
| if(existing.size() != 0) {
| facesMessages.add("#{messages['NewEmailExists']}" + selectedUser.getEmail());
| return true;
| }
| return false;
| }
|
| @Remove @Destroy
| public void destroy() {}
| }
|
Extension of "menu.xhtml" to start the conversation:
| ...
| <rich:toolBarGroup rendered="#{identity.loggedIn}">
| <s:link action="#{userAction.selectLoggedInUser}" value="#{messages['MyUser']}"/>
| </rich:toolBarGroup>
| ...
|
The form "editLoggedInUser.xhtml" is:
| <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:j4j="http://javascript4jsf.dev.java.net/"
| xmlns:rich="http://richfaces.ajax4jsf.org/rich"
| template="layout/template.xhtml">
|
| <ui:define name="body">
|
| <h:messages styleClass="message" globalOnly="true"/>
|
| <h:form id="editLoggedInUser">
|
| <rich:panel>
| <f:facet name="header">#{messages['MyUser']}</f:facet>
|
| <div class="dialog">
| <s:validateAll>
| <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
|
| <h:outputLabel>#{messages['Username']}</h:outputLabel>
| <h:outputText value="#{user.username}"/>
|
| <h:outputLabel for="firstname">#{messages['FirstName']}</h:outputLabel>
| <s:decorate>
| <h:inputText id="firstname" required="true"
| value="#{user.firstname}"/>
| </s:decorate>
|
| <h:outputLabel for="lastname">#{messages['LastName']}</h:outputLabel>
| <s:decorate>
| <h:inputText id="lastname" required="true"
| value="#{user.lastname}"/>
| </s:decorate>
|
| <h:outputLabel for="email">#{messages['Email']}</h:outputLabel>
| <s:decorate>
| <h:inputText id="email" required="true"
| value="#{user.email}"/>
| </s:decorate>
|
| </h:panelGrid>
| </s:validateAll>
| </div>
|
| </rich:panel>
|
| <div class="actionButtons">
| <h:commandButton id="saveLoggedInUser" value="#{messages['Save']}"
| action="#{userAction.saveLoggedInUser}"/>
| </div>
|
| </h:form>
|
| </ui:define>
| </ui:composition>
|
The persistence.xml shows that Hibernate is the persistence provider, so MANUAL FlushMode should work:
| ...
| <persistence-unit name="aValidationTest">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/aValidationTestDatasource</jta-data-source>
| <properties>
| <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
| <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
| <property name="hibernate.show_sql" value="true"/>
| <property name="hibernate.format_sql" value="true"/>
| <property name="jboss.entity.manager.factory.jndi.name" value="java:/aValidationTestEntityManagerFactory"/>
| </properties>
| </persistence-unit>
| ...
|
components.xml:
| ...
| <persistence:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/aValidationTestEntityManagerFactory"/>
| ...
|
import-dev.sql:
| insert into MyUser (ID, USERNAME, FIRSTNAME, LASTNAME, EMAIL) values (1, 'admin', 'Frederic', 'Chopin', 'one(a)email.com');
| insert into MyUser (ID, USERNAME, FIRSTNAME, LASTNAME, EMAIL) values (2, 'user', 'Baby', 'Love', 'two(a)email.com');
|
What's wrong in my thinking?
Thank you very much for all answers.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113239#4113239
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113239
18 years, 4 months