[jboss-user] [JBoss Seam] - Re: Seam, problem with EntityManager
grdzeli_kaci
do-not-reply at jboss.com
Thu Jul 5 02:23:01 EDT 2007
hi lowecg2004,
first of all thank you for your post, i tried all versions of seam and jboss application server,
is this so difficult that use seam and richfaces together ???
i already tried this for a week but could not resolve :(
environment :
1. JBoss AS 4.2.0GA
2. Seam 2.0.0.BETA1
3. Richfaces 3.0.1
4.ajax4jsf 1.1.1
here is my example simple dynamic tree generation into seam component :
1.MenuBean.java (Seam Component)
| @Name("menu")
| @Scope(ScopeType.SESSION)
| public class MenuBean{
|
| @In
| private EntityManager entityManager;
|
| private HtmlPanelBar bar = new HtmlPanelBar();
| public MenuBean() {
| }
|
| public HtmlPanelBar getBar() {
| if (bar!=null && bar.getChildren()!=null) {
| bar.getChildren().clear();
| }
|
| ArrayList<Menu> arraylist = (ArrayList<Menu>)entityManager.createNamedQuery("Menu.findAll").getResultList();
| for (Menu elem : arraylist) {
| HtmlPanelBarItem item= new HtmlPanelBarItem();
| item.setLabel("Blaaaa");
|
| Library library = new Library();
| HtmlTree tree = new HtmlTree();
| tree.setStyle("width:150px");
| tree.setValue(library.getData());
| tree.setVar("item");
| tree.setNodeFace(library.getType());
|
|
| Iterator<Artist> itArtists = library.getArtists().values().iterator();
| while (itArtists.hasNext()) {
| Artist artist = (Artist)itArtists.next();
|
| HtmlTreeNode artistNode = new HtmlTreeNode();
| artistNode.setType("artist");
| HtmlOutputText artistText = new HtmlOutputText();
| artistText.setValue(artist.getName());
|
| Iterator<Album> itAlbums = artist.getAlbums();
| while (itAlbums.hasNext()) {
| Album album = (Album) itAlbums.next();
|
| HtmlTreeNode albumNode = new HtmlTreeNode();
| albumNode.setType("album");
| HtmlOutputText albumText = new HtmlOutputText();
| albumText.setValue(album.getTitle());
|
| Iterator<Song> itSongs = album.getSongs();
| while (itSongs.hasNext()) {
| Song song = (Song) itSongs.next();
|
| HtmlTreeNode songNode = new HtmlTreeNode();
| songNode.setType("song");
| HtmlOutputText songText = new HtmlOutputText();
| songText.setValue(song.getTitle());
|
| tree.getChildren().add(songNode);
| }
| tree.getChildren().add(albumNode);
| tree.getChildren().add(artistNode);
| item.getChildren().add(tree);
| bar.getChildren().add(item);
| }
| }
| }
| return bar;
| }
| public void setBar(HtmlPanelBar bar) {
| this.bar = bar;
| }
| }
|
1.Home.xhtml (Presentation Layer)
| <ui:define name="body">
|
| <h:messages globalOnly="true" styleClass="message"/>
| <h:form id="bodyForm">
| <rich:panel>
| <f:facet name="header">Welcome!</f:facet>
| <p>This empty shell application includes:</p>
| <ul>
| <li>Ant build script</li>
| <li>Deployment to JBoss AS</li>
| <li>Integration testing using TestNG and JBoss Embeddable EJB3</li>
| <li>EJB 3.0 Seam components</li>
| <li>Templated Facelets views</li>
| <li>HSQL (or MySQL) Datasource</li>
| <li>Default CSS stylesheet</li>
| <li>Internationalization support</li>
| </ul>
| <rich:panelBar binding="#{menu.bar}" width="500" height="600">
| </rich:panelBar>
| </rich:panel>
| </h:form>
| </ui:define>
|
i always get this error :
| Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: menu.entityManager
| at org.jboss.seam.Component.getValueToInject(Component.java:2042)
| at org.jboss.seam.Component.injectAttributes(Component.java:1481)
| at org.jboss.seam.Component.inject(Component.java:1302)
|
i tried to find something into seam code but i could not find anything for this issue,
you told me about configurations lowecg200, here is my configurations :
1.components.XML
| <?xml version="1.0" encoding="UTF-8"?>
| <components xmlns="http://jboss.com/products/seam/components"
| xmlns:core="http://jboss.com/products/seam/core"
| xmlns:persistence="http://jboss.com/products/seam/persistence"
| xmlns:drools="http://jboss.com/products/seam/drools"
| xmlns:security="http://jboss.com/products/seam/security"
| xmlns:mail="http://jboss.com/products/seam/mail"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation=
| "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
| http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
| http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
| http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
| http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
| http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
|
| <core:init debug="@debug@" jndi-pattern="@jndiPattern@"/>
|
| <core:manager concurrent-request-timeout="500"
| conversation-timeout="120000"
| conversation-id-parameter="cid"/>
|
|
| <persistence:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/NewBillingEntityManagerFactory"/>
|
| <drools:rule-base name="securityRules">
| <drools:rule-files>
| <value>/security.drl</value>
| </drools:rule-files>
| </drools:rule-base>
|
| <security:identity authenticate-method="#{authenticator.authenticate}"
| security-rules="#{securityRules}"/>
|
| <event type="org.jboss.seam.notLoggedIn">
| <action expression="#{redirect.captureCurrentView}"/>
| </event>
| <event type="org.jboss.seam.postAuthenticate">
| <action expression="#{redirect.returnToCapturedView}"/>
| </event>
| <mail:mail-session host="localhost" port="2525" username="test" password="test" />
| </components>
|
here is managed-persistence-context defined
2.persistence.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <!-- Persistence deployment descriptor for dev profile -->
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
|
| <persistence-unit name="NewBilling">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/NewBillingDatasource</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="validate"/>
| <property name="hibernate.cache.use_query_cache" value="true"/>
| <property name="hibernate.show_sql" value="true"/>
| <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
|
| <!-- use a file system based index -->
| <property name="hibernate.search.default.directory_provider"
| value="org.hibernate.search.store.FSDirectoryProvider"/>
| <!-- directory where the indexes will be stored -->
| <property name="hibernate.search.default.indexBase" value="./dvdindexes"/>
| <!-- Not needed with HA 3.3 -->
| <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>
| <property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>
| <property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>
|
|
| <property name="jboss.entity.manager.factory.jndi.name" value="java:/NewBillingEntityManagerFactory"/>
|
| <property name="hibernate.default_schema" value="JITS"/>
| </properties>
| </persistence-unit>
| </persistence>
|
also here is jndi.name defined correctly.
i also saw dvd example and i could not find difference into configurations.
have you ever tried to use richfaces and seam together ??
and i have one another question also, if i have one ejb interface and seam components which is also bean for component (for example richfaces treenode bean) how i can call ejb component ?? @EJB does not work, i like separated logic : business layer - presentation layer, how i can call ejb component ?
Any idea will be appreciated.
________________________
Regards,
Paata.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060650#4060650
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060650
More information about the jboss-user
mailing list