Recent Notes

Displaying notes 101 - 110
Created by Dr. Xi on March 22, 2010 01:50:49
The class org.apache.xerces.jaxp.SAXParserFactoryImpl extends javax.xml.parsers.SAXParserFactory , so casting the former to the latter should not be a problem. This error occurs when there are two copies of javax.xml.parsers.SAXParserFactory loaded by two different class loaders, and you are trying to cast one to the other. Normally, you'll be able to find xml-apis.jar under WEB-INF/lib of the WAR file. Deleting the jar will resolve the problem. java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source) at org.apache.commons.digester.Digester.getFactory(Digester.java:478) at org.apache.commons.digester.Digester.getParser(Digester.java:683) at org.apache.commons.digester.Digester.getXMLReader(Digester.java:891) at org.apache.commons.digester.Digester.parse(Digester.java:1591) at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java:1144) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:328) at javax.servlet.GenericServlet.init(GenericServlet.java:242)
Created by nogeek on March 21, 2010 20:30:53    Last update: March 21, 2010 20:37:53
Port 8080 is undoubtedly overused. You may want to change JBOSS to a port other than the default 8080. Edit the file $JBOSS_HOME/server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml and change the webserver port from 8080 to 8088: <bean class="org.jboss.services.binding.ServiceBindingMetadata"> <property name="serviceName">jboss.web:service=WebServer</property> <property name="port">8088</property> <property name="description">JBoss Web HTTP connector socket; also drives the values for the HTTPS and AJP sockets</property> <!-- Inject a XSLT transform configuration (see below) that describes how to transform server.xml If the binding value request doesn't require an XSL Transform, this config will be ignored. --> <property name="serviceBindingValueSourceConfig"><inject bean="JBossWebConnectorXSLTConfig"/></property> </bean> The XSLT at the bottom of the file transforms port 8080 in $JBOSS_HOME/server/default/deploy/jbossweb.sar/server.xml to 8088 specified in this file.
Created by nogeek on March 21, 2010 20:13:48    Last update: March 21, 2010 20:23:41
Download JBoss from http://www.jboss.org/jbossas/downloads/ Set environment variables JAVA_HOME and JBOSS_HOME Open a command prompt and enter %JBOSS_HOME%\bin\run.bat ( $JBOSS_HOME/bin/run.sh on *nix). Drop your WAR or EAR file into %JBOSS_HOME%\server\default\deploy
Created by Dr. Xi on March 18, 2010 21:37:41
You run an update and it hangs. Use this query to find out who's locking the table. select o.object_type, o.object_name, DECODE(v.locked_mode, 1, 'no lock', 2, 'row share (SS)', 3, 'row exclusive (SX)', 4, 'shared table (S)', 5, 'shared row exclusive (SSX)', 6, 'exclusive (X)') lock_mode, v.oracle_username, v.os_user_name, v.session_id from all_objects o, v$locked_object v where o.object_id = v.object_id;
Created by James on March 16, 2010 16:55:51    Last update: March 16, 2010 19:29:28
I had this seemingly innocent code that did not work: <html> <body> <script language="JavaScript" type="text/javascript"> function sameAsInputName() { alert('This does not fire!'); } </script> <form> <!-- onclick handler can't have the same name as field name --> Click the radio buttons: <input type="radio" value="Y" name="sameAsInputName" onclick="sameAsInputName();">Yes <input type="radio" value="N" name="sameAsInputName" onclick="sameAsInputName();">No <form> </body> </html> I fired up the Chrome JavaScript console and it told me that: Uncaught TypeError: object is not a function . When the name sameAsInputName appeared in the inline event handler, the browser thinks that it refers to the input field(s), not the JavaScript function! It works as expected if you attach the event handler later: <html> <body> <script language="JavaScript" type="text/javascript"> function sameAsInputName() { alert('This does not fire!'); } </script> <form> <!-- ...
Created by Fang on March 03, 2010 05:16:40    Last update: April 02, 2010 16:30:03
Implicit variables are always available to JSTL - you don't need to set them before using them. Page context: pageContext pageContext properties: Name Type Description page javax.servlet.Servlet The current servlet request request javax.servlet.ServletRequest The current servlet request response javax.servlet.ServletResponse The current servlet response servletConfig javax.servlet.ServletConfig The servlet config servletContext javax.servlet.ServletContext The application session javax.servlet.http.HttpSession The current HTTP session Note: request , response etc., is not directly available, you access them with pageContext.request , pageContext.response , etc. Scope variables: pageScope, requestScope, sessionScope, applicationScope Name Type Description pageScope java.util.Map Name-value pair of page scoped variables requestScope java.util.Map Name-value pair of request scoped variables sessionScope java.util.Map Name-value pair of session scoped variables applicationScope java.util.Map Name-value pair of application scoped variables Parameters, HTTP headers and cookies: param, paramValues, header, ...
Created by Dr. Xi on March 02, 2010 00:07:48
OC4J didn't offer much help in the console. This is all it displayed: 2010-03-01 15:48:21.372 ERROR J2EE EJB-03027 [FabulousApp] An error occured deploying EJB module: com.evermind.server.ejb.exception.DeploymentException: [FabulousApp:TheEJBModule] - Exception creating EntityManagerFactory using PersistenceProvider class org.hibernate.ejb.HibernatePersistence for persistence unit DefaultPU. 10/03/01 15:48:21 WARNING: Application.setConfig Application: FabulousApp is in failed state as initialization failed. java.lang.InstantiationException: Error initializing ejb-modules: [FabulousApp:TheEJBModule] - Exception creating EntityManagerFactory using PersistenceProvider class org.hibernate.ejb.HibernatePersistence for persistence unit DefaultPU. 2010-03-01 15:48:21.403 WARNING J2EE OJR-00013 Exception initializing deployed application: FabulousApp. Application: FabulousApp is in failed state as initialization failed However, in the em console, Logs -> Diagnostic Logs gives more details: Message Text [FabulousApp] An error occured deploying EJB module: com.evermind.server.ejb.exception.DeploymentException: [FabulousApp:TheEJBModule] - Exception creating EntityManagerFactory using PersistenceProvider class org.hibernate.ejb.HibernatePersistence for persistence unit DefaultPU. Supplemental Text ...
Created by Dr. Xi on February 24, 2010 21:13:05    Last update: February 24, 2010 21:19:54
This program demonstrates the use of the java.nio package to implement a single thread echo server. import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.*; public class EchoServer { private InetAddress addr; private int port; private Selector selector; private Map<SocketChannel,List<byte[]>> dataMap; public EchoServer(InetAddress addr, int port) throws IOException { this.addr = addr; this.port = port; dataMap = new HashMap<SocketChannel,List<byte[]>>(); startServer(); } private void startServer() throws IOException { // create selector and channel this.selector = Selector.open(); ServerSocketChannel serverChannel = ServerSocketChannel.open(); serverChannel.configureBlocking(false); // bind to port InetSocketAddress listenAddr = new InetSocketAddress(this.addr, this.port); serverChannel.socket().bind(listenAddr); serverChannel.register(this.selector, SelectionKey.OP_ACCEPT); log("Echo server ready. Ctrl-C to stop."); // processing while (true) { // wait for events this.selector.select(); // wakeup to ...
Created by Dr. Xi on February 18, 2010 21:17:34
-- add a foreign key to abother table alter table BOOKS add constraint BK_ATHR_FK foreign key (AUTHOR_ID) references AUTHORS (AUTHOR_ID); -- add a foreign key to same table -- PARENT_MENU_ID is a foreign key to primary key MENU_ID alter table MENUS add constraint MENU_MENU_FK foreign key (PARENT_MENU_ID) references MENUS (MENU_ID);
Created by Dr. Xi on February 18, 2010 21:04:13
-- disable foreign key alter table my_table disable constraint mytbl_col_othr_tbl_col_fk; -- enable foreign key alter table my_table enable constraint mytbl_col_othr_tbl_col_fk;
Previous  6 7 8 9 10 11 12 13 14 15 Next