Confused with package statement
My classpath is set to as follows:
.;C:\projects\profjava;
I create a class Xyz.classis in package com.sunil.misc that means the full location of this class is
C:\projects\profjava\com\sunil\misc\Xyz.class
when I execute following:
C:\ > java Xyz
I get following error:
Exception in thread "main" java.lang.NoClassDefFoundError: FontPropertiesPanel
when I execute it from within C:\projects\profjava\com\sunil\misc
I get following error:
Exception in thread "main" java.lang.NoClassDefFoundError: FontPropertiesPanel (
wrong name: com/sunil/misc/FontPropertiesPanel)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Whats going on here? In first case I can understand it is not able to find the class hence the error. But in second case it is finding the class and I'd expect it to appent the package structure ie com\sunil\misc to be appended with classpath and form a full path like
c:\projects\profjava\com\sunil\misc\Xyz.class ... am I right. Can any one explain this ?
When you run a class with java command how does it finds the class ? In order to find in which package class resided it needs to find the class itself first, because, I think package information is with in the class. Its a loop isn't it ? I am confused... any input will be great !!!
Thanks,
Sunil
You can't use "Xyz" for "com.sunil.misc.Xyz" with the java command. There is no "import"-statement to be used with the runtime environment. :)
Java also cannot start searching for a class called Xyz from the classpath. Imagine your classpath contains "the current directory". You try to do something like:
C:\>java ClassThatDoesNotExist
Would you really expect the java runtime environment to go through every file and each directory on your C: drive searching for something that's not there, plus all the other paths that you have in the classpath? I don't think you would...
When you run a class with java command how does it
finds the class ?You'll find this interesting: http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html
Check the doc "How Classes are Found".
Similar Messages
-
Problem With Package Statement
Hello -
I am semi new to Java and I am trying to place two classes I have created into a package. At the top of both classes I have the statement:
package mycode.stringtests;
I have saved both files into d:\jf\mycode\stringtests and set my classpath variable to d:\jf;.
I can compile just fine, but when I go to run from the command line with the java command I get an exception:
Exception in thread "main" java.lang.NoClassDefFoundError: StringTest (wrong name mycode/stringtests/StringTest)
Any ideas? Thanks!You probably cd to the stringtests directory and using
the command "java StringTest"
java is finding a file named StringTest.class, but
when it looks inside the file, it finds that the fully
qualified name of the class is
mycode.stringtests.StringTest. Since the name you
supplied in the argument is different from the fully
qualified name, you get a wrong name error.
When a class is executable and part of a package, you
need to supply the fully qualified name of the class.
So your command should be "java
mycode.stringtests.StringTest"Hi,
I am having the same problem as the one mentioned and I have come here to find a solution. I have tried the answer you suggested and am still getting the same error message as above. Could you please elaborate or point me to some more information on the topic. -
Hi All,
I have a situation where I have a package I am working on in one schema (say AUX) that has functions being called by a trigger in another schema (say MAIN). Whenever I change and recompile the package the trigger throws the following error:
Error CALL__ACT_FUNC_STP ORA-04068: existing state of packages has been discarded
ORA-04068: existing state of packages (AUX.US.ORACLE.COM) has been discarded
ORA-04061: existing state of package body "AUX.ACTIVITY_NOTIFICATION" has been invalidated
ORA-04065: not executed, altered or dropped package body "AUX.ACTIVITY_NOTIFICATION"
ORA-06512: at "MAIN.ACTION_AFTER_UPD_STATUS", line 63
ORA-04088: error during execution of trigger 'MAIN.ACTION_AFTER_UPD_STATUS'
When I inflict this upon mysef it errors once and then never again until I make another change. When my users experience this it comes from only a handful and then doesnt happen again. BTW, this is Oracle 9 serving a web application hosted by websphere.
Can someone explain why this happens, and more importantly how I can deploy changes without causing this particular speedbump?
Thanks in advance!
MichaelWhen we execute a package a version of it is stored in the session memory cache. This is how variables set in the package persist between calls. When someone recompiles the package that invalidates our stored version of it. This happens even if the package is SERIALLY_REUSEABLE.
Unfortunately the only way to fix ORA-04068 is to close the session and reconnect. I guess this explains your users' expereinces - I guess you're using some form of connection pooling, so only those users who connect with an existing connection will notice. I don't know the specifics of your set-up but I think you'll need to synchronise a flush of your connection pool with the deployment of your trigger code. I expect that will be difficult in a 24-7 environment but zero downtime is an aspiration not a realistic goal.
Cheers, APC -
Unable to add java files with package statement
Hi all,
I have the following problem. I add to my project(JBuilder8) a set of java files that
they have in their headers the statement...
package jp.gr.java_conf.tame.swing.table;except one with statement...
package jp.gr.java_conf.tame.swing.colorchooser;If i try to compile the project i get the following message many times for
each file...
"AttributiveCellRenderer.java": Error #: 901 : package
jp.gr.java_conf.tame.swing.table stated in source
C:\Development\JBProjects\cellspan\AttributiveCellRenderer.java does not
match directory . at line 4, column 36What i have to do to embed correctly the java files?
Thank you for advance, kostas.Sounds like your source file is in the wrong directory. The directory the file's in has to match the package.
-
Compiling files with the 'package'-statement
Hi,
I have a problem compiling files that uses the 'package'-statement:
I have 2 files ClassA.java and ClassB.java. ClassA uses objects of type ClassB. When I compile ClassA.java the compiler also automatically compiles ClassB.java. No problem so far.
But when I add "package mypackage" to ClassA.java and ClassB.java and then try to compile ClassA.java with the command "javac -d . ClassA.java" I get the compile-error "Class mypackage.ClassB not found". This would mean that I would have to compile all my files separately?
Can anybody tell me what I am doing wrong?
Thx,
JanI was still working on it, but I think I have it now :-)
Let me try to summarize what I think/hope that I understand:
I have the following files in package mypackage:
C:\src\mypackage\ClassA.java
C:\src\mypackage\ClassB.java
with ClassA using ClassB.
I want to compile them into C:\classes\mypackage\ClassA.class and C:\classes\mypackage\ClassB.class
I change directory to C:\classes and then give the command
>javac -d . ..\src\mypackage\ClassA.java
This didn't work at first because my classpath wasn't set correctly. To make it work I had to add C:\src to my classpath. Which surprised me a little because I thought that the classpath was only used to find *.class files and not by javac to find *.java files?
If anybody has something to add to this, please feel free to do so.
Jan -
Problem with import statement !!!
Hi all,
When I'm compiling a java progam(client program in an EJB application) I'm getting the following error.
\ejb\converter\ConverterClient.java:14: '.' expected
import Converter;
^
\ejb\converter\ConverterClient.java:15: '.' expected
import ConverterHome;
^
2 errors
All files , Home interface , bean class , remote interface and client program are all in same folder. And no package statement is used.
When I had removed the above statements , it compiled well.But After when running the client (after every thing is done and deployed bean in J2EE server using deploy tool ), the following error is coming..
Binding name:`java:comp/env/ejb/SimpleConverter`
Application threw an exception:java.lang.NoClassDefFoundError: ConverterHome
Unbinding name:`java:comp/env/ejb/SimpleConverter`
Can any one suggest a solution with explanation ???
I'm using J2SE 1.4 beta 2 version. This J2EE SDK us designed for J2SE 1.3 . is this the reason ??
Thanks in advance..
ashokDid you added the <your_ejb>.jar file to the classpath??
/Sreenivasa Kumar Majji.
Hi all,
When I'm compiling a java progam(client program in an
EJB application) I'm getting the following error.
\ejb\converter\ConverterClient.java:14: '.' expected
import Converter;
^
\ejb\converter\ConverterClient.java:15: '.' expected
import ConverterHome;
^
2 errors
All files , Home interface , bean class , remote
interface and client program are all in same folder.
And no package statement is used.
When I had removed the above statements , it compiled
well.But After when running the client (after every
thing is done and deployed bean in J2EE server using
deploy tool ), the following error is coming..
Binding name:`java:comp/env/ejb/SimpleConverter`
Application threw an
exception:java.lang.NoClassDefFoundError:
ConverterHome
Unbinding name:`java:comp/env/ejb/SimpleConverter`
Can any one suggest a solution with explanation ???
I'm using J2SE 1.4 beta 2 version. This J2EE SDK us
designed for J2SE 1.3 . is this the reason ??
Thanks in advance..
ashok -
Help with dynamic statement returning values into collection
Hi All
I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
create table t(
pk number,
id_batch varchar2(30),
date_created date,
constraint t_pk primary key ( pk )
create or replace type num_ntt is table of number;
create or replace type vc2_ntt is table of varchar2(30);
create or replace
package pkg
as
type rec is record(
pk num_ntt,
id_batch vc2_ntt
procedure p(
p_count in number,
p_rt out nocopy rec
end pkg;
create or replace
package body pkg
as
procedure p(
p_count in number,
p_rt out nocopy rec
is
begin
execute immediate '
insert into t
select level, ''x'' || level, sysdate
from dual
connect by level <= :p_count
returning pk, id_batch into :pk, :id_batch'
using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
end p;
end pkg;
declare
r pkg.rec;
begin
pkg.p( 5, r );
end;
/sanjeevchauhan wrote:
but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
Regards,
Rob. -
Help! With Packages...I'm new & frustrated!
In the following directory structure, I have 2 classes, a DBHandler class that hits a database and a GetData class uses the DBHandler class to get specific data. I want to put both of these into a WebSiteClasses package. When I try to package both of them to the WebSiteClasses package, the DBHandler class compiles just fine. But when I try to compile the GetData class (that uses the DBHandler class) I get an error stating the following:
"cannot resolve symbol
symbol : class DBHandler".
My code for the two java files is below this directory structure. I'm rather new at this and any help would be greatly appreciated
…
- tomcat
- bin
- classes
- WebSiteClasses
DBHandler.class
DBHandler.java
GetData.class
GetData.java
- common
- conf
- lib
- logs
- server
- temp
- work
=====================================================
JAVA Files ------>>>>
DBHandler.java:
package WebSiteClasses;
import java.sql.*;
public class DBHandler{
public ResultSet getData(String sql){
Connection cn = null;
Statement st = null;
ResultSet rs = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:FileToFile";
String user = "";
String pwd = "";
cn = DriverManager.getConnection(url,user,pwd);
st = cn.createStatement();
rs = st.executeQuery(sql);
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
return rs;
GetData.java:
package WebSiteClasses;
import java.sql.*;
import java.io.*;
import java.util.ArrayList;
public class GetData{
DBHandler db = new DBHandler();
String[] monthList;
public GetData() throws Exception{
getTrans();
public ArrayList getTrans() throws Exception{
ResultSet rs = db.getData("select distinct Transaction from tblTransactReport");
ArrayList list = new ArrayList();
try{
while (rs.next()){
String Transaction = rs.getString("Transaction");
list.add(Transaction);
}catch (SQLException e){e.printStackTrace();}
return list;"...Everywhere I've read about packages, in books or on line tutorials, merely states the obvious...create a folder and then name that folder in a package statement in the JAVA program..."
Not so obvious, apparently.
I don't know about a comprehensive reference - explaining CLASSPATH shouldn't take a 1,000 page book.
I think it's important to understand the connection between the package names, the directory structure, the fully-resolved class name, and the way that javac.exe and java.exe go looking for classes. Maybe you need to look past the obvious and think about this for a while longer.
If you have a class X with package a.b.c, do you understand what the directory structure must look like? Where should the X.class file be? If you're using a command shell, what directory should you navigate to in order to compile X.java, and where should X.class end up when you're finished? When you try to run your new X.class, how do you invoke it in java.exe?
If you can answer all those, you're in better shape.
How To Set The CLASSPATH -
Sequence.nextval doubles the returned value with Execute Statement (F9)
There appears to be a quirk with sequences in Raptor.
Has anyone noticed that depending on how you execute this sql (SELECT MYSEQ.NEXTVAL FROM DUAL;) the value returned is either the correct nextval or double what you expected?
For example, MYSEQ is a simple sequence which increments by 1. If you Execute Statement (F9) then the value returned jumps by 2 instead of 1. If you Run Script (F5) then the value returns jumps by 1, as expected.
If MYSEQ is changed to increment by 2. The when you Execute Statement (F9) then the value returned jumps by 4 instead of 2. If you Run Script (F5) then the value returns jumps by 2, as expected. No matter what you put for the increment by Execute Statement (F9) always doubles it.
It always seems to be double. Executing the same scenario in TOAD always returns the correct value (i.e. properly increments).
Is the query being executed multiple times with Execute Statement? Why is this happening?While there is no guarantee from Oracle that sequences produce sequential numbers, this is obviously a case where SQL Developer is running the select statement twice.
The issue is that queries can actually change information, rather than just retrieve data from the database.
The following package is a test case:
create or replace package test_query is
function get_next_count return number;
end;
create or replace package body test_query is
cnt number := 0;
function get_next_count return number is
begin
cnt := cnt + 1;
return cnt;
end;
end;
select test_query.get_next_count from dual;
This query, which should return 1, 2, 3, 4, etc actually returns 2, 4, 6, 8, etc, because SQL Developer is running the select twice. -
I have two classes within a same directory (directory name is myPackage), but one using package statement as:
package myPackage;
other file doesn't. The codes are as follows:
* file: myPackage\A.java
public class A{
public void call(){
* file: myPackage\B.java
package myPackage;
public class B{
public static void main(String[] args){
A a = new A();
{code}
When compiles B.java it successfully compiles.
javac myPackage\B.java
But when try to invoke call method of A, the compilation fails. Here I'm confused wonder why can not be invoked if you can create an instance. Please reply if some one knows this issue.* file: myPackage\A.java
public class A{
public void call(){
* file: myPackage\B.java
package myPackage;
public class B{
public static void main(String[] args){
A a = new A();
When compiles B.java it successfully compiles.
javac myPackage\B.javaI doubt that B.java successfully compiles base on the code structure above.
B here is assuming to instantiate myPackage.A -
Appletviewer not compitable with Package
Hi All,
I have created a package javaProg.completeReferance. and use this same package to execute all of my java application however when I try to execute an applet it complains.this is how I execute applet.
appletviewer javaProg.SimpleApplet.html (or .class), but when I remove all the packages statement and go to the current Dir it executes perfectly . So can I concule that appletviewer is not complitable with packages.
below is the simple code. Any help is highly appreciated.
package javaProg.completeReferance;
//<applet code="SimpleApplet.class" width="200" height="200"></applet>
import java.applet.Applet;
import java.awt.*;
public class SimpleApplet extends Applet
public void paint(Graphics g)
g.drawString("Hello World",20,20);
}I am using window vista and I read somewhere that
vista and java together , in the Applet programhave
few bugs.
Regards!Your chance of finding a true Java bug increases as
your java experience increases. On the other hand,
99.999% of 'bugs' reported by newbies are actually
bugs in the newbie's own code.sorry about that actually Java rocks.I am preparing for my SCJP , Can you please tell me is the exam very difficult to crack and also how much time is actually required for a noviceto crack this .This will be very helpful for me as I can plan according.
Thanks in advance!! -
Help with packages and classpath
Heya,
first off, i use textpad to compile my java, i don't do it via the command line.
my problem is faily simple, i think. i've got a main class and i'd like it to import a custom class from a subdir.
Main class is in
C:\Documents and Settings\David\Desktop\java\test_gen.java
I would like it to import
C:\Documents and Settings\David\Desktop\java\obj_data\objects.java
I understand that I have to declare objects.java to be a part of a package, so i head the code with: package obj_data; as i understand it, the directory in which the package to be imported resides in will be named the same as the package.
When i import my package into test_gen.java, i import obj_data as follows:
import obj_data.*;
this should import objects.class and any other classes in the same directory. also import obj_data.objects.*; could be used.
Anyway, thats my understanding of how you set up the class and package; i also understand that when the java file compiles the compiler looks at the directoy(s) indicated in the class path for the classes to import. that in mind i tried to add:
C:\Documents and Settings\David\Desktop\java\obj_data\
to my classpath. i did this via dos, javac -classpath "C:\Documents and Settings\David\Desktop\java\obj_data\"
i got no error messages, so i assume it worked. however when i try to compile the main java (test_gen) i get-
package packages does not exist
import packages.*;
^
1 error
Tool completed with exit code 1
can anyone give me some help please?This is a minimal explanation of packages.
Assume that your programs are part of a package named myapp, which is specified by this first line in each source file:
package myapp;
Also assume that directory (C:\java\work\) is listed in the CLASSPATH list of directories.
Also assume that all your source files reside in this directory structure: C:\java\work\myapp\
Then a statement to compile your source file named aProgram.java is:
C:\java\work\>javac myapp\aProgram.java
Explanation:
Compiling
A class is in a package if there is a package statement at the top of the class.
The source file needs to be in a subdirectory structure. The subdirectory structure must match the package statement. The top subdirectory must be in the classpath directory.
So, you generate a directory structure C:\java\work\myapp\ which is the [classpath directory + the package subdirectory structure], and place aProgram.java in it.
Then from the classpath directory (C:\java\work\) use the command: javac myapp\aProgram.java
Running
Compiling creates a file, aProgram.class in the myapp directory.
(The following is where people tend to get lost.)
The correct name now, as far as java is concerned, is the combination of package name and class name: myapp.aProgram (note I omit the .class) If you don't use this name, java will complain that it can't find the class.
To run a class that's NOT part of a package, you use the command: java SomeFile (assuming that SomeFile.class is in a directory that's listed in the classpath)
To run a class that IS part of a package, you use the command java myapp.aProgram (Note that this is analogous to the command for a class not in a package, you just use the fully qualified name) -
Again confused with delta update.
Hello experts
I am confused with delta update as usual
I have one Infocube in which last data pull was on 29.11.2005.
If now again I run delta load then will it pull entire data from 2005 to 2008 or I should delete all data from cube n do full load??
Kindly explain
Regards
SwatiHi Swathi
LIS EXTRACTION
T.code - :MC18 create field catalog
1. Characteristic Catalog
Application-01-Sales and Distribution, 02-Purchasing, 03-Inventory
Controlling, etc..
Catalog category 1. Characteristic catalog, 2. Key figures catalog 3.
Date catalog
Select characteristic catalog and enter, click on characteristic select
the source table and it will be display the relevant source field and
select the source field, copy + close, copy.
Save, similarly create key figures catalog
T.code : MC21 create infostructure
Example
Inforstructure : S789
Application 01
Choose characteristic select the catalog, select the fields, copy +
close
Choose key figures catalog select the key figures ,copy + close, save
and generate
T.code MC24 create updating
Infostructure : S789
Update group : 01- Sales document, delivery, billing document ,enter
Select the key figures click on rules for key figures give suggest
rules, copy save and generate
Click on updating (activate updating)
Select the infostructure set periodic split 1. Daily, 2. Week, 3.
Month, 4. Posting period
Updating 1)No updating,2)Synchronous updating (V1), 3)As synchronous
updating (V2), 4)As synchronous updating (V3),
T.code LBW0 - Connection of LIS Information structures to SAPBW
Information structure : S786
Select the radio button-Setup LIS environment and Execute.
Select the radio button-Generate data source and Execute.
For Delta update:
Select the radio button-Generate updating and Execute
Select the radio button -Activate / deactivate and Execute.
T.code SBIW Display IMG (implementation guide)
Setting for applications specific data source logistics Managing
transfer information structure setup of statistical data applications
specific setup of statistical data perform statistical setup sales.
Choose activity
Setup Orders, deliveries, billing
Choose the activities enter the infostructure (S789), give name of the
run, date of termination, time of termination, No. of tolerated faulty
documents. Then execute
T.code RSA3 Extractor checker
Give the data source name eg. 2LIS 01S789 and execute, result will
get some records
Go to BW side replicate data source Assign infosource Create
infocube Create update rules create infopackage and schedule the package
with initialize delta process.
For delta update :
In R/3 side
T.code MC25, set update (V1) or (V2) or (V3)
T.code LBW0, choose generate updating and execute then choose
activate / deactivate and execute
BW side - create infopackage and schedule the package with delta
update.
First time if your scheduling the infopackage -in R/3 side T.code :MC25
-Udating set to No update,insted of selecting the update V1,V2,V3.
If your doing the Delta update:in R/3 side T.code :MC25-Updating set to
either V1 or V2 or V3. and the to T.code :LBW0 -Select the radio button
Active/deactivate and Execute.
and schedule the infopackage with delta update.
Regards,
Chandu. -
My confusion with logs in iAS 6.5
Hi everybody,
I am very much confused with the log files in iAS 6.5. Bit lengthy, but Kindly go through this slowly and help me in solving the same.
(1) In the settings -> Control Panel -> Services window, i have enabled "Allow Service to Interact with Desktop".
In the admin tool, i have checked "Enable Server Event Log" check box. I have also enabled the option "Log to console" and selected the message type to be "All Messages".
When i did this, i was able to see the logs as console(command prompt windows). When ever i run a jsp/servlet/EJB containing System.out.println() statements, i was able to see the std out messages in the KJS.exe console. What should i do these std out messages in a file rather than a console?
(2) In the settings -> Control Panel -> Services window, i have enabled "Allow Service to Interact with Desktop".
In the admin tool, i have checked "Enable Server Event Log" check box. I have also enabled the option "Log to File", gave the file name as "logs\ias" and selected the message type to be "All Messages".
When i did this, i saw the following files created under the installdir\ias6\ias\logs.
ias.10817
ias.10818
ias.10819
ias.10820
ias.10821
(10817 - kas port, 10818 - kxs port, 10819 - kjs port, 10820 - kcs port, 10821 - cxs port)
Since, these log files contains the port number of the above mentioned processes, i expected them to be the log files of the processes with corresponding port numbers. For example, ias.10819 to be the log of KJS process, since its port is 10819. Is it correct?
If it is correct, i am not able to see the System.out.println()
messages in this file, though it appears in the console(as mentioned in point 1 ). Why is it?
I want to see all the Std Out messages (which appears in KJS console) in a log file. What should i do for that?
(3) In the iPlanet Application Server Administration guide (Page 90), i found a way to log to a file on Windows platform. As per that document, i changed the IAS_KASLOGFILE from 0 to 1 in the System Variable and restarted the system. It created the file by the name, KAS.log in the installdir/ias6/ias/logs.
Now i was able to see the KAS process's console messages in this log file. But there is nothing written to the KAS console. Why is it?
(4) What is the difference between the log file ias.10817 (created as per in point 2) and KAS.log (created as per in point 3)?
thanks and regards,
desiganHi,
Can you please let me know the resource from where you have got this information ?
Thanks & Regards
Ganesh .R
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support -
RE: (forte-users) Confusion with return event
Samer,
The return event is delivered to the calling task, which is the window in
your first test. It is not deliverd to the event loop of the service object
unless the call to the processor originated in the event loop, which is the
case in your second test. The output you get from the server is exactly as I
would expect.
You need the following code in you client:
event loop
postregister
SomeService1.StartImmediate();
when SomeService1.Proc.ProcessEvent_return do
task.Part.Logmgr.Putline('ProcessEvents_return');
when SomeService1.Proc.ProcessEvent_exception do
task.Part.Logmgr.Putline('ProcessEvents_exception');
end event;
Note that this logoutput will not be written to a logfile, but will appear
in the logwindow which is opened when you start a client application.
Pascal Rottier
Atos Origin Nederland (BAS/West End User Computing)
Tel. +31 (0)10-2661223
Fax. +31 (0)10-2661199
E-mail: Pascal.Rottiernl.origin-it.com
++++++++++++++++++++++++++++
Philip Morris (Afd. MIS)
Tel. +31 (0)164-295149
Fax. +31 (0)164-294444
E-mail: Rottier.Pascalpmintl.ch
-----Original Message-----
From: Samer Kanjo [mailto:skanjoyahoo.com]
Sent: Thursday, January 18, 2001 1:54 AM
To: ForteUsers
Subject: (forte-users) Confusion with return event
I have observed some odd behavior when attempting to
catch a return event for a method invoked using start
task. I provided the primary classes I used during my
test and some output produced by those classes at the
bottom of this message.
The SomeService1 class is used to create an
environment visible service object and the Processor
class is one of its members. The Processor class
starts processing when one of two things happens: the
SomeService1 timer ticks off 10 seconds or when
SomeService1.StartImmediate is called directly by
another entity. Either way StartImmediate is called to
start processing.
The provided output is the result of starting a test
application and invoking StartImmediate from another
object (I used a window) and then observing what
happens when the timer ticks. As you can see the
invocation from the window did not result in the
return event being received. However, the return event
was received when the timer ticked.
According to the Forte documentation a return event
will only be posted to the parent task's event queue.
Since I am making a cross partition call, the window
and service object are not really in the same task
(Unless my assumption is wrong). That would explain
why the window did not cause a return event to be
generated but was an event generated but not caught
and if so where did the event go?
In SomeService2 class I added an event StartProcessing
and moved the code from StartImmediate to the
StartProcessing event case in the event loop and
simply posted the StartProcessing event in
StartImmediate. I performed the same test I used when
testing SomeService1. The Traceback output is
identical for the window invocation but the return
event is received this time! Why?
It seems that to guarantee the receipt of a return
event an asynchronous task must be initiated from
within an event loop. Is this correct?
I do not understand this behavior does someone have
any thoughts on this? How can you guarantee the
receipt of a return event?
Samer Kanjo
OUTPUT FROM SOMESERVICE1
StartTaskTest_cl0: processing loop listening
StartTaskTest_cl0:
Traceback:
SomeService.StartImmediate at line 1
TestWin.Display at line 4
C++ Method(s)
UserApp.Run at offset 105
StartTaskTest_cl0:
StartTaskTest_cl0: Start processing...
StartTaskTest_cl0: Processing complete.
StartTaskTest_cl0:
Traceback:
SomeService.StartImmediate at line 1
SomeService.ProcessingLoop at line 9
StartTaskTest_cl0:
StartTaskTest_cl0: Start processing...
StartTaskTest_cl0: Processing complete.
StartTaskTest_cl0: ProcessEvents_return
OUTPUT FROM SOMESERVICE2
StartTaskTest_cl0: processing loop listening
StartTaskTest_cl0:
Traceback:
SomeService2.StartImmediate at line 1
TestWin.Display at line 4
C++ Method(s)
UserApp.Run at offset 105
StartTaskTest_cl0:
StartTaskTest_cl0: Start processing...
StartTaskTest_cl0: Processing complete.
StartTaskTest_cl0: ProcessEvents_return
StartTaskTest_cl0:
Traceback:
SomeService2.StartImmediate at line 1
SomeService2.ProcessingLoop at line 9
StartTaskTest_cl0:
StartTaskTest_cl0: Start processing...
StartTaskTest_cl0: Processing complete.
StartTaskTest_cl0: ProcessEvents_return
SOMESERVICE1 CLASS
begin CLASS;
class SomeService1 inherits from Framework.Object
has public attribute proc: StartTaskTest.Processor;
has public attribute processing: Framework.boolean;
has public method Init;
has public method ProcessingLoop;
has public method StartImmediate;
has property
shared=(allow=off, override=on);
transactional=(allow=off, override=on);
monitored=(allow=off, override=on);
distributed=(allow=on, override=on, default=off);
end class;
method SomeService1.Init
begin
super.Init();
processing = FALSE;
proc = new;
start task ProcessingLoop();
end method;
method SomeService1.ProcessingLoop
begin
timer : Timer = new;
timer.tickInterval = 10000;
event loop
task.part.logmgr.putline('processing loop
listening');
timer.isActive = TRUE;
when timer.tick do
StartImmediate();
when proc.ProcessEvents_return do
task.part.logmgr.putline('ProcessEvents_return');
processing = FALSE;
when proc.ProcessEvents_exception do
task.part.logmgr.putline('ProcessEvents_exception');
processing = FALSE;
when task.shutdown do
exit;
end event;
end method;
method SomeService1.StartImmediate
begin
task.part.logmgr.putline(task.traceBack());
processing = TRUE;
start task proc.ProcessEvents() where completion =
event;
end method;
end CLASS;
SOMESERVICE2 CLASS
begin CLASS;
class SomeService2 inherits from Framework.Object
has public attribute proc: StartTaskTest.Processor;
has public attribute processing: Framework.boolean;
has public event StartProcessing;
has public method Init;
has public method ProcessingLoop;
has public method StartImmediate;
has property
shared=(allow=off, override=on);
transactional=(allow=off, override=on);
monitored=(allow=off, override=on);
distributed=(allow=on, override=on, default=off);
end class;
method SomeService2.Init
begin
super.Init();
processing = FALSE;
proc = new;
start task ProcessingLoop();
end method;
method SomeService2.ProcessingLoop
begin
timer : Timer = new;
timer.tickInterval = 10000;
event loop
task.part.logmgr.putline('processing loop
listening');
timer.isActive = TRUE;
when timer.tick do
StartImmediate();
when self.StartProcessing do
processing = TRUE;
start task proc.ProcessEvents() where completion =
event;
when proc.ProcessEvents_return do
task.part.logmgr.putline('ProcessEvents_return');
processing = FALSE;
when proc.ProcessEvents_exception do
task.part.logmgr.putline('ProcessEvents_exception');
processing = FALSE;
when task.shutdown do
exit;
end event;
end method;
method SomeService2.StartImmediate
begin
task.part.logmgr.putline(task.traceBack());
post StartProcessing;
end method;
end CLASS;
PROCESSOR CLASS
begin CLASS;
class Processor inherits from Framework.Object
has public method Init;
has public method ProcessEvents where completion =
(return = ProcessEvents_return, exception =
ProcessEvents_exception);
has property
shared=(allow=off, override=on);
transactional=(allow=off, override=on);
monitored=(allow=off, override=on);
distributed=(allow=off, override=on);
end class;
method Processor.Init
begin
super.Init();
end method;
method Processor.ProcessEvents
begin
task.part.logmgr.putline('Start processing...');
task.Delay(msecs = 1500);
task.part.logmgr.putline('Processing complete.');
end method;
end CLASS;
For the archives, go to: http://lists.xpedior.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.comYes, you're right. The return event is queued until the moment that you
actually enter an eventloop. I stand corrected.
Pascal Rottier
Atos Origin Nederland (BAS/West End User Computing)
Tel. +31 (0)10-2661223
Fax. +31 (0)10-2661199
E-mail: Pascal.Rottiernl.origin-it.com
++++++++++++++++++++++++++++
Philip Morris (Afd. MIS)
Tel. +31 (0)164-295149
Fax. +31 (0)164-294444
E-mail: Rottier.Pascalpmintl.ch
-----Original Message-----
From: Adamek, Zenon [mailto:ZAdamekpurolator.com]
Sent: Thursday, January 18, 2001 6:13 PM
To: Rottier, Pascal
Cc: 'forte-userslists.xpedior.com'
Subject: RE: (forte-users) Confusion with return event
I think it is always safe to use start task with where complition = event
clause before event loop. The reason is described in Forte Help in the
Complition Clause index:
"Requesting the return and exception events automatically registers the
events for the calling task. When the asynchronous method completes or
terminates, Forté adds the appropriate event to the calling task's event
queue.
This registration is unlike the event registration for the event statement.
In the event statement, the event is registered just before the event
statement is ready to process the event. In the start task statement, the
return and exception events are registered when the task is started, even
though it can be much later on that your application is prepared to wait for
those events. Therefore, only the "parent" task that executes the start task
statement is registered for the completion event of the started task."
and some comments from "Forte Performance and Patterns" page 18:
"When you use the where completion = event clause in the start task
statement, Forte automatically buffer the return event until you register
for it. Therefore, you do not need to worry about the child task completing
before you register for its return event".
Regards,
Zenon
-----Original Message-----
From: Rottier, Pascal [SMTP:Rottier.Pascalpmintl.ch]
Sent: Thursday, January 18, 2001 11:16 AM
To: 'Samer Kanjo'; ForteUsers
Subject: RE: (forte-users) Confusion with return event
Yes, if you want the eventloop of the service object to be informed when
the
method on the processor class is invoked, regardless of who invoked it,
then
you should simply post an event as the last statement inside the method on
the processor class.
The return events are only used to inform a partent task that a child-task
has completed. So, only the calling task receives the event, only if the
calling task is inside an event-loop at the moment the child-task
terminates
and only if there really is a child task (method started using "start task
Note, that the calling task doesn't have to be inside an event loop when
the
asynchronous call is made. It has to be inside an eventloop when the
asynchronous task terminates. The following piece of code works just as
well:
SomeService1.StartImmediate();
self.DoSomeOtherStuff();
event loop
when SomeService1.Proc.ProcessEvent_return do
task.Part.Logmgr.Putline('ProcessEvents_return');
when SomeService1.Proc.ProcessEvent_exception do
task.Part.Logmgr.Putline('ProcessEvents_exception');
end event;
However, if the asynchronous task started from within "StartImmediate"
finishes before the client gets a chance to enter its event loop, then
you're too late to catch the event. That's why it's safer to use the
"postregister" function, which makes sure a certain action is not started
untill all events from the event loop have been registered.
Pascal Rottier
Atos Origin Nederland (BAS/West End User Computing)
Tel. +31 (0)10-2661223
Fax. +31 (0)10-2661199
E-mail: Pascal.Rottiernl.origin-it.com
++++++++++++++++++++++++++++
Philip Morris (Afd. MIS)
Tel. +31 (0)164-295149
Fax. +31 (0)164-294444
E-mail: Rottier.Pascalpmintl.ch
-----Original Message-----
From: Samer Kanjo [mailto:skanjoyahoo.com]
Sent: Thursday, January 18, 2001 5:04 PM
To: ForteUsers
Subject: RE: (forte-users) Confusion with return event
Pascal,
So you are confirming that a return event can only be
received in an event loop if a task is started from
within that event loop.
After making your proposed changes I was able to
receive the return event in the window.
I originally wanted the SomeService event loop to
always receive the return event regardless of whether
or not StartImmediate is called by some other entity
or called when the timer ticks. It seems that the only
way to do this is with events. Is that correct?
Thank you for insight,
Samer Kanjo
--- "Rottier, Pascal" <Rottier.Pascalpmintl.ch>
wrote:
Samer,
The return event is delivered to the calling task,
which is the window in
your first test. It is not deliverd to the event
loop of the service object
unless the call to the processor originated in the
event loop, which is the
case in your second test. The output you get from
the server is exactly as I
would expect.
You need the following code in you client:
event loop
postregister
SomeService1.StartImmediate();
when SomeService1.Proc.ProcessEvent_return do
task.Part.Logmgr.Putline('ProcessEvents_return');
when SomeService1.Proc.ProcessEvent_exception do
task.Part.Logmgr.Putline('ProcessEvents_exception');
end event;
Note that this logoutput will not be written to a
logfile, but will appear
in the logwindow which is opened when you start a
client application.
Pascal Rottier
Atos Origin Nederland (BAS/West End User Computing)
Tel. +31 (0)10-2661223
Fax. +31 (0)10-2661199
E-mail: Pascal.Rottiernl.origin-it.com
++++++++++++++++++++++++++++
Philip Morris (Afd. MIS)
Tel. +31 (0)164-295149
Fax. +31 (0)164-294444
E-mail: Rottier.Pascalpmintl.ch--
For the archives, go to: http://lists.xpedior.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com
For the archives, go to: http://lists.xpedior.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com
Maybe you are looking for
-
Content Server: External NAS, DB without MS Domain?
Is it possible to configure Content Server for using external NAS and DB without put Content Server in a MS Domain?
-
How do I get Vista to go back to the Windows' Vista generic driver after an Extigy upgrade fiasco
Hello all. First, I'm glad to have the opportunity to be a part of this group. I didn't know it even existed, but here I am...so, let me know what you think. I am a new Windows Vista Ultimate OS owner, and thus far, I'm absolutely thrilled with the a
-
see question above...
-
After installing the package "agfa-fonts-2003.03.19-156.21.noarch.rpm" (for SLES 11.2 DVD) during the printing progress, firefox freezes in about 20 minutes and then page is printed . HW: Intel (R) Core (TM) i5-2450M CPU @ 2.50GHz / 4GB O.S:. SLED 11
-
Bottom half of screen not working, need to turn airplane mode on
3gs Bottom half of screen no longers works, or at least the bar at the bottom so cant unlock the phone .. i suspect that part of the screen doesnt work anymore, tried reset etc. i can play etc via voice control but i need to catch a 7hr flight late