Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Java Programming 24-Hour Trainer 2nd Edition
This is the forum to discuss the Wrox book Java Programming 24-Hour Trainer, 2nd Edition by Yakov Fain; ISBN: 978-1-118-95145-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Java Programming 24-Hour Trainer 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 10th, 2015, 01:17 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lesson31 Tryit

The Tryit source code isn't in the download (this is true for many tryit. ex: lesson 30 as well). I manually created the source code but getting HTTP Status 404 - Not Found.


package lesson31.ejb;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.jms.ConnectionFactory;
import javax.annotation.Resource;

import javax.jms.Destination;
import javax.jms.JMSContext;
import javax.jms.JMSProducer;

/**
* Session Bean implementation class StockServerBean
*/
@Stateless
@LocalBean
public class StockServerBean {
@Resource(lookup = "java:comp/DefaultJMSConnectionFactory")
ConnectionFactory factory;


@Resource(lookup = "MyJMSTestQueue")
Destination testQueue;

private List<String> nasdaqSymbols = new ArrayList<>();
/**Ser
* Default constructor.
*/
public StockServerBean() {
// Define some hard-coded NASDAQ symbols
nasdaqSymbols.add("AAPL");
nasdaqSymbols.add("MSFT");
nasdaqSymbols.add("YHOO");
nasdaqSymbols.add("AMZN");

}
@Schedule(second="*",minute="*", hour="*")
public void getQuote(){

String symbol = "AAPL";
// Generate a random price for valid symbols
String price = (new Double(Math.random()*100)).toString();
String quote = "The price of " + symbol + " is " + price;

// send to JMS queue

{
try (JMSContext context = factory.createContext("admin","admin")) {

JMSProducer producer = context.createProducer();

// Send stock quote to the queue
producer.send(testQueue, quote);

System.out.println("Sent stock quote to the queue: " + quote);
}

}
}
}
Reply With Quote
  #2 (permalink)  
Old December 10th, 2015, 04:21 PM
Authorized User
Points: 159, Level: 3
Points: 159, Level: 3 Points: 159, Level: 3 Points: 159, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Location: Romania
Posts: 30
Thanks: 5
Thanked 4 Times in 4 Posts
Default

Might it be that the StockServerBean is not created?
How about using the @Startup annotation, to request the creation of the bean on application startup?
Reply With Quote
  #3 (permalink)  
Old December 10th, 2015, 04:51 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

@Startup doesn't help. Same error
Reply With Quote
  #4 (permalink)  
Old December 10th, 2015, 05:06 PM
Authorized User
Points: 159, Level: 3
Points: 159, Level: 3 Points: 159, Level: 3 Points: 159, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Location: Romania
Posts: 30
Thanks: 5
Thanked 4 Times in 4 Posts
Default

Did you implement a consumer (message driven bean) as well?
I don't understand what does HTTP have to do with this ejb...
Reply With Quote
  #5 (permalink)  
Old December 23rd, 2015, 02:45 PM
Authorized User
Points: 75, Level: 1
Points: 75, Level: 1 Points: 75, Level: 1 Points: 75, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2014
Posts: 13
Thanks: 1
Thanked 4 Times in 4 Posts
Default Lesson31 Tryit

Hi,

Let me know if you are still having problems with the Lesson 31 TryIt code. I can help out.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 9 Tryit cellison BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 1 July 14th, 2012 01:57 PM
Chapter 11 TryIt Luthios BOOK: Java Programming 24-Hour Trainer by Yakov Fain 8 March 3rd, 2012 01:57 PM
TryIt 32 zavodney BOOK: Stephens' Visual Basic Programming 24-Hour Trainer 5 October 13th, 2011 11:33 AM
Lesson 36 Tryit Mark P. BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 4 October 11th, 2011 02:49 PM
Chapter 10 Tryit Mark P. BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 3 June 20th, 2011 08:20 PM



All times are GMT -4. The time now is 05:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.