Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Abhijit Rai

Ranch Hand
+ Follow
since Aug 07, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Abhijit Rai

I am trying to explore Java in depth regarding implementation details in Java :
"How are classes such as linked list,Stack,Array ,HashMap ,HashTable are implemented ,which data structures are used ,which memory is used ,how does java interact with the OS and the like ".
Please do flood me with links , resources or books which could help me in getting to the bottom of these issues.
8 years ago
Hi all,

I have a website containing top secret "eyes only " stuff,so to protect its contents I use java authentication.
I am able to authenticate the user properly and every thing works fine.
Where I am stuck is logging out a user once the user is authenticated.
I believe that the problem is in web browser caching and have tried a few things which did not work .
My top military general is annoyed as hell and I would be his Basset Hound 's dinner if the issue is not solved.
Here is the code listing :





The problem might be because the request being sent by my browser contains a Principal with the corresponding username and password . I dont want to go the java script way and am trying for a complete java solution.

Thanks for having a peek

8 years ago

You are totally wrong

kindly do explain ...
8 years ago
You could invalidate the session in the login.jsp page itself ,this could be done by
8 years ago
Hey Cameron,
Thanks mate ,awesome reply ,was like a beautiful sun ray tearing the dark clouds away .
The link was quite useful too . Just as you did I added a main method in my Cabin class and it works like a charm .

Also the Hibernate configuration xml looks like :

Thanks again , Cheers
Hi ,
I am of the view that JPA may be used for standalone applications (i.e. even without a server(web/application)),
dragged along by this belief I ventured along to make an application

I made an entity class :Cabin

and a client class: StandaloneClient

also I have persistence.xml within META-INF in my classpath

and all I get is a Fat exception :

Is it possible to use JPA the way I want to use it . If yes ,how do we get over this exception( does any one have the postal address for the Persistence provider ) .
Thanks everyone for helping out
To access any database Using JDBC follow these steps :
1.Make sure the RDBMS server is up and running correctly.
2.Find out on which port the RDBMS server is .
3.Make sure that the relevant JDBC driver (for you RDBMS ) is present and in class path.

Once these steps are followed write a Java class to access the DB. The steps to be followed in the Class are:

1.Register the JDBC driver for your RDBMS
2.Define URL of database server for your database on the localhost with the relevant port number( default :3306)
save it in a String .

3.Get a connection to the database.

4.Get a Statement object eg:

5.Execute commands on that statement object.

6.Get a ResultSet back

7. Close everything:

Below is a sample ,I am using mySQL database named javatest,

Hi Mark,

When you set up a JDBC datasource on an application server, at least in my experience, you must give a JNDI name to that datasource.

You can access a database with the JDBC API without using JNDI ,but yes when it comes to datasource you have to use some naming service,I too have used JNDI.
As for the question ,
There are many reasons that according to the specification, one should also specify the <resource-ref> in web.xml. One of the most important reasons is the scope of the DataSource being used.

. . .
. . .

You can read more about that in the following thread
8 years ago

Ulf Dittmer:
So if you've enjoyed using the Roundup in the past, this is your chance to give back a little to make it even better...

Any place we could drop questions for the new RoundUp Version
Although it is fine to leave a method blank ,it may be useful if you declare the method inside an interface and implement that interface in your class as blank method.
This way it would be clear that the method was meant to be implemented as a blank method rather than it being left blank by mistake .
8 years ago
An add on issue ,
I am trying to make the HelloUser interface Local ie

public interface HelloUser {
public void sayHello(String name);

I also changed to


The excepiton I get is :

javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Unresolved address [Root exception is Unresolved address] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is jnp://localhost:1099: jnp://localhost:1099]]]
at org.jnp.interfaces.NamingContext.checkRef(
at org.jnp.interfaces.NamingContext.lookup(
at org.jnp.interfaces.NamingContext.lookup(
at javax.naming.InitialContext.lookup(Unknown Source)
at com.ejb3inaction.actionbazaar.HelloUserClient.main(
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is jnp://localhost:1099: jnp://localhost:1099]]
at org.jnp.interfaces.NamingContext.getServer(
at org.jnp.interfaces.NamingContext.checkRef(
... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is jnp://localhost:1099: jnp://localhost:1099]
at org.jnp.interfaces.NamingContext.getServer(
... 5 more
Caused by: jnp://localhost:1099: jnp://localhost:1099

What changes should be done (I guess to access the bean locally ?

Thanks all for helping out .

Thanks a lot guys ,
Got it working now with your help .As you pointed out the trouble was that I did not have in classpath .

So the working solution can be listed as :

Step 1.
Create ""
package com.ejb3inaction.actionbazaar;
import javax.ejb.Remote;
public interface HelloUser {
public void sayHello(String name);

Step 2.
Create ""
package com.ejb3inaction.actionbazaar;
import javax.ejb.Stateless;
public class HelloUserBean implements HelloUser {
public void sayHello(String name) {
System.out.println("Hello " + name + " welcome to EJB 3 In Action!");

Created a client class "HelloUserClient"

package com.ejb3inaction.actionbazaar.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.ejb3inaction.actionbazaar.buslogic.HelloUser;
import com.ejb3inaction.actionbazaar.buslogic.HelloUserBean;

public class HelloUserClient {
private static HelloUser helloUser;
public static void main(String[] args) {
try {
Context context = new InitialContext();
helloUser = (HelloUser) context.lookup(“HelloUserBean/remote");
helloUser.sayHello("Obama ");
} catch (NamingException e) {

Step 4.
Create in the souce folder (src folder)


Step 5.
Deploy the code ,start the server and run the client as a standalone java application.

Don’t forget to include jBossall-client.jar ,without it ClassNotFound exception is thrown .

thanks and cheers
Couldnt find it there mate am searching the net for it .
Hi could you provide some additional info :
1.Whether the project is a web application deployed on the server or a standalone java apllication
2.In case of it being a web application ,the directory structure of the application , present in the server where it is deployed.
8 years ago
Ernest rightly pointed out that there is no semi colon instruction .My description was intended to help figure out what exactly is happening logically .I have erred on the technical part though .For better understanding of the language I would suggest that you go through any good Java book ,find them at find here - list of beginers java books.
8 years ago