[JBoss Seam] - Link a user with the entities he/she created
by eroussel
Hello,
I'm fairly new the Seam and looking for some advice on achieving the following:
Some tables (entities) in my application contain data that must be associated with the user that created the record.
I got the part where the entities are annotated properly to describe the 1 to * relationship.
The question I have is which one of the two following approaches Seam veterans would recommend to use (or if neither are appropriate, what's the alternative).
Approach A would be to override the "persist" method in entityHome such as:
| public class myEntityHome extends EntityHome<MyEntity>
| {
| ...
| @In
| User user; // That's the entity with the user's data
|
| ...
| @Override
| public String persist() {
| this.getInstance().setSubmitter(user); // Recording who created this using the entity's setter
| return super.persist();
| }
| }
|
Approach B would be to handle this in an "action" bean.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110025#4110025
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110025
18 years, 4 months
[JBossCache] - Possible Memory Leak? (1.4 SP7)
by slattery
Hi all,
I'm running a test program with a simple loop that writes an object to the cache and then removes it.
As I monitor with JConsole, the heap usage grows and grows and can't be reclaimed with a garbage collection. Eventually it crashes with an OutOfMemoryError.
Below is my code.
MemoryLeakTest.java:
| package test;
|
| import static java.lang.System.out;
|
| import org.jboss.cache.PropertyConfigurator;
| import org.jboss.cache.aop.PojoCache;
|
| public class MemoryLeakTest {
|
| static PojoCache cache;
|
| public static void cacheInit() throws Exception {
| cache = new PojoCache();
| PropertyConfigurator config = new PropertyConfigurator();
| config.configure(cache, "replSync-service.xml");
| cache.start();
| }
|
|
| public static void main(String[] args) throws Exception {
| cacheInit();
|
| final int MAX = 1000000;
| final int INNER_MAX = 2;
| final int DEPTH = 0;
|
| out.println("Adding to cache...");
| for (Integer i=0; i<MAX; i++) {
| String fqn = "/" + i;
| if (i % 100 == 0) out.println(" putting at: " + fqn);
|
| for (int j=0; j<INNER_MAX; j++) {
| cache.putObject(fqn+"/"+j, new DummyObject(DEPTH));
| }
|
| for (int j=0; j<INNER_MAX; j++) {
| cache.removeObject(fqn+"/"+j);
| cache.remove(fqn+"/"+j);
| }
|
| }
|
| cacheStop();
| }
|
| public static void cacheStop() {
| cache.stop();
| cache.destroy();
| }
| }
|
|
DummyObject.java:
| package test;
|
| import java.util.ArrayList;
| import java.util.List;
| import java.util.Random;
|
| public class DummyObject {
| static Random random = new Random();
|
| byte[] data;
| List<DummyObject> children = new ArrayList<DummyObject>();
|
|
| public DummyObject(int depth) {
| this.data = new byte[100];
|
| if (depth > 0) {
| int nextDepth = depth - 1;
| children.add(new DummyObject(nextDepth));
| children.add(new DummyObject(nextDepth));
| }
| }
|
| private String generateRandomData() {
| StringBuilder sb = new StringBuilder();
| for (int i=0; i<1000; i++)
| sb.append(random.nextLong());
|
| return sb.toString();
| }
| }
|
replSync-service.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <server>
| <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
| <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">
|
| <depends>jboss:service=Naming</depends>
| <depends>jboss:service=TransactionManager</depends>
|
| <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
| <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
| <attribute name="CacheMode">REPL_SYNC</attribute>
| <attribute name="UseReplQueue">false</attribute>
| <attribute name="ReplQueueInterval">0</attribute>
| <attribute name="ReplQueueMaxElements">0</attribute>
| <attribute name="ClusterName">TreeCache-Cluster</attribute>
|
| <attribute name="ClusterConfig">
| <config>
| <UDP mcast_addr="228.1.2.3" mcast_port="58866"
| ip_ttl="64" ip_mcast="true"
| mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
| ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
| loopback="false"/>
| <PING timeout="2000" num_initial_members="3"
| up_thread="false" down_thread="false"/>
| <MERGE2 min_interval="10000" max_interval="20000"/>
| <FD_SOCK/>
| <VERIFY_SUSPECT timeout="1500"
| up_thread="false" down_thread="false"/>
| <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
| max_xmit_size="8192" up_thread="false" down_thread="false"/>
| <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
| down_thread="false"/>
| <pbcast.STABLE desired_avg_gossip="20000"
| up_thread="false" down_thread="false"/>
| <FRAG frag_size="8192"
| down_thread="false" up_thread="false"/>
| <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
| shun="true" print_local_addr="true"/>
| <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/>
| </config>
| </attribute>
|
| <attribute name="FetchInMemoryState">true</attribute>
| <attribute name="InitialStateRetrievalTimeout">15000</attribute>
| <attribute name="SyncReplTimeout">15000</attribute>
| <attribute name="LockAcquisitionTimeout">10000</attribute>
| <attribute name="EvictionPolicyClass"></attribute>
| <attribute name="UseRegionBasedMarshalling">true</attribute>
| </mbean>
|
| </server>
|
jboss-aop.xml contains:
| <?xml version="1.0" encoding="UTF-8"?>
| <aop>
| <prepare expr="field(* test.DummyObject->*)" />
| </aop>
|
I launch MemoryLeakTest with these VM parameters:
-Dcom.sun.management.jmxremote -javaagent:.\lib\jboss-aop-jdk50.jar -Djboss.aop.path=.\resources\pojocache-aop.xml -Djboss.aop.path=.\resources\jboss-aop.xml -Xms128M -Xmx128M
Is there anything obvious I might be doing wrong here?
Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110023#4110023
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110023
18 years, 4 months
[JBoss Seam] - Re: What to do to make @Factory method working?
by amorfis
"Andy Gibson" wrote : Do you have your bean setup as a seam component with a @Name annotation? It should be like :
|
|
| | @Name("articleManager")
| | @Scope(ScopeType.Conversation)
| | public class ArticlesManagerBean ....... {
| |
| | @Factory("article")
| | public Article getArticle() {
| | <init code if necessary>
| | return article
| | }
| | }
| |
|
Yes, I have something exactly like this.
anonymous wrote :
| Can you reference your bean from the page?
|
| Try putting in something like :
|
|
| | <h:outputText value="#{articlesManager}"/>
| |
|
| to see if it can pick up your articles manager bean.
|
I just tried, and it doesn't work. Looks like my app doesn't see this bean.
anonymous wrote :
| Also, is your getArticles() method defined in your interface that the bean implements?
|
Yes, it is.
anonymous wrote :
| Other than that, if you post some code, it should be easy to spot. Did you create the app with Seam Gen, and if not, do you have anything working that would indicate whether the app is set up properly?
|
The code is exaclty like in your examples. I am using eclipse and this project is downloaded from CVS of my friend, so I didn't generate it with Seam Gen. My task is to add web module. Application seems to be working, I can access jsp, just expressions like #{articlesManager} evaluate to empty string. If I put some gibberish there (like #{asefbadfe}) there is also empty string, so it behaves like this variables are not existing.
I have components.xml like this:
| <components xmlns="http://jboss.com/products/seam/components"
| xmlns:core="http://jboss.com/products/seam/core">
| <core:init jndi-pattern="@jndiPattern@"/>
| </components>
|
in WEB-INF. There is also faces-config.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <faces-config version="1.2"
| xmlns="http://java.sun.com/xml/ns/javaee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
|
| <!-- Facelets support -->
| <application>
| <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
| </application>
|
| </faces-config>
|
and of course web.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
| <display-name>inka-web</display-name>
| <welcome-file-list>
| <welcome-file>index.html</welcome-file>
| <welcome-file>index.htm</welcome-file>
| <welcome-file>index.jsp</welcome-file>
| <welcome-file>default.html</welcome-file>
| <welcome-file>default.htm</welcome-file>
| <welcome-file>default.jsp</welcome-file>
| </welcome-file-list>
| <listener>
| <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
| </listener>
| <context-param>
| <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| <param-value>client</param-value>
| </context-param>
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.jsp</url-pattern>
| </servlet-mapping>
| </web-app>
|
If you need any other data I can put it here. I just don't know what is wrong.
Best regards
Pawel Stawicki
Cheers,
Andy
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110022#4110022
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110022
18 years, 4 months
[JBoss Seam] - seam fileupload problem reflection error
by yilmaz_
OS : Win xp
Seam 1.2.1 GA @ JBOSS 4.2.2 GA
I tried both
private InputStream picturedata;
or
private byte[] picturedata;[]
i am getting following error
| 23:09:06,203 WARN [lifecycle] javax.el.ELException: /private/profile/profile.xhtml @43,5 data="#{privatePerson.picturedata}": Error writing 'picturedata' on type org.javassist.tmp.java.lang.Object_$$_javassist_15
| javax.faces.el.EvaluationException: javax.el.ELException: /private/profile/profile.xhtml @43,5 data="#{privatePerson.picturedata}": Error writing 'picturedata' on type org.javassist.tmp.java.lang.Object_$$_javassist_15
| at javax.faces.component.ValueBindingValueExpressionAdapter.setValue(ValueBindingValueExpressionAdapter.java:147)
| at org.jboss.seam.ui.UIFileUpload.decode(UIFileUpload.java:57)
|
I am using this interface and implemented all methods.
| public interface PrivatePersonService {
| public String updatePerson();
| public InputStream getPicturedata();
| public void setPicturedata(InputStream data) ;
| public String getContentType() ;
| public void setContentType(String contentType);
| public String getFileName();
| public void setFileName(String fileName);
| public String getTitle() ;
| public void setTitle(String title);
| }
|
| @Stateless
| @Name("privatePerson")
| public class PrivatePerson implements PrivatePersonService {
| @In
| @Out
| User user;
| @In
| EntityManager entityManager;
| @In
| FacesMessages facesMessages;
| @In
| FacesContext facesContext;
| @Logger
| Log log;
| private String contentType;
| private String fileName;
| private String title;
| private InputStream picturedata;
| public String updatePerson() {
| try {
| entityManager.merge(user.getPerson());
| if (getPicturedata() != null) {
| //....
| }
|
| } catch (Exception e) {
|
| }
| return "";
| }
|
| /**
| * @return the data
| */
| public InputStream getPicturedata() {
| return picturedata;
| }
|
| /**
| * @param data
| * the data to set
| */
| public void setPicturedata(InputStream picturedata) {
| this.picturedata = picturedata;
| }
|
| /**
| * @return the contentType
| */
| public String getContentType() {
| return contentType;
| }
|
| /**
| * @param contentType
| * the contentType to set
| */
| public void setContentType(String contentType) {
| this.contentType = contentType;
| }
|
| /**
| * @return the fileName
| */
| public String getFileName() {
| return fileName;
| }
|
| /**
| * @param fileName
| * the fileName to set
| */
| public void setFileName(String fileName) {
| this.fileName = fileName;
| }
|
| /**
| * @return the title
| */
| public String getTitle() {
| return title;
| }
|
| /**
| * @param title
| * the title to set
| */
| public void setTitle(String title) {
| this.title = title;
| }
|
| }
|
i configured web.xml
<filter>
| <filter-name>Seam Filter</filter-name>
| <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
| </filter>
| <filter-mapping>
| <filter-name>Seam Filter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
component.xml file
<component class="org.jboss.seam.web.MultipartFilter">
| <property name="createTempFiles">true</property>
| <property name="maxRequestSize">1000000</property>
| </component>
Server log show multipart component is intalled.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110014#4110014
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110014
18 years, 4 months
[JBoss Seam] - Remoting periodic exception.
by samdoyle
Using the JavaScript remoting I will see periodically but quite frequently the following exception. It is a result of simply doing a polled based operation to retrieve the latest available data.
| [#|2007-12-03T12:53:34.110-0500|SEVERE|sun-appserver9.1|org.jboss.seam.remoting.Remoting|_ThreadID=21;_ThreadName=httpSSLWorkerThread-38080-0;_RequestID=d5d7caaf-2e82-41be-b6f7-383164d5a74f;|Error
| org.dom4j.DocumentException: Error on line 1 of document : Premature end of file. Nested exception: Premature end of file.
| at org.dom4j.io.SAXReader.read(SAXReader.java:482)
| at org.dom4j.io.SAXReader.read(SAXReader.java:343)
| at org.jboss.seam.remoting.ExecutionHandler.handle(ExecutionHandler.java:59)
| at org.jboss.seam.remoting.Remoting.getResource(Remoting.java:113)
| at org.jboss.seam.servlet.SeamResourceServlet.doGet(SeamResourceServlet.java:69)
| at org.jboss.seam.servlet.SeamResourceServlet.doPost(SeamResourceServlet.java:86)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110012#4110012
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110012
18 years, 4 months