EJB Helper class not created
Dear Sirs,
I am following the example in the "Enterprise Java Beans manual" to use Jdeveloper to create the Hello World EJB described in appendix B.
My EJB is deployed successfully but when I run the client I get "ClassNotFoundException: hello.HelloHomeHelper".
I imagine that the computer is trying to load the HelloHomeHelper.narrow method to properly case the call to the create method of my EJB. But such class only gets created when you use the wizard "Generate CORBA Server classes". But I cannot do that since I am not extending org.omg.CORBA.Object object. Rather the EJB I am implementing implements the "SessionBean".
So why I am having CORBA-related problems with EJB?
thanks.
Hi,
I have the same problem with bc4j deployed on Oracle 8.1.7 as session EJB.
I'm testing the deployed bc with a client code. I have the following problem on the lookup method:
avax.naming.NamingException: Unknown reasons. Root exception is
java.lang.ClassNotFoundException: vebs.jbo.common.ejb.VeAppModuleHomeHelper
void oracle.jbo.client.remote.ejb.aurora.AuroraEJBAmHomeImpl.initRemoteHome()
void oracle.jbo.client.remote.ejb.aurora.AuroraEJBAmHomeImpl.<init>(oracle.jbo.JboContext, java.lang.String)
oracle.jbo.common.JboHome oracle.jbo.client.remote.ejb.aurora.AuroraEJBInitialContext.createJboHome(java.lang.String)
java.lang.Object oracle.jbo.common.JboInitialContext.lookup(java.lang.String)
java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
void bctest.main(java.lang.String[])
but if I see in the Oracle db, the class is exported.
Help me!!
Similar Messages
-
Javax ejb CreateException: Could not create stateless EJB
Hi,
I have a JavaEE (EJB3.0) project deployed on glassfish2.1 as -.ear (exported from eclipse3.4 to the autodeploy-folder) with -.ejb.jar, -.webui.war, general-lib-base.jar (some other...)
The session bean is invoked by a jsf-managed bean. Have a pure annotation +@ejb+ in managed bean (identifiing the ejb-interface (+@Remote+) ...the ejb is annotated with +@stateless+
get the following error message:
*...nested exception is: javax.ejb.CreateException: Could not create stateless EJB*
as beginner in the JavaEE-field I'm looking for some help concerning the possible causes.
thank's for any comment...
(also posted in the Enterprise JavaBeans-forum possibly better there)problem fixed: in the deployment-descriptor ejb-jar.xml a spezification of the session-bean hung around ...very annoying!
-
Obtaining principal in EJB helper classes
I have a pretty typical EJB setup where the actual EJBs delegate a lot of work
off to helper classes which are simple java classes. Some of these helpers need
access to the principal currently executing on this container thread. Currently,
I am passing the principal as a parameter in every method signature on the helpers
which need it. But as you can probably guess that approach is quickly becoming
unweildy.
Ideally, what I would like to do is to have access to the principal associated
with the currently executing thread. I can mimic this by setting thread-local
variables in the EJB prior to calling helpers. But I was wondering (ok, hoping)
that there was already a way to access this information (either through weblogic
classes or MBeans). At this point, I dont even care if it is not portable.
P.S., I use WL6.1
Thank you in advance,
Steve>
The helper methods do database querries etc and return results that the EJB sends onwards to clients. If these methods
are NOT synchronized (and the ejbs share the static class) won't it cause concurrency errors? I think most of our methods are not
synchronized (and it doesn't seem to cause any concurrency errors so far... though the system have not beeen stressed test that much,
and concurrency bugs tends to pop up later and randomly :P).
>
No, if you dont have any static data variables in the Java classes, static method as such will not cause concurrency errors, and the methods should not be synchronized.
If you have any synchronized methods and they take a while to execute, that could become a bottleneck in itself, because different threads waiting for each other,
so make sure you dont have any synchronized methods where it is not explicitly needed.
Think of a static method (without static data in the class being manipulated) as a plain function in another programming-language.
>
We have some scaleability problems with the EJBs... It seems as if they do not run concurrently. If we do a stress test with several threads calling the EJBs their response time increases by a too large factor to feel comfortable...
>
Apparently, you do have a some scaling/concurrency problem, which could have many causes -- transaction locking and clashes in the database, poorly configured database, network congestion, problems in the EJB architecture, etc -- can be many reasons...
The general idea to debug, is first to find out exactly what calls in your code that take longest time to execute (profiling, logging, System.out.println's are useful) when you put parallel load on your system -- rather than just seeing "the whole application seems slow" -- from there you can move on, "divide&conquer" the problem, etc... -
Applet help, class not found?
hi all ! This is the first time I try a applet.
I have my applet declared in my JSP
<APPLET CODE = "AppletViewer.class" ARCHIVE = "MedPro.jar" WIDTH = "600" HEIGHT = "400">
/*creating space for better reading of the code*/ AppletViewer.class is part of a package called beans, and MedPro.jar is the jar generated when building the whole app.
Im getting in the applet "viewer" something like:
java.lang.ClassNotFoundException: AppletViewer.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:https://localhost:8443/MedPro/servlet/AppletViewer/class.class
Im using SSL to make the app secure, but what I dont get is why its not finding the class, isnt that independant from the connection? Plus the applet code is not asking for any connection atm. Im just trying to load it.
Any help is appreciated.
Thanks!
Edited by: juanmanuelsanchez on Jan 28, 2009 10:33 PM
Edited by: juanmanuelsanchez on Jan 28, 2009 10:33 PMwell what Im trying to do is to implement jasper reports in a viewer. So for that Im using
public class AppletViewer extends javax.swing.JApplet {
private javax.swing.JPanel pnlMain;
public AppletViewer()
throws ClassNotFoundException
initComponents();
private void initComponents() {//GEN-BEGIN:initComponents
pnlMain = new javax.swing.JPanel();
pnlMain.setLayout(new java.awt.BorderLayout());
getContentPane().add(pnlMain, java.awt.BorderLayout.CENTER);
}//GEN-END:initComponents
public void init()
public void ViewReport(String jasperFileName) throws net.sf.jasperreports.engine.JRException,javax.naming.NamingException,java.sql.SQLException,
java.net.MalformedURLException
/* HashMap hm = null;
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MedPro");
Connection conexion = ds.getConnection();
// Create arguments
// Map params = new HashMap();
hm = new HashMap();
// Generate jasper print
//JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(new URL(getCodeBase(), "../MedPro/Reportes/"));
JasperPrint jasperPrint = (JasperPrint) JasperFillManager.fillReport(jasperFileName, hm, conexion);
// JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(jasperFileName);
JRViewer viewer = new JRViewer(jasperPrint);
this.pnlMain.add(viewer, BorderLayout.CENTER);
}That class is part of a package called beans in a project called Medpro wich is compiled as a .WAR archive since its a webapp. The examples show a jar file instead wich is for libraries... so Im confused there. There is no documentation about it :(
I still get the error
java.lang.ClassNotFoundException: beans.AppletViewer.class I have tried everything, still nothing
Thanks for any help you guys can give me -
Button class not creating a button
Hi,
I have some AS3 code which I was hoping would create a
re-usable button class but it does not. I just get a blank canvas.
I am not getting any errors. Code is attached. Anyone see what is
wrong?thanks for the response.
to instantiate this class with the var code that you posted
and I reposted. Would this code be added to the .as file or would I
put that on frame 1 of the .fla file?
Also I want to create multiple buttons and position them on a
page within a grid. With the class code I have posted, how would I
go about doing that? Lastly, I want one of two movie clips to
display once the button is clicked. Can someone explain how I would
go about that as well?
thanks -
My application was designed based on MVC Architecture. But I made some changes to HMV base on my requirements. Servlet invoke helper classes, helper class uses EJBs to communicate with the database. Jsps also uses EJBs to backtrack the results.
I have two EJBs(Stateless), one Servlet, nearly 70 helperclasses, and nearly 800 jsps. Servlet acts as Controler and all database transactions done through EJBs only. Helper classes are having business logic. Based on the request relevant helper classed is invoked by the Servlet, and all database transactions are done through EJBs. Session scope is 'Page' only.
Now I am planning to use EJBs(for business logic) instead on Helper Classes. But before going to do that I need some clarification regarding Network traffic and for better usage of Container resources.
Please suggest me which method (is Helper classes or Using EJBs) is perferable
1) to get better performance and.
2) for less network traffic
3) for better container resource utilization
I thought if I use EJBs, then the network traffic will increase. Because every time it make a remote call to EJBs.
Please give detailed explanation.
thank you,
sudheer<i>Please suggest me which method (is Helper classes or Using EJBs) is perferable :
1) to get better performance</i>
EJB's have quite a lot of overhead associated with them to support transactions and remoteability. A non-EJB helper class will almost always outperform an EJB. Often considerably. If you plan on making your 70 helper classes EJB's you should expect to see a dramatic decrease in maximum throughput.
<i>2) for less network traffic</i>
There should be no difference. Both architectures will probably make the exact same JDBC calls from the RDBMS's perspective. And since the EJB's and JSP's are co-located there won't be any other additional overhead there either. (You are co-locating your JSP's and EJB's, aren't you?)
<i>3) for better container resource utilization</i>
Again, the EJB version will consume a lot more container resources. -
Add helper class public parts as used DC in EJB DC
Hi Experts,
I have created a JAVA DC project containing the helper classes.
For this helper classes i have created a Jar file.
I have also created two public parts
1) with an option Can be packaged into other build results (e.g. SDAs)
2) with an option Provides an API for developing/compiling other DCs
Now i want to use these public parts in my EJB DC.
I have added the API public part in my EJB DC as build time design time and run time.
Now when i am getting java.lang.NoClassDefFoundError: for the class defined in JAVA DC helper class.
Can you help me in resolving this?
Regards,
Ashish ShahHi
I have done following things:
1) I have a java DC containing helper classes and an EJB DC referring to it.
2) Now to access this EJB DC, I have created a java command bean DC.
3) And I am using this command bean Java dc in my WebDynpro application.
4) Now for deploying the helper class, I have created a library project.
5) To this library project I have added the SDA and API public part of helper class as used dc.
6) I have added this java library file as used DC in WebDynpro DC and in EJB DC.
7) I have added the library reference to the WebDynpro DC for J2ee server component library DC As pg.comaptsc~dc_aptjl
8) When i checked in Visual admin i could see the Assembly (SDA) helper class jar file.
In my helper class files, I am getting this warning.
Checking package reservation
Warning: Package pg.com.apt.help.cls is not reserved for DC : apt/sc/dc_apthc.
Now in my webdynpro DC when I refer to the helper class through the EJB, I get this error.
java.lang.NoClassDefFoundError: pg/com/apt/help/cls/TargetMarket at pg.com.atos.WebModuleProject.FetchSDCDataBean.SearchGTINTMDataEJB(FetchSDCDataBean.java:133) at pg.com.atos.WebModuleProject.FetchSDCDataObjectImpl0.SearchGTINTMDataEJB(FetchSDCDataObjectImpl0.java:119) ... 35 more ; nested exception is: java.lang.NoClassDefFoundError: pg/com/apt/help/cls/TargetMarket
Can you please guide on what I am missing.
Thanks in advance.
Regards,
Ashish Shah
Edited by: ashish shah on Dec 18, 2007 3:23 PM -
EJB and helper classes ...
I have created an EJB component which uses
some helper classes in JDeveloper 3.0 .
The component deploys sucessfully to OAS 4.0.8.1 . When I try to run the component through an applet ( including the _client.jar
in the archive tag) , the applet does not find the helper classes . How I do i include the helper classes in the _client.jar file ?Hi,
Try to put all the EJB's in a single package and import the package. I
can think of this solution right now, will keep posting for updates.
Regards
Raj
Daniel Westerdale wrote:
Hi,
I have a number of EJBs that each use a common set interfaces,
exceptions and Value beans. If I deploy using the iasdeploy command
line, then I must package up all these common classes within each of
the EJB modules - leading to a lot of duplicate code.
Is there a smarter a way of packaged the common classes so that I can
include them in the .EAR file but only in one module.
Note: I would prefer to only argument the IAS classpath with 3rd party
classes that rarely change and not these common classes e.g. Jlog
cheers
Daniel
Try our New Web Based Forum at http://softwareforum.sun.com
Includes Access to our Product Knowledge Base! -
EJB environment question (static helper classes)
We're using JBoss as AS containing several stateless session beans.
Now, we have certain helper classes that are abstract and contain static methods. Is this a problem for the EJBs? All of them use these helper classes all over their methods. Are they sharing the static class and will slow down somehow? Or is each EJB using its version of the class and can run concurrently?
Should we rethink this and put an INSTANCE of each helper class in each ejb instead of using static methods in the helper class?
Now in EJB method:
Helper.calculateStuff();
Should it be?
Helper h = new Helper(); // defined when ejb is created
helper.calculateStuff();
Edited by: JAeon on Sep 8, 2008 12:21 AM
Edited by: JAeon on Sep 8, 2008 12:22 AM>
The helper methods do database querries etc and return results that the EJB sends onwards to clients. If these methods
are NOT synchronized (and the ejbs share the static class) won't it cause concurrency errors? I think most of our methods are not
synchronized (and it doesn't seem to cause any concurrency errors so far... though the system have not beeen stressed test that much,
and concurrency bugs tends to pop up later and randomly :P).
>
No, if you dont have any static data variables in the Java classes, static method as such will not cause concurrency errors, and the methods should not be synchronized.
If you have any synchronized methods and they take a while to execute, that could become a bottleneck in itself, because different threads waiting for each other,
so make sure you dont have any synchronized methods where it is not explicitly needed.
Think of a static method (without static data in the class being manipulated) as a plain function in another programming-language.
>
We have some scaleability problems with the EJBs... It seems as if they do not run concurrently. If we do a stress test with several threads calling the EJBs their response time increases by a too large factor to feel comfortable...
>
Apparently, you do have a some scaling/concurrency problem, which could have many causes -- transaction locking and clashes in the database, poorly configured database, network congestion, problems in the EJB architecture, etc -- can be many reasons...
The general idea to debug, is first to find out exactly what calls in your code that take longest time to execute (profiling, logging, System.out.println's are useful) when you put parallel load on your system -- rather than just seeing "the whole application seems slow" -- from there you can move on, "divide&conquer" the problem, etc... -
Ejb-jar.xml not using fully qualified class names
HI,
I am trying yo upgrade my application from weblogic 8.1 to weblogic 9.2.3. My application has both session and enitybeans. I updated weblogic related jars with 9.x version. But while running ejbgen, i am getting the following exception.
*[java] weblogic.ejb.container.deployer.DeploymentDescriptorException: Unable to set the transaction attribute for method 'updateService(abcTO)' on EJB 'AbcService'. No matching method could be found. Please verify the method signature specified in the ejb-jar.xml file matches that of your Local interface for this EJB.*
In ejb-jar.xml file, it is not creating the fully qualified class name for abcTo in <method-param>. In component interface, the method signature is not contaning fully qualified class name for the parameters and return values.
If i change the signature in the bean with the fully qualified class name of the parameter, the ejb-jar.xml file is creating fine. But there are 100's of signatures i need to change if this is the only solution.
Can you please advice what i need to change when i upgrade from weblogic 8 to 9 series from session and entity bean's point of view?
Thanks in Advance
Naveen.
Edited by: avn_venki on Mar 16, 2009 7:15 AM
Edited by: avn_venki on Mar 16, 2009 7:15 AMejb-jar.xml has always required fully-qualified class names. If some vendors have accepted unqualified class names unfortunately that
behavior is non-portable. Your best bet is to fully-qualify the names. Perhaps you can find some tools to help you given the large
number of components in your application. -
Hi,
Can you any one help me to resolve this exception below. The conext is I
have successfully deplyed a bean and when i call the bean remot method I am
getting the following exception.
Can you any one help me in what situations we will get this type of
exception. I am using jdk1.3
Thanks
Kumar
*************** EXCEPTIN IS BELOW *****************************
PayDateRespondRequestBean lookup successful
creating session bean instance
Calling operation operation
java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVers
ionUID=796770993296843510
at
java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523)
at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)
at
java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.ClassTableEntry.readExternal(ClassTableEntry.java:29)
at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1212)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.InboundMsgAbbrev.readObject(InboundMsgAbbrev.java:66)
at weblogic.rjvm.InboundMsgAbbrev.read(InboundMsgAbbrev.java:38)
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:175)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
--------------- nested within: ------------------
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating response stream ] - with nested exception:
[java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVersionUID=796770993296843510]
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:184)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Error accessing PayDateRespondRequest bean
weblogic.rjvm.PeerGoneException: ; nested exception is:
weblogic.utils.NestedException: ***** ASSERTION FAILED
****[ Exception
creating response stream ] - with nested exception:
[weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating
response stream ] - with nested exception:Yes, this solved my problem. I was having two versions of javax.ejb package.
--Sajith
"Nils Winkler" <[email protected]> wrote in message
news:[email protected]...
Hi,
it looks like you have two different versions of the same class in the
classpath. Your client is expecting version A, but the server is
returning an instance of version B. Make sure that you only have one
version of the class in your classpath. If you're starting the client as
a separate app, also make sure that it's using the same classes as the
server.
Hope that helps,
Nils
Sajith wrote:
Hi,
Can you any one help me to resolve this exception below. The conext is I
have successfully deplyed a bean and when i call the bean remot method I
am
getting the following exception.
Can you any one help me in what situations we will get this type of
exception. I am using jdk1.3
Thanks
Kumar
*************** EXCEPTIN IS BELOW *****************************
PayDateRespondRequestBean lookup successful
creating session bean instance
Calling operation operation
java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVers
ionUID=796770993296843510
at
java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523)
atjava.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)
at
java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.ClassTableEntry.readExternal(ClassTableEntry.java:29)
at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1212)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.InboundMsgAbbrev.readObject(InboundMsgAbbrev.java:66)
at weblogic.rjvm.InboundMsgAbbrev.read(InboundMsgAbbrev.java:38)
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:175)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
--------------- nested within: ------------------
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating response stream ] - with nested exception:
[java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVersionUID=796770993296843510]
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:184)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Error accessing PayDateRespondRequest bean
weblogic.rjvm.PeerGoneException: ; nested exception is:
weblogic.utils.NestedException: ***** ASSERTION FAILED
****[ Exception
creating response stream ] - with nested exception:
[weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating
response stream ] - with nested exception:--
============================
[email protected] -
Help needed in creating File Directory if not exist
hi, All
I am thinking about wite files to directories based on year, month, day. if the directory for that year or month or day exists already, do not create the directory, but write the file to that directory.
For example: 2003/02/22/file.txt --2003/02/22 exist, just write file.txt
If the directory does not exist, the program will create the direcotry and write the file into the right directory.
For example 2003/02/22/file.txt, ---2003/02/22/ does not exist, the program will create the directoies and write file file.txt
If anyone can provide any example or suggestion, I really appreciate!
Thanks
SteveHi!
Just have a look at the class "File"
and it's method "exists()".
Hope, that helps.
Thoto -
Reference EJB from servlet's action/helper classes
Hello
How to make a reference to stateless session bean from one of the helper classes of a servlet WITHOUT using any of these:
* dependency injection (like @EJB) - I think this is not supported in this kind of class, EJB references can be injected only to servlets themselves or some other things (but not objects of classes "accompanying" a servlet)
* home or local home interfaces (I would like to avoid writing them)
* using mappedName (either in @Stateless or in ejb-jar) - since meaning of this is application-server dependent and thus not portable.
By a "class accompanying a servlet" / "helper class" I mean utility or action classes, like MyActionClass, which would be instantiated and then used by a aforementioned servlet.
Thanks.The EJB dependency must be looked up via the java:comp/env namespace since as you point out
Java EE 5 environment annotations are not supported on POJOs. However, the dependency itself
can either be defined using @EJB on some other managed class in the .war or within the
web.xml. We have an entry in our EJB FAQ that has the details :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB
Also, whenever the client component resides in the same application as the target EJB (which is
required for Local access but not for Remote access) there is no need to use mappedName to
resolve the EJB dependency. It is either automatically resolved if the business interface type of
the EJB dependency is only exposed by a single EJB in the application, OR the beanName()
/ ejb-link attributes can be used to unambiguously identify the target EJB using ejb-name.
You can find more about this in the FAQ as well. -
Class not Found Exception while running an EJB
I have created and published a EJB in Oracle 8i (in a particular
schema) by running the deployejb tool supplied. The ejb was
published successfully. On running the client program I get an
error saying that the mybeans's HomeHelper class cannot be
found. This error occurs when there is a lookup to the home
interface of the bean. The exception thrown says Reasons are
unknown. On checking the objects of type 'JAVA CLASS' I found
that the homeHelper class object had been created automatically
be the deploy process. What is the reason for the class not
found exception and what can I do to correct it. ?
The code for the beans is as given below :
Home Interface
package mituser ;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface MITUserHome extends EJBHome {
public MITUser create()
throws CreateException, RemoteException;
Remote Interface
package mituser ;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface MITUser extends EJBObject {
public int validateUserName (String username)
throws java.sql.SQLException, RemoteException;
public int validatePassword (String username, String password)
throws java.sql.SQLException, RemoteException;
public String validateSearchAccess (String username, String
password)
throws java.sql.SQLException, RemoteException;
Bean
package mituserServer ;
import java.sql.*;
import java.rmi.RemoteException;
import javax.ejb.*;
public class MITUserBean implements SessionBean {
SessionContext ctx;
public void ejbCreate() throws CreateException,
RemoteException {
public void ejbActivate() {
public void ejbPassivate() {
public void ejbRemove() {
public void setSessionContext(SessionContext ctx) {
this.ctx = ctx;
public int validateUserName (String username) throws
SQLException, RemoteException
int count = 0 ;
Connection conn =
new oracle.jdbc.driver.OracleDriver().defaultConnection ();
PreparedStatement ps =
conn.prepareStatement ("select count(username) from
useraccountinfo where username = ?");
try {
ps.setString (1, username);
ResultSet rset = ps.executeQuery ();
if (!rset.next ())
throw new RemoteException ("no registered user with User
Name " + username);
count = rset.getShort(1) ;
return count ;
} finally {
ps.close();
public int validatePassword (String username, String password)
throws SQLException, RemoteException
int count = 0 ;
Connection conn =
new oracle.jdbc.driver.OracleDriver().defaultConnection ();
PreparedStatement ps =
conn.prepareStatement ("select count(username) from
useraccountinfo where username = ? and password = ?");
try {
ps.setString (1, username);
ps.setString(2, password);
ResultSet rset = ps.executeQuery ();
if (!rset.next ())
throw new RemoteException ("Invalid Password ");
count = rset.getShort(1) ;
return count ;
} finally {
ps.close();
public String validateSearchAccess (String username, String
password) throws SQLException, RemoteException
String searchaccess = "" ;
Connection conn =
new oracle.jdbc.driver.OracleDriver().defaultConnection ();
PreparedStatement ps =
conn.prepareStatement ("select searchprofileaccess from
useraccountinfo where username = ? and password = ?");
try {
ps.setString (1, username);
ps.setString(2, password);
ResultSet rset = ps.executeQuery ();
if (!rset.next ())
throw new RemoteException ("Access Denied for " +
username );
searchaccess = rset.getString(1) ;
return searchaccess ;
} finally {
ps.close();
Client program
import mituser.MITUser;
import mituser.MITUserHome;
import oracle.aurora.jndi.sess_iiop.ServiceCtx;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;
public class Client {
public static void main (String [] args) throws Exception {
int count = 0 ;
String access = "" ;
if (args.length != 4) {
System.out.println("usage: Client serviceURL objectName
user password");
System.exit(1);
String serviceURL = args [0];
String objectName = args [1];
String user = args [2];
String password = args [3];
Hashtable env = new Hashtable();
env.put(Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
env.put(Context.SECURITY_PRINCIPAL, user);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.SECURITY_AUTHENTICATION,
ServiceCtx.NON_SSL_LOGIN);
Context ic = new InitialContext(env);
MITUserHome home = (MITUserHome)ic.lookup (serviceURL +
objectName);
MITUser testBean = home.create ();
count = testBean.validateUserName("MITA");
if (count > 0 )
System.out.println ("Valid User");
else
System.out.println ("Invalid User");
count = testBean.validatePassword("MITA", "MITA");
if (count > 0 )
System.out.println ("Valid Password");
else
System.out.println ("Invalid Password");
access = testBean.validateSearchAccess("MITA", "MITA");
if ( access.equalsIgnoreCase("YES") )
System.out.println ("Search Access Available");
else
System.out.println ("Search Access Denied");
The Descriptor file
// MIT UserBean EJB deployment descriptor
SessionBean mituserServer.MITUserBean {
BeanHomeName = "test/mitUserJDBCBean";
RemoteInterfaceClassName = mituser.MITUser;
HomeInterfaceClassName = mituser.MITUserHome;
AllowedIdentities = {MIT};
SessionTimeout = 20;
StateManagementType = STATEFUL_SESSION;
RunAsMode = CLIENT_IDENTITY;
TransactionAttribute = TX_REQUIRED;
Batch File for deploying the ejb
@echo off
if (%ORACLE_HOME%)==() goto usage
if (%ORACLE_SERVICE%)==() goto usage
if (%JDK_CLASSPATH%)==() goto usage
@echo on
set CLASSPATH=.;%ORACLE_HOME%\lib\aurora_client.jar;%ORACLE_HOME%
\jdbc\lib\classes111.zip;%ORACLE_HOME%\sqlj\lib\translator.zip;%
ORACLE_HOME%\lib\vbjorb.jar;%ORACLE_HOME%\lib\vbjapp.jar;%
JDK_CLASSPATH%
javac -g mituser\MITUser.java
javac -g mituser\MITUserHome.java
javac -g mituserServer\MITUserBean.java
jar cf0 mituser.jar mituser\MITUser.class
mituser\MITUserHome.class mituserServer\MITUserBean.class
javac -g Client.java
call deployejb -republish -temp temp -u mit -p mit -s %
ORACLE_SERVICE% -descriptor mituser.ejb mituser.jar
@echo off
goto done
:usage
@echo -------------------------------------------------------
@echo Following are the requirements to run this script
@echo set ORACLE_HOME to installed Oracle home
@echo set ORACLE_SERVICE to the CORBA service name of
your databae
@echo for example sess_iiop://localhost:2481:ORCL
@echo set JDK_CLASSPATH to the full path of your JDK
classes.zip
@echo -------------------------------------------------------
:done
Batch file for running the cleint program
@echo off
if (%ORACLE_HOME%)==() goto usage
if (%ORACLE_SERVICE%)==() goto usage
if (%JDK_CLASSPATH%)==() goto usage
@echo on
set CLASSPATH=.;%ORACLE_HOME%\lib\aurora_client.jar;%ORACLE_HOME%
\jdbc\lib\classes111.zip;%ORACLE_HOME%\sqlj\lib\translator.zip;%
ORACLE_HOME%\lib\vbjorb.jar;%ORACLE_HOME%\lib\vbjapp.jar;%
JDK_CLASSPATH%;server_generated.jar
java Client %ORACLE_SERVICE% /test/mitUserJDBCBean mit mit
@echo off
goto done
:usage
@echo -------------------------------------------------------
@echo Following are the requirements to run this script
@echo set ORACLE_HOME to installed Oracle home
@echo set ORACLE_SERVICE to the CORBA service name of
your databae
@echo for example sess_iiop://localhost:2481:ORCL
@echo set JDK_CLASSPATH to the full path of your JDK
classes.zip
@echo -------------------------------------------------------
:done
I know this is not strictly to do with JDBC but there appears to
be no discussion forum for EJB
Hoping for a response soon as it us very URGENT
Thanks
Mita
nullI have created and published a EJB in Oracle 8i (in a particular
schema) by running the deployejb tool supplied. The ejb was
published successfully. On running the client program I get an
error saying that the mybeans's HomeHelper class cannot be
found. This error occurs when there is a lookup to the home
interface of the bean. The exception thrown says Reasons are
unknown. On checking the objects of type 'JAVA CLASS' I found
that the homeHelper class object had been created automatically
be the deploy process. What is the reason for the class not
found exception and what can I do to correct it. ?
The code for the beans is as given below :
Home Interface
package mituser ;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface MITUserHome extends EJBHome {
public MITUser create()
throws CreateException, RemoteException;
Remote Interface
package mituser ;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface MITUser extends EJBObject {
public int validateUserName (String username)
throws java.sql.SQLException, RemoteException;
public int validatePassword (String username, String password)
throws java.sql.SQLException, RemoteException;
public String validateSearchAccess (String username, String
password)
throws java.sql.SQLException, RemoteException;
Bean
package mituserServer ;
import java.sql.*;
import java.rmi.RemoteException;
import javax.ejb.*;
public class MITUserBean implements SessionBean {
SessionContext ctx;
public void ejbCreate() throws CreateException,
RemoteException {
public void ejbActivate() {
public void ejbPassivate() {
public void ejbRemove() {
public void setSessionContext(SessionContext ctx) {
this.ctx = ctx;
public int validateUserName (String username) throws
SQLException, RemoteException
int count = 0 ;
Connection conn =
new oracle.jdbc.driver.OracleDriver().defaultConnection ();
PreparedStatement ps =
conn.prepareStatement ("select count(username) from
useraccountinfo where username = ?");
try {
ps.setString (1, username);
ResultSet rset = ps.executeQuery ();
if (!rset.next ())
throw new RemoteException ("no registered user with User
Name " + username);
count = rset.getShort(1) ;
return count ;
} finally {
ps.close();
public int validatePassword (String username, String password)
throws SQLException, RemoteException
int count = 0 ;
Connection conn =
new oracle.jdbc.driver.OracleDriver().defaultConnection ();
PreparedStatement ps =
conn.prepareStatement ("select count(username) from
useraccountinfo where username = ? and password = ?");
try {
ps.setString (1, username);
ps.setString(2, password);
ResultSet rset = ps.executeQuery ();
if (!rset.next ())
throw new RemoteException ("Invalid Password ");
count = rset.getShort(1) ;
return count ;
} finally {
ps.close();
public String validateSearchAccess (String username, String
password) throws SQLException, RemoteException
String searchaccess = "" ;
Connection conn =
new oracle.jdbc.driver.OracleDriver().defaultConnection ();
PreparedStatement ps =
conn.prepareStatement ("select searchprofileaccess from
useraccountinfo where username = ? and password = ?");
try {
ps.setString (1, username);
ps.setString(2, password);
ResultSet rset = ps.executeQuery ();
if (!rset.next ())
throw new RemoteException ("Access Denied for " +
username );
searchaccess = rset.getString(1) ;
return searchaccess ;
} finally {
ps.close();
Client program
import mituser.MITUser;
import mituser.MITUserHome;
import oracle.aurora.jndi.sess_iiop.ServiceCtx;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;
public class Client {
public static void main (String [] args) throws Exception {
int count = 0 ;
String access = "" ;
if (args.length != 4) {
System.out.println("usage: Client serviceURL objectName
user password");
System.exit(1);
String serviceURL = args [0];
String objectName = args [1];
String user = args [2];
String password = args [3];
Hashtable env = new Hashtable();
env.put(Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
env.put(Context.SECURITY_PRINCIPAL, user);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.SECURITY_AUTHENTICATION,
ServiceCtx.NON_SSL_LOGIN);
Context ic = new InitialContext(env);
MITUserHome home = (MITUserHome)ic.lookup (serviceURL +
objectName);
MITUser testBean = home.create ();
count = testBean.validateUserName("MITA");
if (count > 0 )
System.out.println ("Valid User");
else
System.out.println ("Invalid User");
count = testBean.validatePassword("MITA", "MITA");
if (count > 0 )
System.out.println ("Valid Password");
else
System.out.println ("Invalid Password");
access = testBean.validateSearchAccess("MITA", "MITA");
if ( access.equalsIgnoreCase("YES") )
System.out.println ("Search Access Available");
else
System.out.println ("Search Access Denied");
The Descriptor file
// MIT UserBean EJB deployment descriptor
SessionBean mituserServer.MITUserBean {
BeanHomeName = "test/mitUserJDBCBean";
RemoteInterfaceClassName = mituser.MITUser;
HomeInterfaceClassName = mituser.MITUserHome;
AllowedIdentities = {MIT};
SessionTimeout = 20;
StateManagementType = STATEFUL_SESSION;
RunAsMode = CLIENT_IDENTITY;
TransactionAttribute = TX_REQUIRED;
Batch File for deploying the ejb
@echo off
if (%ORACLE_HOME%)==() goto usage
if (%ORACLE_SERVICE%)==() goto usage
if (%JDK_CLASSPATH%)==() goto usage
@echo on
set CLASSPATH=.;%ORACLE_HOME%\lib\aurora_client.jar;%ORACLE_HOME%
\jdbc\lib\classes111.zip;%ORACLE_HOME%\sqlj\lib\translator.zip;%
ORACLE_HOME%\lib\vbjorb.jar;%ORACLE_HOME%\lib\vbjapp.jar;%
JDK_CLASSPATH%
javac -g mituser\MITUser.java
javac -g mituser\MITUserHome.java
javac -g mituserServer\MITUserBean.java
jar cf0 mituser.jar mituser\MITUser.class
mituser\MITUserHome.class mituserServer\MITUserBean.class
javac -g Client.java
call deployejb -republish -temp temp -u mit -p mit -s %
ORACLE_SERVICE% -descriptor mituser.ejb mituser.jar
@echo off
goto done
:usage
@echo -------------------------------------------------------
@echo Following are the requirements to run this script
@echo set ORACLE_HOME to installed Oracle home
@echo set ORACLE_SERVICE to the CORBA service name of
your databae
@echo for example sess_iiop://localhost:2481:ORCL
@echo set JDK_CLASSPATH to the full path of your JDK
classes.zip
@echo -------------------------------------------------------
:done
Batch file for running the cleint program
@echo off
if (%ORACLE_HOME%)==() goto usage
if (%ORACLE_SERVICE%)==() goto usage
if (%JDK_CLASSPATH%)==() goto usage
@echo on
set CLASSPATH=.;%ORACLE_HOME%\lib\aurora_client.jar;%ORACLE_HOME%
\jdbc\lib\classes111.zip;%ORACLE_HOME%\sqlj\lib\translator.zip;%
ORACLE_HOME%\lib\vbjorb.jar;%ORACLE_HOME%\lib\vbjapp.jar;%
JDK_CLASSPATH%;server_generated.jar
java Client %ORACLE_SERVICE% /test/mitUserJDBCBean mit mit
@echo off
goto done
:usage
@echo -------------------------------------------------------
@echo Following are the requirements to run this script
@echo set ORACLE_HOME to installed Oracle home
@echo set ORACLE_SERVICE to the CORBA service name of
your databae
@echo for example sess_iiop://localhost:2481:ORCL
@echo set JDK_CLASSPATH to the full path of your JDK
classes.zip
@echo -------------------------------------------------------
:done
I know this is not strictly to do with JDBC but there appears to
be no discussion forum for EJB
Hoping for a response soon as it us very URGENT
Thanks
Mita
null -
Example of binding an object(just a java class not an EJB) to a JNDI name
Hi,
I would appreciate your help if you could give me some pointers regarding where
to find any examples which uses objects ( a java class not an EJB) to a JNDI name.
I could get an example to work using String but it doesnt work with a java class
object.
Thanks a lot,
SunithaTry making the java object serializable.
- Naresh
"sunitha" <[email protected]> wrote:
>
Hi,
I would appreciate your help if you could give me some pointers regarding
where
to find any examples which uses objects ( a java class not an EJB) to
a JNDI name.
I could get an example to work using String but it doesnt work with a
java class
object.
Thanks a lot,
Sunitha
Maybe you are looking for
-
I just downloaded the latest itunes update 11.1 for windows 7 and now when I try to open itunes with the shortcut on my desktop I get this error message: "The item 'itunes.exe' that this shortcut refers to has been changed or moved, so this shortcut
-
How to hide the select-options fields on radiobutton select in webdynpro
hi Could you please help how to hide the select-option fields in webdynpro there are four radio buttons for every radiobutton there is corresponding the select_option filed is associated to it user as only provision select one radio button and reset
-
Failure to install Windows XP Mode under Win7
After (apparently successful) installation of 500-megabyte "Windows XP Mode," installation of 10-megabyte "Windows Virtual PC," after reboot, reports "Failure configuring Windows updates / Reverting changes." Event viewer shows "Package KB958559 fail
-
Hi all, i have the need to implement an FTP procedure and accordingly to what i found here : http://www.oracle-base.com/articles/misc/ftp-from-plsql.php i try this code: DECLARE l_conn UTL_TCP.connection; l_result PLS_INTEGER; BEGIN
-
Prenote - Prenotification for A/P during payment processing
Hi all - we're running prenotes for A/P (combining with payroll for the output to the bank). I have no issues with the prenote in general (file creation - sending to the bank - bank error file load into SAP). Where my issue/question resides is arou