Randy Gibbons

Greenhorn
+ Follow
since Feb 06, 2005
Merit badge: grant badges
For More
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 Randy Gibbons

Thanks, Annie. Trying a range occurred to me too, but I don't see which operator would do that, since Monson-Haefel explictly says it is not possible to use any comparison operator (=, >, >=, etc.) to compare Date CMP fields (which is what I have) with find/select method input parameters or literal values. If you see something I don't, let me know!

I also have a more general question. As I said in my original posting, my EJB container won't allow CMP fields that don't map to a specific column in the data store. Is that spec-conformant and the way things are, or a limitation in my EJB container (SAP's J2EE Engine). It strikes me as contradicting the idea of the Entity bean as an "abstract persistent schema" that can be used (so I thought) in conjunction with many underlying date stores.
I am learning Entity Beans and EJB QL and have come across the following dilemna. I have a legacy relational db some of whose columns are Java type java.sql.Date. I created an Entity Bean to manage persistence with this table. I created a ejbSelectMethod with the query SELECT OBJECT(b) FROM Booking AS b WHERE b.fld1 = ?1 AND b.fld2 = ?2 AND bl.fld3 = ?3. fld1 and fld2 are strings, but fld3 is type java.sql.Date, and reading Monson-Haefel's Enterprise JavaBeans 4th Ed., I learned that you can't use java.util.Date/java.sql.Date objects in equality comparisons, rather, you must compare dates in long/millis form. I tried defining a CMP field of type long in my Entity bean, but my EJB container won't let me deploy it because the CMP field doesn't have a counterpart in the db table (my EJB container has a vendor-specific deployment descriptor for mapping CMP fields to db columns). Monson-Haefel says you must persist the date in long form rather than Date form, but modifying the definition of my legacy table is not an option. Is there something I can do with my Entity bean CMP fields and/or methods that will allow me to the EJB QL query indicated (with "fld3= ?3" being a comparison of longs)?
Thanks. I had tried that too. Since I posted the note, with some more hacks of the slapd.conf file (to be honest, when I posted the note, I was mistakenly editing the ldap.conf file ), I got around the "invalid credentials" error. I got it to the point where ldapadd was trying to load the tutorial.ldif file but errored out with something like "no attributes new or changed." My problem at this point is that I don't know enough about ldap to even see if there are any roots/databases in there that I can add the tutorial.ldif contents to as a subcontext, or enough to create an o=JNDITutorial root to work off (one or the other is necessary, according to the Preparations part of the JNDI Tutorial). Since my intention was to learn JNDI and not LDAP, I've burned enough time on this unless someone has successfully loaded the tutorial's tutorial.ldif file and can tell me how they did this. (A possible variable in my case is that I installed OpenLDAP as a set of Windows binaries pulled down from the Web, and I don't know if the initial database has any or different content from what one would get building the system from the OpenLDAP source [something no way now how I'm going to try to do!]).
I'm teaching myself elementary JNDI using Sun's JNDI Tutorial. The tutorial has name/file service provider exercises and directory/ldap service provider exercises. No problem with the naming service exercises (using an fs provider service I downloaded from Sun), but question about the ldap (and I know nothing to speak of about ldap):

I'm using SDK 1.4.2, so I've got the ldap service provider built in.I downloaded and installed (on Windows XP) a Win32 bundling of OpenLDAP from Lucas Bergman. To my amazement, my JNDI Tutorial directory service exercises connect to the OpenLDAP server. But the exercises require loading tutorial.ldif into the directory server, and I can't get past an "invalid credentials" error when running ldapadd.exe.

I know the problem concerns the directory server config file ldap.conf and Access Control. I've looked through the Quick Start and man for OpenLDAP and tried to hack out a ldap.conf that works, but I'm working in the blind. If my diagnosis is right, then I'm looking for the simplest but correct ldap.conf, with a superuser who can bind/write anything. Any help appreciated in validating my diagnosis and giving me a ldap.conf I can use.

Here's what I'm putting in at the command line:

I'm prompted for and enter password "secret." I get back an
error message.

Here is my ldap.conf file, copied from an example given in the OpenLDAP manual, with my (perhaps erroneous) changes of Unix directory syntax to that of Windows:

Originally posted by Bear Bibeault:
Oh, on re-reading your post. You are getting a listener to work -- just not the example you are trying to emulate?

Are any tags in the same TLD being loaded?

[ July 22, 2005: Message edited by: Bear Bibeault ]



Yes, I did get a listener declared in a TLD to work, just not the example from Marty's book. That listener worked fine too, when declared in the web.xml. And yes, the tag declared in the same TLD is working.
[ July 22, 2005: Message edited by: Randy Gibbons ]
18 years ago
I am implementing the downloaded source code from Chapter 10 (The Application Events Framework) of Marty Hall's "more Servlets and JavaServer Pages." I'm using Tomcat 5.5.7. The initial example illustrating ServletContextListener works fine. But when I remove the declaration of the listener from web.xml to a tag library (company-name-taglib.tld, in the book's example), Tomcat is APPARENTLY not loading the listener or executing its contextInitialized() method. The .tld file is in WEB-INF. I am 99.9% sure my web.xml and .tld files are conforming (I'm certainly not getting any parse errors). And when I create my own analogous but extremely simple example declaring a ServletContextListener from a .tld rather than from the web.xml, it works fine. Has anyone tried Marty's examples? In any case, any hints as to what I should check?

I say APPARENTLY not loading/executing. It was first apparent simply from running the application (null values for attributes that the listener is supposed to initialize). When I try including a "hi it's me" system.out.println statement in the contextIntialized() code, I am finding it doesn't output to Tomcat's log, in this or any other case, though the same statements in my HttpSessionListener's do output to the log. Is this an expected result (system.out.println statements produce output for HttpSessionListener's but not ServletContextListener's) and, if so, why? I then tried writing out a physical file from within my contextInitialized() code instead, and that produces a file for all my ServletContextListener's except the case in point, which seems to confirm that that particular listener is not getting loaded/executed. So a secondary question is, what is the best way, at least in a Tomcat 5.x environment, for knowing that the listener is being loaded/executed (other than inferring this from the runtime results or from debugging via file output)?
18 years ago

Originally posted by Bear Bibeault:


It would create full-compliant XML. That means using CDATA sequences and entities where appropriate.

Which is why I see no advantage to the XML syntax for hand-coded pages. Once you've added all the necessary markup to keep the page legal, it's an unreadable (at least by humans) mass of markup goo that obfuscates the actual content of the page.

YMMV.



Point taken! Even my simple page is indeed an unreadable mass of markup goo. But I can still be curious ...
18 years ago
JSP
Bear B. asks why I am trying to do this. Answer: Just as part of teaching myself Servlets & JSPs. I understand your point and might never use the XML syntax in practice, though the two books I am using -- Marty Hall and Larry Brown's Core Servlets and JavaServer Pages, Second Edition (see chapter 11 on XML syntax) and The J2EE Tutorial, Second Edition (see chapter 13 on JavaServer Pages Documents) -- don't seem to find anything wrong with using it even in a non-auto-generated development environment. The Tutorial even suggests some advantages.

Sushma: In my original post I attempted to say that I had already tried the character entity 'ambersand lt ;' (which, as in your original reply, got translated into '<'!). The point was that when I do that, I get a syntax error (i.e., the XML parser now recognizes the validity of my <jsp:scriptlet>...</jsp:scriptlet> start and end tags, but the compiler compiling the Java code between these tags chokes on the character entity, which of course is not valid Java syntax. So my problem remains unsolved. (Going back to Bear's point, I wonder what an auto-generator would do?)
18 years ago
JSP
I am experimenting with the XML syntax alternative in JSPs. in the fragment below, the compiler is tripping up on the "<" in the for loop and concluding that my <jsp:scriplet> element doesn't have a valid end tag. I tried replacing "<" with "<" and my intuition was right that that simply replaces a parsing error with a syntax error. How do I escape the "<" or otherwise do something to eliminate this problem? (I prefer a solution that doesn't involve using the Expression Language.)

<CODE>
...
<TABLE BORDER=1>
<jsp:scriptlet>
Iterator entries = request.getParameterMap().entrySet().iterator();
while(entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
String key = (String) entry.getKey();
String[] values = (String[]) entry.getValue();
for(int i = 0; i < values.length; i++) {
</jsp:scriptlet>
<TR><TD><jsp:expression> key </jsp:expression>
<TD><jsp:expression> values[i] </jsp:expression>
<jsp:scriptlet>
}
}
</jsp:scriptlet>
</TABLE>
...
</CODE>
18 years ago
JSP
I see the light, thanks. In my greenhornness, I wasn't distinguishing between the thread object itself and the potentially different Runnable object containing the thread's task.
A mild criticism of Eckel's chapter on Concurrency (Thinking in Java, 3rd Edition), which is my introduction to the topic: Since he has an expressed preference for subclassing Thread rather than using Runnable (since, where appropriate, the Thread subclass can be an inner class and therefore not prevent the outer class from inheriting from something else), he doesn't have many examples using Runnable. Seems to me my confusion would be common among beginners and should be addressed in an introductory text (nevertheless, I find the Eckel book awesome).
I'm off to Borders this afternoon to buy your 3rd edition on Threads.
For those following this "thread," here is a version of "Runnables" that works:
I'm doing my first concurrency exercices. I can't figure out why the following works when my objects subclass Thread but don't when they implement Runnable:

Works:



Doesn't work (seems that notify() never "gets through"):

Thanks! Your code certainly shows all the possibilities. I believe both K&B and Eckel slightly misstate things, in that the OuterClassName in the expression OuterClassName.InnerClassName is NOT required when used in static code of the outer class, and that should probably be explicitly stated. But I bow before the awesomeness of both their books, and I rest content that, as a greenhorn, I got the need for the reference to the outer class and the ref.new syntax down.
19 years ago
Yes, but you'll notice Kathy and Bert define "outside" to include "static method code WITHIN the outer class" (my CAPS). Eckel, in Thinking in Java Third Edition, page 333, says the same thing: "If you want to make an object of the inner class anywhere except from within a non-static method of the outer class [in other words, including from within a static method of the outer class], you must specify the type of that object as OuterClassName.InnerClassName, as seen in main() [where the main() he is referring to is WITHIN the outer class of his exampe]. Similarly, I can omit the OuterClassName from Eckel's example, and it compiles and runs fine. Am I misunderstanding what I am reading?
19 years ago
Kathy Sierra and Bert Bates' "Sun Certified Programmer ... Study Guide" page 462 states that "From outside the outer class code (including static method code within the outer class), the inner class name must now include the outer class name," as in MyOuter.MyInner. I see the same statement in many other books. Yet from static method code within the outer class, I am able to compile and run fine without including the outer class name, as in the following example from p. 463 of the same book:

Explanation?

[I added [ code ] tags - Jim]
[ February 07, 2005: Message edited by: Jim Yingst ]
19 years ago