J2EE problem

T

Taki

Hi everyone,

I'm new in J2EE, so my problem might be an easy one,
but I'm stuck for days.

I'm developing an online game that 2 players interact
with each other in applets. For 2 players to interact,
I have a game (POJO) class stored in JNDI so that 2 players
can interact with each other through it. I implemented
the observer pattern between the game class and player class
(player is observer, game is observable),
but I am having problems:

1. J2EE server (I'm running JBoss) wants all the classes used
directly or indirectly by game class to be packaged in a jar file.
This includes all the GUI files that are not serializable.
I want a clear separation between server side components and
client side components.

2. Because of the problem above, I declared all GUI components as
transient. Now, this is giving me another problem. The update method
in player class uses transient attributes (call a method on them etc).
However, the game object generates null poitner exception (I think it's
because the attributes are declared as transient).


I am not even sure I'm designing this in a right way, but if
someone can give me some advice, I would really appreciate it.

I'm running Jboss3.2.3 with tomcat, and client talks to a session bean
directly (doesn't go though a servlet).

Thanks in advance

Taki
 
A

adhirmehta41

Hi friend
ur going in wrong manner. first thing is that u don't need to put your
gui file in jar file because any j2ee server don't concern with
application. u need to package only server side file into jar file. on
the client side u will have to keep up gui files in a classpath so
that your client application can use it.
So u don't need to declare transient.
 
J

John C. Bollinger

Taki said:
Hi everyone,

I'm new in J2EE, so my problem might be an easy one,
but I'm stuck for days.

I'm developing an online game that 2 players interact
with each other in applets. For 2 players to interact,
I have a game (POJO) class stored in JNDI so that 2 players
can interact with each other through it. I implemented
the observer pattern between the game class and player class
(player is observer, game is observable),
but I am having problems:

1. J2EE server (I'm running JBoss) wants all the classes used
directly or indirectly by game class to be packaged in a jar file.
This includes all the GUI files that are not serializable.
I want a clear separation between server side components and
client side components.

2. Because of the problem above, I declared all GUI components as
transient. Now, this is giving me another problem. The update method
in player class uses transient attributes (call a method on them etc).
However, the game object generates null poitner exception (I think it's
because the attributes are declared as transient).

Relieve the game class of dependencies on the GUI stuff instead of
making the GUI references transient. Best use of the Observer /
Observable pattern would involve defining Observer as an interface that
client-side objects can implement; that makes the observable (game class
or related class) independant of the actual Observer implementations.

The part about transient references causing NullPointerExceptions sounds
like you are either intentionally or inadvertently serializing instances
of your game class or related classes; this would likely happen if you
are sending objects over RMI, for instance.


John Bollinger
(e-mail address removed)
 
T

Taki

John C. Bollinger said:
Relieve the game class of dependencies on the GUI stuff instead of
making the GUI references transient. Best use of the Observer /
Observable pattern would involve defining Observer as an interface that
client-side objects can implement; that makes the observable (game class
or related class) independant of the actual Observer implementations.

Yes, that's what I want to achieve. I don't want any GUI stuff on the
server side.
My observer interface isn't concerned with any GUI stuff at all; the class
that
implements the interface does the GUI stuff. I don't know how I can get rid
of
all the GUI dependencies. For example, I want to update the view when
server notifies. Even if a observer class being sent (registered) to a
server doesn't use
any GUI, when a server calls update() on the observer, observer will have to
somehow and
eventually call GUI's method, which indicates that the update() method has
to call
a GUI's method directly or indirectly. To call a GUI's method, a class
called by an observer
has to have a reference. Since JBoss seems to require all the classes that
directly or
indirectly called by the class that I want to store in JNDI, I have to put
the GUI
class in jar, too.
The part about transient references causing NullPointerExceptions sounds
like you are either intentionally or inadvertently serializing instances
of your game class or related classes; this would likely happen if you
are sending objects over RMI, for instance.

Yes, I am using RMI.

I don't know if I explained it well, but if any of you can give me some
help, that would be
great.

Thanks in advance

Taki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top