[JBoss Seam] - Re: Charts
by engelme
I use JFreeCharts. Here is an example of what i do. The code is a little rough but gives the general idea.
| package example.chartprocesser;
|
| @Name("chartprocesser")
| public class ChartProcesserBean implements {
|
| @In
| EntityManager em; // Entity Manager to access the database
|
| byte[] chart; // chart image (.png) as a byte array
|
|
| @Factory(value="chart")
| public void createChart() {
|
| DefaultCategoryDataset ds = this.getData;
|
|
| JFreeChart chart = ChartFactory.createLineChart(
| "TITLE",
| "Category Label",
| "Axis Lable",
| ds,
| PlotOrientation.HORIZONTAL,
| false,
| false,
| false
| );
|
| try{
| this.chart = ChartUtilities.encodeAsPNG(chart.createBufferedImage(400, 400));
| } catch (IOException e){
| e.printStackTrace();
| }
|
| }
|
| private DefaultCategoryDataset getData(){
| //get the data and put into DefaultCategoryDataset
| //Then return it.
| }
| }
|
Then in the display page.
| <s:graphicImage value="#{chartprocesser.chart}" />
|
Take a look at the <s:graphicImage/> tag and the JFree docs for more on creating charts.
If you put this in a SFSB then you might want to put something to clear the
chart before the method is run again, especially if the chart can change between renderings.
I usually use this in a stateless bean that does all of the processing for the page to be rendered. Then once rendered, the SLSB is destroyed (I hope) when the page is refreshed the SLSB gets recreated and the chart is rendered anew. No messing with storing images to the disk.
Hope this makes sense.
Micheal
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067255#4067255
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067255
18Â years, 9Â months
[EJB/JBoss] - Fail to lookup entity bean inside a stateless session bean b
by calsonli
Hi all,
I am using JBoss 4.0.5 GA and myEclipse 5.1.1 GA to do a web project with EJB for database manipulation.
I created a stateless session bean which is invoked in doGet method of a servlet. I tried to add CMP entity bean lookup method in a business method of this session bean. It ends up with a "Naming Exception". The code snippet inside the business method of stateless session bean is as follows.
| try {
| // StaffLocalHome is the home interface of CMP entity bean Staff
| StaffLocalHome staffHome = StaffUtil.getLocalHome();
| StaffLocal staff = staffHome.findByPrimaryKey(new StaffPK(loginID));
| StaffData staffData = staff.getValueObject();
| ....
| catch (NamingException ne) {
| returnCode = 1;
| }
| catch (FinderException fe) {
| returnCode = -2;
| }
| catch (Exception e) {
| returnCode = 2;
| }
| ...
|
If I moved the above codes inside the servlet where stateless session bean is invoked, no problem of naming exception when looking up CMP entity bean. So, it seems that ejb-jar.xml, jboss.xml, web.xml and jboss-web.xml are correctly configured.
Could you advise where the problem is?
Thank you,
Calson
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067254#4067254
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067254
18Â years, 9Â months
[JBoss Seam] - Seam 2.0 Connection timed out
by blackers
When I run my jboss (4.2) from behind a proxy server I am getting a connection timed out error. It works fine, but slowly when I am running it with a direct connection to the internet. I am assuming Seam is looking for the xsi schema document from http://www.w3.org/2001/XMLSchema-instance
since the pages-2.0.xsd is included in the jboss-seam.jar file.
My pages.xml looks as follows. (Generated by SeamGen)
|
| <?xml version="1.0" encoding="UTF-8"?>
| <pages xmlns="http://jboss.com/products/seam/pages"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
|
| no-conversation-view-id="/home.xhtml"
| login-view-id="/login.xhtml">
|
| <page view-id="*">
| <navigation>
| <rule if-outcome="home">
| <redirect view-id="/home.xhtml"/>
| </rule>
| </navigation>
| </page>
|
| <exception class="org.jboss.seam.framework.EntityNotFoundException">
| <redirect view-id="/error.xhtml">
| <message>Not found</message>
| </redirect>
| </exception>
|
| <exception class="javax.persistence.EntityNotFoundException">
| <redirect view-id="/error.xhtml">
| <message>Not found</message>
| </redirect>
| </exception>
|
| <exception class="javax.persistence.OptimisticLockException">
| <end-conversation/>
| <redirect view-id="/error.xhtml">
| <message>Another user changed the same data, please try again</message>
| </redirect>
| </exception>
|
| <exception class="org.jboss.seam.security.AuthorizationException">
| <redirect>
| <message>You don't have permission to do this</message>
| </redirect>
| </exception>
|
| <exception class="org.jboss.seam.security.NotLoggedInException">
| <redirect view-id="/login.xhtml">
| <message>Please log in first</message>
| </redirect>
| </exception>
|
| <exception>
| <redirect view-id="/error.xhtml">
| <message>Unexpected error, please try again</message>
| </redirect>
| </exception>
|
| </pages>
|
The error I get is as follows.
|
| java.lang.RuntimeException: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
| at org.jboss.seam.navigation.Pages.getDocumentRoot(Pages.java:943)
| at org.jboss.seam.navigation.Pages.parse(Pages.java:929)
| at org.jboss.seam.navigation.Pages.createPage(Pages.java:182)
| at org.jboss.seam.navigation.Pages.getPage(Pages.java:157)
| at org.jboss.seam.navigation.Pages.createPageStack(Pages.java:239)
| at org.jboss.seam.navigation.Pages.getPageStack(Pages.java:218)
| at org.jboss.seam.navigation.Pages.getScheme(Pages.java:515)
| at org.jboss.seam.navigation.Pages.encodeScheme(Pages.java:413)
| at org.jboss.seam.ui.util.ViewUrlBuilder.<init>(ViewUrlBuilder.java:24)
| at org.jboss.seam.ui.component.UISeamCommandBase.getUrl(UISeamCommandBase.java:36)
|
Is there a way I can get this to work from behind a proxy? Is this the expected behaviour?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067252#4067252
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067252
18Â years, 9Â months
[Management, JMX/JBoss] - MBean init and schedule
by loseyourself
Greetings all,
I create an Mbean and deploy it to JBoss 3.2.5, the overview of the MBean is:
public class TopicMailListener extends ServiceMBeanSupport
| implements MessageListener, TopicMailListenerMBean {
| String url;
| String name;
|
| public TopicMailListener(String url, String name) {
| super();
|
| this.url = url;
| this.name = name;
| LOGGER.info("Topc mail listner initiaated: url: " + url + "; name: " + name);
| }
|
| public void start() throws Exception {
| try {
| super.start();
| LOGGER.info(">>>>>>>>>>> Topic mail listner start now...");
| this.initializeListener();
| } catch (Exception e) {
| LOGGER.info("Error creating listener: " + e);
| e.printStackTrace();
| }
| }
|
| protected void startService() throws Exception{
| try {
| super.startService();
| LOGGER.info(">>>>>>>>>>> Topic mail listner start service now...");
| this.initializeListener();
| } catch (Exception e) {
| LOGGER.info("Error creating listener: " + e);
| e.printStackTrace();
| }
| }
|
| }
|
the jboss-service.xml is as following:
| <?xml version="1.0" encoding="UTF-8"?>
| <server>
| <mbean code="au.gov.nsw.community.mail.TopicMailListener" name="au.gov.nsw.community.mail:service=TopicMailListener">
| <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
| <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
| <depends>jboss:service=ScheduleManager</depends>
| <depends>jboss:service=SchedulableMBeanExample</depends>
| <attribute name="StartAtStartup">true</attribute>
| <attribute name="DateFormat"></attribute>
| <attribute name="StartDate">NOW</attribute>
| <attribute name="Period">10000</attribute>
| <attribute name="Repetitions">-1</attribute>
| <attribute name="SecurityConf">
| <security>
| <role name="guest" read="true" write="true"/>
| <role name="publisher" read="true" write="true" create="false"/>
| <role name="durpublisher" read="true" write="true" create="true"/>
| </security>
| </attribute>
| <constructor>
| <arg type="java.lang.String" value="10.65.240.244:1099"/>
| <arg type="java.lang.String" value="topic/testTopic"/>
| </constructor>
| </mbean>
| </server>
|
but it doesn't invoke the construct or start, startService method while this class is deployed as a service in JMX. Any ideas?
And based on this MBean, how can I configure it as a schedule service, say it will be started immediately and every 1 minute will be invoked.
I do appreciate for any help.
cheers,
hj
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067248#4067248
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067248
18Â years, 9Â months