• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:13
CEST 19:13
KST 02:13
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro8 Preview Pt1: Inheritors2[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists16[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10
Community News
2026 GSL Season 1 Qualifiers19Maestros of the Game 2 announced92026 GSL Tour plans announced15Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid25
StarCraft 2
General
MaNa leaves Team Liquid Maestros of the Game 2 announced 2026 GSL Tour plans announced Team Liquid Map Contest #22 - The Finalists Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament 2026 GSL Season 1 Qualifiers INu's Battles#14 <BO.9 2Matches> GSL CK: More events planned pending crowdfunding RSL Revival: Season 5 - Qualifiers and Main Event
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 522 Flip My Base The PondCast: SC2 News & Results Mutation # 521 Memorable Boss Mutation # 520 Moving Fees
Brood War
General
[ASL21] Ro8 Preview Pt1: Inheritors Leta's ASL S21 Ro.16 review FlaSh: This Will Be My Final ASL【ASL S21 Ro.16】 BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion
Tourneys
[ASL21] Ro16 Group D [Megathread] Daily Proleagues Escore Tournament StarCraft Season 2 [ASL21] Ro16 Group C
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread Dawn of War IV Diablo IV Total Annihilation Server - TAForever Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread YouTube Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread McBoner: A hockey love story
World Cup 2022
Tech Support
Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1609 users

The Big Programming Thread - Page 909

Forum Index > General Forum
Post a Reply
Prev 1 907 908 909 910 911 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
berated-
Profile Blog Joined February 2007
United States1134 Posts
October 07 2017 00:07 GMT
#18161
On October 07 2017 09:05 Manit0u wrote:
Show nested quote +
On October 07 2017 06:10 berated- wrote:
On October 07 2017 01:59 Manit0u wrote:
On October 07 2017 01:00 spinesheath wrote:
On October 06 2017 18:14 Manit0u wrote:
I wanted to git gud at OOP. Now I have strategies built upon more abstract strategies which select factories built upon more abstract factories and it's all encompassed in even more abstractions with managers, providers, resolvers, handlers, services and such. All this to parse single JSON file...


Someone who is good with OOP would use an existing parser.


I am using an existing parser. But I need to parse the contents of the JSON and then map them to our database structure creating/updating records as necessary.


Every time I see stuff like this I always just want to post the image from the medium article showing java having the highest paid salaries. >_<

Which parsing library are you using? You parsing into json objects and then doing the data transformations yourself or using something like Gson and going straight to objects? You even in java?

Edit: I think you're in ruby, right?

Design patterns never made much sense to me until I started testing. Once you starting writing code for testability they make a ton of sense. If you are just trying to break things down because you "want to git gud" (yeah I know you're joking), then it's really hard to see where you really need to make your seams.


Yeah. Also, my original post was kind of a sitire (pointed at myself of course) about how you can sometimes go overboard and do simple stuff in most convoluted ways.


Understood , but I know how much everyone likes to make fun of us OOP fans too :D
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2017-10-07 07:33:20
October 07 2017 07:33 GMT
#18162
On October 06 2017 23:02 travis wrote:
We are learning about, and implementing in our latest project, DFAs and NFAs. I think they are pretty interesting and I was surprised I had literally never heard of them.

The professor never really told us what their applications are, though. It seems to me that their role is basically to pattern match? They are probably used to implement regex, for example?

Have any of you used these in the real world?


Our log-in mechanism uses a Finite State Machine to determine what actions should be shown and displayed.

https://gist.github.com/andymatuschak/d5f0a8730ad601bcccae97e8398e25b2
There is no one like you in the universe.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 07 2017 08:27 GMT
#18163
On October 06 2017 23:02 travis wrote:
We are learning about, and implementing in our latest project, DFAs and NFAs. I think they are pretty interesting and I was surprised I had literally never heard of them.

The professor never really told us what their applications are, though. It seems to me that their role is basically to pattern match? They are probably used to implement regex, for example?

Have any of you used these in the real world?

I use DFAs very extensively in a project of mine. It's an algorithm for calculating how far from winning a hand in riichi mahjong is. The straightforward implementation of that algorithm is recursive with a ridiculous amount of branching out, really slow. Other implementations use huge lookup tables (in the order of gigabytes) or medium sized lookup tables coupled with a small amount of recursion. My implementation basically takes a multi layered lookup table approach and instead of actually using lookup tables, I convert those into highly compressed DFAs. I got it down to a few of megabytes and no recursion at all.

In short: DFAs can be very useful when compressing data of the "words in a language" type.

There are plenty of other resonable applications though.
If you have a good reason to disagree with the above, please tell me. Thank you.
Acrofales
Profile Joined August 2010
Spain18278 Posts
October 07 2017 13:29 GMT
#18164
On October 07 2017 17:27 spinesheath wrote:
Show nested quote +
On October 06 2017 23:02 travis wrote:
We are learning about, and implementing in our latest project, DFAs and NFAs. I think they are pretty interesting and I was surprised I had literally never heard of them.

The professor never really told us what their applications are, though. It seems to me that their role is basically to pattern match? They are probably used to implement regex, for example?

Have any of you used these in the real world?

I use DFAs very extensively in a project of mine. It's an algorithm for calculating how far from winning a hand in riichi mahjong is. The straightforward implementation of that algorithm is recursive with a ridiculous amount of branching out, really slow. Other implementations use huge lookup tables (in the order of gigabytes) or medium sized lookup tables coupled with a small amount of recursion. My implementation basically takes a multi layered lookup table approach and instead of actually using lookup tables, I convert those into highly compressed DFAs. I got it down to a few of megabytes and no recursion at all.

In short: DFAs can be very useful when compressing data of the "words in a language" type.

There are plenty of other resonable applications though.

Working in AI there are about a billion uses for DFAs and NFAs. Not only that, but they are but a few of many graph-based formalisms for decision-making, and if you generalize these to Markov Decision Processes, you open a giant world of state-of-the-art research that is applied in all kinds of current applications from Siri to self-driving cars.
FO-nTTaX
Profile Blog Joined January 2013
Johto4982 Posts
October 09 2017 15:17 GMT
#18165
Hey everyone, as I'm aware we have a nice little programming community here, I want to drop this link in here: http://www.teamliquid.net/forum/general/527528-liquipedia-is-hiring
Administrator@FO_nTTaX | FO-nTTaX.de | 0xff0000.dev | Senior Lead Liquipedia Developer
"Nimm es. Es ist nicht viel, aber es kommt von Herzen. Vergiss mich nicht!"
waffelz
Profile Blog Joined June 2012
Germany711 Posts
October 09 2017 17:18 GMT
#18166
On October 06 2017 23:02 travis wrote:
We are learning about, and implementing in our latest project, DFAs and NFAs. I think they are pretty interesting and I was surprised I had literally never heard of them.

The professor never really told us what their applications are, though. It seems to me that their role is basically to pattern match? They are probably used to implement regex, for example?

Have any of you used these in the real world?


*cough cough* compilers *cough cough*

In general there is Chomsky hierarchy, which you either already learned about or probably are going to learn about, which covers all of the classic compiler phases (and more). Your idea with regex for example was spot on. Regex is short for regular expressions, often used as a keyword for its function in programming languages, which is FSA in action. It is also an own category / set or subset in Chomsky’s hierarchy.
There are 4 sets in Chomsky’s hierarchy (3 if you only count languages / grammars), whereby each set is including the previous set. Regular-expressions (not a language yet, which is why you will read about the 3 models for description of language) -> context-free grammar -> context-sensitive grammar -> recursively enumerable.
Which means regular expressions are part of context-free grammar which is part of context-sensitive grammar…

Each of these sets get covered by an automata theory, and all but the last are usually featured in compiler theory:
Regular expressions - this gets covered by FSA (DFAs and NFAs) as stated, in compiler theory this is used by the lexer (which basically matches pattern, so again: spot on).
Context-free grammar - this gets covered by pushdown Automata and is used in compiler theory when building a parser.
Context-sensitive grammar - this gets covered by linear bounded automata and basically covers a programming languages as a whole and in execution.
Recursively enumerable - this gets covered by Turing machines, but doesn’t have to come up in compiler theory.
RIP "The big travis CS degree thread", taken from us too soon | Honourable forum princess, defended by Rebs-approved white knights
Manit0u
Profile Blog Joined August 2004
Poland17733 Posts
October 11 2017 08:23 GMT
#18167
On October 10 2017 00:17 FO-nTTaX wrote:
Hey everyone, as I'm aware we have a nice little programming community here, I want to drop this link in here: http://www.teamliquid.net/forum/general/527528-liquipedia-is-hiring


Heh, I wish I could move

And speaking of job offers. This one looks pretty amazing too:
https://stackoverflow.com/jobs/156766/python-php-elasticsearch-developer-usamm-armed-forces-super
Time is precious. Waste it wisely.
FO-nTTaX
Profile Blog Joined January 2013
Johto4982 Posts
October 11 2017 08:53 GMT
#18168
On October 11 2017 17:23 Manit0u wrote:
Show nested quote +
On October 10 2017 00:17 FO-nTTaX wrote:
Hey everyone, as I'm aware we have a nice little programming community here, I want to drop this link in here: http://www.teamliquid.net/forum/general/527528-liquipedia-is-hiring


Heh, I wish I could move

And speaking of job offers. This one looks pretty amazing too:
https://stackoverflow.com/jobs/156766/python-php-elasticsearch-developer-usamm-armed-forces-super

Ah Elasticsearch is a beast, we use it on Liquipedia ^^
Administrator@FO_nTTaX | FO-nTTaX.de | 0xff0000.dev | Senior Lead Liquipedia Developer
"Nimm es. Es ist nicht viel, aber es kommt von Herzen. Vergiss mich nicht!"
Manit0u
Profile Blog Joined August 2004
Poland17733 Posts
October 11 2017 20:55 GMT
#18169
On October 11 2017 17:53 FO-nTTaX wrote:
Show nested quote +
On October 11 2017 17:23 Manit0u wrote:
On October 10 2017 00:17 FO-nTTaX wrote:
Hey everyone, as I'm aware we have a nice little programming community here, I want to drop this link in here: http://www.teamliquid.net/forum/general/527528-liquipedia-is-hiring


Heh, I wish I could move

And speaking of job offers. This one looks pretty amazing too:
https://stackoverflow.com/jobs/156766/python-php-elasticsearch-developer-usamm-armed-forces-super

Ah Elasticsearch is a beast, we use it on Liquipedia ^^


Yeah. Only got to work with it once though.
Time is precious. Waste it wisely.
Manit0u
Profile Blog Joined August 2004
Poland17733 Posts
October 12 2017 11:04 GMT
#18170
Guys, I need help...

Can you think of possible reasons why triggers would stop working in the db (postgres)?

I've checked, they're there. Functions are there. Definitions are in place. They just don't fire.

Checked locally with same schema, triggers are fired. On the server, not at all.
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
October 12 2017 22:22 GMT
#18171
On October 12 2017 20:04 Manit0u wrote:
Guys, I need help...

Can you think of possible reasons why triggers would stop working in the db (postgres)?

I've checked, they're there. Functions are there. Definitions are in place. They just don't fire.

Checked locally with same schema, triggers are fired. On the server, not at all.



Figure it out? I'm sure you checked all the easy stuff, looks like triggers can stop firing if one returns null, was a new one introduced?
Manit0u
Profile Blog Joined August 2004
Poland17733 Posts
October 13 2017 06:29 GMT
#18172
On October 13 2017 07:22 berated- wrote:
Show nested quote +
On October 12 2017 20:04 Manit0u wrote:
Guys, I need help...

Can you think of possible reasons why triggers would stop working in the db (postgres)?

I've checked, they're there. Functions are there. Definitions are in place. They just don't fire.

Checked locally with same schema, triggers are fired. On the server, not at all.



Figure it out? I'm sure you checked all the easy stuff, looks like triggers can stop firing if one returns null, was a new one introduced?


One was updated. Thankfully it wasn't in production yet so we could just drop and recreate the DB (it works fine now) because of lack of time to figure it out properly.
Time is precious. Waste it wisely.
Wrath
Profile Blog Joined July 2014
3174 Posts
October 13 2017 19:41 GMT
#18173
Hi guys, I need a little help here,

I'm learning JavaEE (EJBs at the moment). I'm following this tutorial:https://www.tutorialspoint.com/ejb/ejb_create_application.htm

The tutorial uses JBoss 5.0.1. I used Wildfly 10 instead.

I'm having an issue with the JNDI.properties part:

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost


When I try to run I get this:

javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
null
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at com.tutorialspoint.test.EJBTester.<init>(EJBTester.java:38)
at com.tutorialspoint.test.EJBTester.main(EJBTester.java:47)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672)
... 5 more
java.lang.NullPointerException
at com.tutorialspoint.test.EJBTester.testStatelessEjb(EJBTester.java:61)
at com.tutorialspoint.test.EJBTester.main(EJBTester.java:49)


For some reason it is not able to find the org.jnp.interfaces.NamingContextFactory. I downloaded JFind to find it under wildfly installation but no luck. So I downloaded "jnp-client.jar" which contains org.jnp.interfaces.NamingContextFactory. Still, it can't find it. I added the path to the jnp-client.jar to the CLASSPATH, restarted wildfly and still it can't find it.

Any idea why this is happening?
berated-
Profile Blog Joined February 2007
United States1134 Posts
October 13 2017 21:53 GMT
#18174
On October 14 2017 04:41 Wrath wrote:
Hi guys, I need a little help here,

I'm learning JavaEE (EJBs at the moment). I'm following this tutorial:https://www.tutorialspoint.com/ejb/ejb_create_application.htm

The tutorial uses JBoss 5.0.1. I used Wildfly 10 instead.

I'm having an issue with the JNDI.properties part:

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost


When I try to run I get this:

javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
null
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at com.tutorialspoint.test.EJBTester.<init>(EJBTester.java:38)
at com.tutorialspoint.test.EJBTester.main(EJBTester.java:47)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672)
... 5 more
java.lang.NullPointerException
at com.tutorialspoint.test.EJBTester.testStatelessEjb(EJBTester.java:61)
at com.tutorialspoint.test.EJBTester.main(EJBTester.java:49)


For some reason it is not able to find the org.jnp.interfaces.NamingContextFactory. I downloaded JFind to find it under wildfly installation but no luck. So I downloaded "jnp-client.jar" which contains org.jnp.interfaces.NamingContextFactory. Still, it can't find it. I added the path to the jnp-client.jar to the CLASSPATH, restarted wildfly and still it can't find it.

Any idea why this is happening?


That tutorial looks like it was written for java ee 5 or so and you are trying to use a container that is meant for use with java ee 7. Is there any particular reason you are trying to use that exact tutorial?

Which version of Netbeans / java are you using?
Wrath
Profile Blog Joined July 2014
3174 Posts
Last Edited: 2017-10-14 06:34:19
October 14 2017 06:28 GMT
#18175
Using Java 1.8 / Netbeans 8.2

Edit: I'm using that tutorial because it is the one I find, and tutorialspoint has a lot of great tutorials for free. Except that most of them are outdated....
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2017-10-14 13:30:02
October 14 2017 13:21 GMT
#18176
On October 14 2017 15:28 Wrath wrote:
Using Java 1.8 / Netbeans 8.2

Edit: I'm using that tutorial because it is the one I find, and tutorialspoint has a lot of great tutorials for free. Except that most of them are outdated....


Are you learning wildfly for a reason either? I haven't done EE tutorials in a long while, but, usually the java docs themselves are pretty good. If you're using netbeans and trying to learn base EE then sticking with glassfish might be easier too.

I'll try doing your combo real quick with wildfly that tutorial / netbeans and let you know what I find but, if you're using those other containers for no reason other than that's what suggested .. sticking with the reference implementation stack (netbeans / glassfish and their associated) could be quicker.

Edit : Certainly not trying to deter your learning, or avoid your question. It's just there are a lot of quirky things with using different versions of all the of different implementations. Java EE is just a spec, and there are multiple companies that become certified. Trying to swap out parts of the reference implementation (oracle/glassfish .. the stuff that comes with netbeans) with redhat's stuff (jboss/wildfly) is certainly doable, but, requires more tinkering.

I've been doing EEish dev (more spring and other frameworks than pure EE) and have made it to architect / director level and it would still take me some time to make sure that using some of each works correctly.
Wrath
Profile Blog Joined July 2014
3174 Posts
October 14 2017 14:40 GMT
#18177
I'm using wildfly as it is a more modern version of JBoss, the mentioned server in the tutorial. I just did not expect that things would be that off between Java 1.5 and 1.8. Also, as Netbeans is an IDE it should produce the same result, heck even if I replaced it by eclipse should be the same.

Do you have any more modern EJB tutorials? I'd like to be comfortable with basic JavaEE before moving to other frameworks like Spring and MVC.
berated-
Profile Blog Joined February 2007
United States1134 Posts
October 14 2017 15:02 GMT
#18178
On October 14 2017 23:40 Wrath wrote:
I'm using wildfly as it is a more modern version of JBoss, the mentioned server in the tutorial. I just did not expect that things would be that off between Java 1.5 and 1.8. Also, as Netbeans is an IDE it should produce the same result, heck even if I replaced it by eclipse should be the same.

Do you have any more modern EJB tutorials? I'd like to be comfortable with basic JavaEE before moving to other frameworks like Spring and MVC.


I'm looking and trying to get that tutorial point thing to work. It's mostly true what you're saying about the IDEs except that netbeans is doing a whole lot of work that you may or may not even be aware of when it starts the application server. It may take a bit cause honestly I'm not all that familiar with remote jndi so I'll let you know in a bit if I can get this thing working and what tutorials I used. It looks like in netbeans they had some samples (under new -> project), I'm not sure if any of those would help.

Spring/MVC is kind of a different world than Java EE. IMO and others can disagree but they are two different approaches to solving the same problem. EE depends heavily on the container providing you with a lot of the tools/configuration where as spring usually configures most things in the application itself.

I personally find the spring route much easier, but, I've also been doing it. But that's really tangental to the point at hand ... alright , trying to get this thing working.
berated-
Profile Blog Joined February 2007
United States1134 Posts
October 14 2017 15:28 GMT
#18179
Alright, so I followed the first part of their tutorial almost exactly. Just picked glassfish as my application server. Didn't really detour too much from it. Built it, deployed it.

For the second part, I just did, new -> project, picked Enterprise Application Client.

And then I had to modify their file to this


package com.tutorialspoint.test;

import com.tutorialspoint.stateless.LibrarySessionBeanRemote;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import javax.naming.InitialContext;
import javax.naming.NamingException;


public class EJBTester {
BufferedReader brConsoleReader = null;
InitialContext ctx;
{
try {
ctx = new InitialContext();
} catch (NamingException ex) {
ex.printStackTrace();
}
brConsoleReader =
new BufferedReader(new InputStreamReader(System.in));
}
public static void main(String[] args) {

EJBTester ejbTester = new EJBTester();

ejbTester.testStatelessEjb();
}
private void showGUI(){
System.out.println("**********************");
System.out.println("Welcome to Book Store");
System.out.println("**********************");
System.out.print("Options \n1. Add Book\n2. Exit \nEnter Choice: ");
}
private void testStatelessEjb(){
try {
int choice = 1;
LibrarySessionBeanRemote libraryBean =
(LibrarySessionBeanRemote)ctx.lookup("com.tutorialspoint.stateless.LibrarySessionBeanRemote");
while (choice != 2) {
String bookName;
showGUI();
String strChoice = brConsoleReader.readLine();
choice = Integer.parseInt(strChoice);
if (choice == 1) {
System.out.print("Enter book name: ");
bookName = brConsoleReader.readLine();
libraryBean.addBook(bookName);
}else if (choice == 2) {
break;
}
}
List<String> booksList = libraryBean.getBooks();
System.out.println("Book(s) entered so far: " + booksList.size());
for (int i = 0; i < booksList.size(); ++i) {
System.out.println((i+1)+". " + booksList.get(i));
}
LibrarySessionBeanRemote libraryBean1 =
(LibrarySessionBeanRemote)ctx.lookup("com.tutorialspoint.stateless.LibrarySessionBeanRemote");
List<String> booksList1 = libraryBean1.getBooks();
System.out.println(
"***Using second lookup to get library stateless object***");
System.out.println(
"Book(s) entered so far: " + booksList1.size());
for (int i = 0; i < booksList1.size(); ++i) {
System.out.println((i+1)+". " + booksList1.get(i));
}
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}finally {
try {
if(brConsoleReader !=null){
brConsoleReader.close();
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
}


It's a bit of a shortcut, but , when I clicked run in the main file , it deployed it to the same application server that the EJB module was running in. Therefore, we didn't need to do a remote InitialContext, we could just construct a new one. I also had to change how I looked up the remote bean, as it didn't store it as the other tutorial did.

I was then able to get their output and add books.
Wrath
Profile Blog Joined July 2014
3174 Posts
October 14 2017 15:34 GMT
#18180
Not sure if I get it right... You made a enterprise application client and deployed to the server. Thus the client called the server from within the server? I'm still learning what is the InitialContext is so not sure what is the different between using here within the code or use it via jndi.properties. Sorry I'm still beginner
Prev 1 907 908 909 910 911 1032 Next
Please log in or register to reply.
Live Events Refresh
PSISTORM Gaming Misc
15:55
FSL s10 playoff replays
Freeedom16
Liquipedia
Ladder Legends
15:00
Valedictorian Cup #1
Solar vs GgMaChine
Bunny vs Cham
ByuN vs MaxPax
SteadfastSC144
Liquipedia
WardiTV Map Contest Tou…
11:00
Playoffs Day 4
Clem vs SHINLIVE!
MaxPax vs TBD
WardiTV1825
IntoTheiNu 833
TKL 618
Ryung 309
IndyStarCraft 287
Rex130
3DClanTV 121
EnkiAlexander 83
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 607
Ryung 309
IndyStarCraft 287
SteadfastSC 144
Rex 127
Railgan 105
BRAT_OK 60
EmSc Tv 16
StarCraft: Brood War
Calm 3778
Horang2 580
firebathero 313
Mini 284
ggaemo 191
zelot 57
Sexy 37
Rock 30
Dewaltoss 21
Sacsri 19
[ Show more ]
Terrorterran 18
IntoTheRainbow 15
SilentControl 13
GoRush 10
Dota 2
qojqva2845
Counter-Strike
byalli1120
Super Smash Bros
Mew2King114
Heroes of the Storm
Khaldor1189
Liquid`Hasu517
MindelVK9
Other Games
singsing2254
Grubby1187
FrodaN1138
B2W.Neo1083
Beastyqt981
XBOCT348
crisheroes269
mouzStarbuck228
QueenE130
KnowMe56
Organizations
Other Games
gamesdonequick422
BasetradeTV235
StarCraft 2
angryscii 20
EmSc Tv 16
EmSc2Tv 16
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• OhrlRock 1
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• 80smullet 12
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Jankos1876
• Nemesis1541
Other Games
• imaqtpie648
• WagamamaTV413
• Shiphtur153
Upcoming Events
BSL
1h 47m
CranKy Ducklings
6h 47m
Replay Cast
15h 47m
Wardi Open
16h 47m
Afreeca Starleague
16h 47m
Soma vs hero
Monday Night Weeklies
22h 47m
Replay Cast
1d 6h
Replay Cast
1d 15h
Afreeca Starleague
1d 16h
Leta vs YSC
Replay Cast
3 days
[ Show More ]
The PondCast
3 days
KCM Race Survival
3 days
Replay Cast
4 days
Replay Cast
4 days
Escore
4 days
Replay Cast
5 days
Replay Cast
5 days
IPSL
5 days
Ret vs Art_Of_Turtle
Radley vs TBD
BSL
6 days
Replay Cast
6 days
uThermal 2v2 Circuit
6 days
Liquipedia Results

Completed

Escore Tournament S2: W4
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W5
KK 2v2 League Season 1
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.