Recent Notes

Displaying keyword search results 41 - 49
Created by Dr. Xi on September 20, 2009 16:52:19    Last update: March 22, 2010 01:28:49
When I assemble a session bean without the proprietary deployment descriptor ( orion-ejb-jar.xml ), OC4J generates one like this (as can be seen from the OC4J management console): <?xml version="1.0" encoding="utf-8"?> <ori... So I use this code to lookup the EJB: import javax.naming.Context; import javax.namin... OC4J throws ClassCastException : java.lang.ClassCastException: com.evermind[Oracle ... The JNDI browser (OC4J container home -> Administration -> JNDI browser) shows that the name simpleEjb_SimpleBeanLocal is bound to: com.evermind.server.ejb.StatelessSessionDefaultLocalHomeImpl Solution: Change the local name in the OC4J generated orion-ejb-jar.xml to simpleEjb_SimpleBeanLocal2 and put it in the EJB package. Redeploy. The JNDI browser shows that simpleEjb_SimpleBeanLocal is still bound to com.evermind.server.ejb.StatelessSessionDefaultLocalHomeImpl . But simpleEjb_SimpleBeanLocal2 is bound to the right proxy: SimpleBean_LocalProxy_5f4b5e5 .
Created by Dr. Xi on February 10, 2010 23:39:37    Last update: February 10, 2010 23:39:37
Example web.xml that includes most frequently used elements. This sample is for Servlet Specification 2.4. <?xml version="1.0" encoding="UTF-8"?> <web-ap...
Created by Bambi on August 07, 2009 03:47:56    Last update: August 07, 2009 03:59:15
Code: package hello.world; // package declaration, must ... Compile/Run: C:\tmp>javac hello\world\HelloWorld.java C:\tmp... Since the class is not public (package access), the name of the Java file could be anything! If a package access class has a public static void main(String[]) method, it may still be run from the command line using the class name. C:\tmp>copy hello\world\HelloWorld.java hello\worl...
Created by James on July 05, 2009 02:21:15    Last update: July 05, 2009 02:25:20
This is a JavaScript wrapper for Bare Naked App's progress bar. As usual, download their images and add this to the CSS: img.progressBar { background: white url(images... Then, add my JavaScript function, which takes a parent HTML element as input and returns the progress bar object with a setValue method: function createProgressBar(elem) { var img = d... Test code: <html> <head> <!-- setup code START --> ...
Created by Dr. Xi on February 09, 2009 23:14:15    Last update: February 09, 2009 23:14:15
This example demonstrates the general steps in creating a custom Java class loader. Normally a class loader would consult its parent class loader when asked to load a class. If it's not loaded by the parent class loader, then the class loader would try to load the class on its own. This class loader tries to load the requested class on its own first, and delegates to the parent only when a java.lang.SecurityException is thrown (which happens when it tries to load core Java classes such as java.lang.String ). The classes are loaded from CLASSPATH through the getResourceAsStream call. It's important to note that when a class is loaded with a certain class loader, all classes referenced from that class are also loaded through the...
Created by Dr. Xi on November 20, 2008 00:35:38    Last update: November 20, 2008 00:36:43
This is from: Using and Programming Generics in J2SE 5.0 There are three types of wildcards: "? extends Type": Denotes a family of subtypes of type Type. This is the most useful wildcard "? super Type": Denotes a family of supertypes of type Type "?": Denotes the set of all types or any As an example of using wildcards, consider a draw() method that should be capable of drawing any shape such as circle, rectangle, and triangle. The implementation may look something like this. Here Shape is an abstract class with three subclasses: Circle , Rectangle , and Triangle . public void draw(List<Shape> shape) { for(Sha... It is worth noting that the draw() method can only be called on lists of Shape and cannot be...
Created by Dr. Xi on September 05, 2008 22:58:01    Last update: September 07, 2008 03:25:24
Java introduced annotations since JDK1.5. Annotations are used to decorate code and can be applied to declarations of classes, fields, methods, and other program elements. They are not part of the code per se, but frequently used to apply external logic to the code being annotated. An "Annotation Type" must accompany each type of annotation. For example, the following code will fail compilation: public class TestAnnotation { @deprecated ... Changing @deprecated to @Deprecated with an upper case D will fix the problem, since @Deprecated is a built in annotation type. There are three built in annotation types: @Deprecated , @Override , and @SuppressWarnings . This is an example of a user defined annotation (the file must be named Test.java ): import java.lang.annotation.*; /** * In......
Created by Dr. Xi on January 09, 2008 03:47:31    Last update: August 31, 2008 16:33:28
Many times I need to test some JavaScript snippet before writing code. Maybe I forgot how some JavaScrpit function is supposed to work, maybe I saw some tricky JavaScript code and needed to figure out how it worked. I used MS scripting host for while, but found it cumbersome. Plus, DOM objects are not available in the scripting host. Below is a simple HTML page I created for this task. You can use the Logger.debug method to output debugging messages. <html> <head> <script language="JavaScript" ... For example, if you enter Logger.debug(unescape('http%3a%2f%2fwww.56.com%2fn... into the text area and click "Execute", you get the following output: http://www.56.com/n_v166_/c33_/17_/ bcd [obj...
Created by Dr. Xi on September 30, 2007 21:25:45    Last update: September 30, 2007 21:25:45
Here's some python code to reduce a list to a string: a = ['a', 'string, 'array'] # method 1 ...
Previous  1 2 3 4 5 Next