[Beginners Corner] - Re: Load index.jsp as welcome file
by pepelara
This is my web.xml file,
<?xml version="1.0" encoding="ISO-8859-1"?>
| <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
| <web-app>
| <servlet>
| <servlet-name>ServletEntrada</servlet-name>
| <servlet-class>es.deusto.servlet.ServletEntrada</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>ServletEntrada</servlet-name>
| <url-pattern>/*</url-pattern>
| </servlet-mapping>
|
| <mime-mapping>
| <extension>doc</extension>
| <mime-type>application/msword</mime-type>
| </mime-mapping>
| <mime-mapping>
| <extension>xls</extension>
| <mime-type>application/vnd.ms-excel</mime-type>
| </mime-mapping>
| <mime-mapping>
| <extension>ppt</extension>
| <mime-type>application/vnd.ms-powerpoint</mime-type>
| </mime-mapping>
| <mime-mapping>
| <extension>pdf</extension>
| <mime-type>application/pdf</mime-type>
| </mime-mapping>
| <mime-mapping>
| <extension>zip</extension>
| <mime-type>application/zip</mime-type>
| </mime-mapping>
|
| <welcome-file-list>
| <welcome-file>index.jsp</welcome-file>
| </welcome-file-list>
|
| </web-app>
|
And this is my application.xml file,
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN' 'http://java.sun.com/j2ee/dtds/application_1_2.dtd'>
| <application>
| <display-name>Entrada</display-name>
| <description>This is the implementaion of the EntradasUsuario application</description>
| <module>
| <ejb>entrada-ejb.jar</ejb>
| </module>
| <module>
| <web>
| <web-uri>entrada-web.war</web-uri>
| <context-root>/entrada</context-root>
| </web>
| </module>
| </application>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4174285#4174285
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4174285
17 years, 8 months
[JBoss Messaging] - Problem with Asynchronous Communicatin
by tpawankumar
Hi All,
I have Jboss-4.2.1 GA and installed jboss-messaging-1.3.0.GA.
I have QueueProducer which sends message to Queue and QueueConsumer which recieves message from the same Queue.
When i run QueueProducer class it is sending the message successfully but when i run QueueConsumer class it is throwing exception on the server console.
Below is the stackTrace:
| 17:57:58,413 WARN [BisocketClientInvoker] Unable to send ping: shutting down Pi
| ngTimerTask
| java.net.SocketException: Connection reset by peer: socket write error
| at java.net.SocketOutputStream.socketWrite0(Native Method)
| at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
| at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
| at org.jboss.remoting.transport.bisocket.BisocketClientInvoker$PingTimer
| Task.run(BisocketClientInvoker.java:636)
| at java.util.TimerThread.mainLoop(Timer.java:512)
| at java.util.TimerThread.run(Timer.java:462)
| 17:58:33,279 WARN [SimpleConnectionManager] ConnectionManager[18a5d49] cannot l
| ook up remoting session ID a2g5c2o-skwq6f-fkpct151-1-fkpct1pw-4
| 17:58:33,279 WARN [SimpleConnectionManager] A problem has been detected with th
| e connection to remote client a2g5c2o-skwq6f-fkpct151-1-fkpct1pw-4. It is possib
| le the client has exited without closing its connection(s) or there is a network
| problem. All connection resources corresponding to that client process will now
| be removed.
Following is the producer class:
| public class QueueProducer {
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| try {
|
|
| Properties prop=new Properties();
| prop.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| prop.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| prop.setProperty("java.naming.provider.url","jnp://localhost:1100");
|
| InitialContext ic =new InitialContext(prop);
|
| ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
| Queue queue = (Queue)ic.lookup("queue/testQueue");
|
| Connection connection = cf.createConnection();
| Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| MessageProducer sender = session.createProducer(queue);
|
| TextMessage message = session.createTextMessage("pavan");
| sender.send(message);
| connection.close();
| System.out.println("message sent");
|
| } catch (Exception e) {
|
| e.printStackTrace();
|
| }
|
| }
|
| }
Following is the QueueConsumer class
| public class QueueConsumer implements MessageListener{
|
| private static Connection conn=null;
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| try{
| Properties prop=new Properties();
| prop.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| prop.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| prop.setProperty("java.naming.provider.url","jnp://localhost:1100");
|
| InitialContext context =new InitialContext(prop);
|
| ConnectionFactory connectionFactory=(ConnectionFactory)context.lookup("ConnectionFactory");
| conn=connectionFactory.createConnection();
| Session session=conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
| Queue queue=(Queue)context.lookup("queue/testQueue");
| MessageConsumer consumer=session.createConsumer(queue);
|
| consumer.setMessageListener(new QueueConsumer());
|
| conn.start();
|
| }
| catch (Exception e) {
| e.printStackTrace();
| }finally{
| try{
| //conn.close();
| }catch(Exception e){
| e.printStackTrace();
| }
| }
|
| }
|
| public void onMessage(Message message)
| {
| try {
| System.out.println("inside onmessage");
| if(message instanceof TextMessage){
| TextMessage objmsg=(TextMessage)message;
| String msg=objmsg.getText();
| System.out.println("message by text : "+msg);
|
| }
| if(message instanceof ObjectMessage){
| ObjectMessage objmsg=(ObjectMessage)message;
| String msg=((Object)objmsg.getObject()).toString();
| System.out.println("message by Object : "+msg);
| }
|
| } catch (Exception e) {
| e.printStackTrace();
| }
|
|
| }
|
| }
After trying out various ways i could resolve this problem by uncommenting the code which is there in QueueConsumer class.
Whenever i comment the code it gives me the same exception.
| finally{
| try{
| conn.close();
| }catch(Exception e){
| e.printStackTrace();
| }
| }
|
Then i feel that the messages are not recieving asynchronously.
whenever i run QueueProducer i should always run QueueConsumer to get the messages.
In JbossMQ it is not necessary to always run the consumer class because the connection is open to the Queue and we are able to recieve messages whenever we run Producer.
Isn't the behaviour for asynchronous communication?
Please help me.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4174281#4174281
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4174281
17 years, 8 months
[Management, JMX/JBoss] - Re: org.jboss.varia.scheduler.Scheduler Problem ?
by jaikiran
"FDomino" wrote : but its strange
| that it looks like that the schedulePeriod is just added.... and not maybe converted...
|
| <attribute name="SchedulePeriod">86400000</attribute>
|
|
Though i haven't completely seen how its behaving on your system (i mean at what "time" the timer is triggered), i think i know what the problem is.
The problem lies in the value being passed to SchedulePeriod. 86400000 milli seconds form 1 day. But on the day when the DST is applied, adding 86400000 to the time is not equivalent to adding 1 day to the date. Here's an example - I have access to a system hosted in US (Pacific Standard Time). This year (2008) the daylight saving time began on March 9 at 2 AM. So in our example, lets start with the date as March 9, 1 AM. The example below,
- first adds 86400000 milli seconds to March 9, 1 AM. The intention is to get the output date as March 10, 1 AM. However as you see in the output, that i have posted below, the output date is Mar 10, 2 AM. Which is not what i wanted.
- Later, instead of adding 86400000 milli seconds, i add 1 day using Calendar.DATE, to the original date March 9, 1 AM. Again, the intention is to get output date as March 10, 1 AM. As shown in the output, this works. So because of the DST, 1 day is not equal to 86400000 milli seconds on March 9.
There's a way to figure out the offset in milliseconds because of the DST. So when adding the 86400000 milli seconds to increment by a day, you should take into account, this offset. See my comments in the code below which does this. When this offset is considered, the output date is as expected March 10, 1 AM.
| package org.myapp;
|
| import java.text.DateFormat;
| import java.text.ParseException;
| import java.text.SimpleDateFormat;
| import java.util.Calendar;
| import java.util.Date;
| import java.util.GregorianCalendar;
| import java.util.Properties;
| import java.util.TimeZone;
|
| public class DateUtility {
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| try {
|
| Calendar calendar = new GregorianCalendar();
| TimeZone tz = calendar.getTimeZone();
| System.out.println("Timezone is " + tz.getDisplayName());
| System.out.println("Amount of time to be added because of DST " + tz.getDSTSavings() + " milli sec");
| DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
| Date originalDate = df1.parse("2008-03-09 01:00:00.000");
| calendar.setTime(originalDate);
| System.out.println("Original date is " + calendar.getTime());
|
| // Jaikiran: Adding 86400000 milli seconds to increment by one day
| // does NOT work
| // Add 86400000 milli seconds and display the output
| calendar.add(Calendar.MILLISECOND,86400000);
| System.out.println("Date after adding 86400000 milli sec to original date is " + calendar.getTime());
|
| // Reset to original date
| calendar.setTime(originalDate);
|
| // Jaikiran: Adding 1 day through Calendar.DATE works
| // Now add 1 day and display the output
| calendar.add(Calendar.DATE,1);
| System.out.println("Date after adding 1 day to original date is " + calendar.getTime());
|
| // Reset to original date
| calendar.setTime(originalDate);
|
| // Jaikiran: Take into consideration the DST offset and then add the milli seconds.
| // This works.
| // Now add (86400000 milli seconds - tz.getDSTSavings() ) and display the output
| calendar.add(Calendar.MILLISECOND,86400000 - tz.getDSTSavings());
| System.out.println("Date after adding (86400000-" + tz.getDSTSavings() + ") = " + (86400000 - tz.getDSTSavings()) + " milli sec to original date is " + calendar.getTime());
|
|
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
|
| }
|
The output of this code:
Timezone is Pacific Standard Time
| Amount of time to be added because of DST 3600000 milli sec
| Original date is Sun Mar 09 01:00:00 PST 2008
| Date after adding 86400000 milli sec to original date is Mon Mar 10 02:00:00 PDT 2008
| Date after adding 1 day to original date is Mon Mar 10 01:00:00 PDT 2008
| Date after adding (86400000-3600000) = 82800000 milli sec to original date is Mon Mar 10 01:00:00 PDT 2008
|
So to handle this efficiently, either
- The org.jboss.varia.scheduler.Scheduler should be enhanced to accept a string value like "DAILY" for the SchedulePeriod attribute. This will shield the user from passing the correct milli seconds value for a day.
OR
- The user who configures the scheduler xml, should be smart enough to know the effect of DST and then decide what value to pass to the SchedulePeriod.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4174272#4174272
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4174272
17 years, 8 months