Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!

De La Hai

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

Recent posts by De La Hai

Hello !

I have a *.mdb file deployed within my ear. Which is located on Glassfish server like this:

MyApplication
- myDBFile.mdb
- myApplication-ejb_jar
- myApplicationWeb_war
- META-INF

The problem is that from EJBs perspective you can only use ClassLoader.getSystemResource(path) or equivalents of ClassLoader.methods.

However this leads me to deploy the .mdb database within a Jar. in my EJB project.

I would like to have it stored in EarContent of my project and access it from there. Is there any possibility to access files that are deployed along the ear from ejb context ?

I tried to get the context path of the ejb session , by using
but this doesn't really help much, as it only points to a path on the server and not on my project.

Can someone help me out, or point out whats wrong with the idea ?

Best regards,

LHD

PS: I know that it is against the restrictions of EJB, to access files in the filesystem. But it's more convenient to have the mdb file deployed within the ear for me.
okok , I have noticed my misunderstanding ... :p ... nevermind my stupid posts ;)
Hello,

My Server is Glassfish v2 can you tell me where I can put my DB file ? In which Folder can I put my file in order to read it from my EJB ? or is it even possible to read it from the EJB ? or is the EJB (SFSB) bound in anyway to a namespace on the server ?



This is the code which is called from my SFSB ... for this instance , where do I have to put my DB.file on ?

Thanks in advance
Hello !

I am trying to deploy a *.mdb file along my ear-project on the glassfish server. But I have no clue how to do it ... . Obviously just hanging the mdb-file to the ear-project // ejb project doesn't work.

Can someone tell me what is the general method to deploy a MS Access Database along with your EAR-Project ?

Unfortunately I need to use MS Access....
Hi Marco ,

I am using this Stateless Bean as a workaround I guess , because I just want to acces my EJB Layer by a WEB Client. By this I mean that my application will start with a startpage, from which the user invokes some action . A Stateful Session Bean should be created for him/her and then he can work with it. .. Since the client requests a SFB through a Servlet , hence the Servlet is processed on the serverside in may be the same thread/object, which leads to the problem that I have described. My workaround is that you use the Stateless Bean as an entry point for invocation ... . In the EJB Container , the Stateless Bean creates a new Instance of a Stateful Bean and returns it ...

When I get it by an Servlet I have to lookup/ or inject the EJB Object somewhere ... either as an class variable or in the doGet or doPost methods (lookup) ... in both cases the Servlet is the same in the WEB COntainer right ? so I will always get the same reference...

I don't see how I can get a new Reference from a servlet/jsp when the only way is to call lookup or injection ...

passing the referenced SFB in the Session is not the issue here i guess because the first reference I get is already the same reference shared by the clients ....

Thats why I'm using this workaround ... but honestly this method is not good i can see it by myself ... But just a question by curiosity , how do you normaly get your SF Session ???

Or am I missing something from your post above ??? Sry if I have missed it though

Thanks

LHD

PS: Isn't it a basic problem ? Shouldn't everybody have used SFSB already ??? how is it done correctly ?
Hello

ok now I have figured it out , since those examples you find on the internet are such misleading , I was kinda stucked, since I believed that these are the suggested ways how to call a SFB ...

I have understood the Servlet problem now and had implemented my test application in this way :

Since I only want to have a WEB APP for accessing my EJB APP

I had declared a Stateless Session Bean , which creates on Server Side the SFB and returns me the Reference of it ...

In my Servlet class I just called the Stateless Bean and get the Reference for my SFB and work with it ... passing it with the Http Session etc...


Is this an appropriate solution ??? what do you think is better ??


Thank you very much for your help

LHD
For example this code :



If I am trying this I would always get the same reference of the EJB "foo" ... . Isn't it the correct way how to get an EJB ?
the Code is from : http://javahowto.blogspot.com/2007/07/simple-ejb-3-servlet-application.html

Or hasn't the author just not thought of this problem ?

thanks


The easiest way to test this is probably to move the SFB reference into session scope and don't maintain it in the servlet!



I get the point but I don't know how I should implement this . What do you mean by session scope ? which session scope ? Can you give me some example code for my problem ?

thank you

LHD
Hello again,

just one thing I am wondering about : How should you design your WEB Client ? If it shouldn't be the way I have done ... ?

I have followed Suns EJB Tutorial and then came to this problem ... how do you do it ? As with my understanding , I have created an EAR project then bind a EJB and dynamic web application to it , with dynamic web application being dependant on EJB's Jar (J2EE Dependencies)...
So by this you mean that I am only accessing the same servlet everytime ? I am running my ejb-application and my web-application on localhost so it is difficult for me to test it with multible clients, I have just created request via different browser client etc... But anyways, how can I test it properly ?

Also to my little experience with Servlet/JSP , if I understand you correctly . Each time I access my Servlet the Servlet will be processed in a thread on my server, and even with my multiple browsers the same servlet is being called ? May this be the reason why everytime the same SFB-Reference is assigned to my client ? ...

I will test it right away... but any more hints are still appreciated

Thank you

LHD
Hello,

In my current project I am facing a strange problem: whenever I want to get my Stateful Session Bean remote object , I get always the same reference. So all clients get the same remote object on server side ... which is of course not the incentive by the Stateful Session Beans model...

I have written a small test application which behaves exactly the same as my projects application ...

here the code :
the SFSB : testBean


the Remote Interface: testRemote



the test JSP



Also I am using Eclipse Europe Winter IDE & Glassfish v2

Everytime it returns the same reference for the SFSB Object , ... I don't know why this happens ... is it a fault by me or is it a Bug on Server Side ??

I just don't know ... ... I also tried it with Servlet Injection but the result is the same , I guess it's my fault but I have no clue how to solve it ...

thanks in advance ...

LHD