發表文章

目前顯示的是 10月, 2011的文章

What is different between Thread.currentThread().getContextClassLoader() and Class.getClassLoader()?

From API document, the Thread.currentThread().getContextClassLoader() returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator of the thread for use by code running in this thread when loading classes and resources. The default is the ClassLoader context of the parent Thread. The context ClassLoader of the primordial thread is typically set to the class loader used to load the application. The context ClassLoader can be set when a thread is created, and allows the creator of the thread to provide the appropriate class loader to code running in the thread when loading classes and resources.  For example, JNDI and JAXP used thread's ClassLoader. You had better to use thread's ClassLoader in your own code when your code need to deployed on J2EE container. The Class.getClassLoader() returns the class loader for the class. Some implementations may use null to represent the bootstrap class loader. This method will return

NoClassDefFoundError vs ClassNotFoundException

The difference from the Java API Specifications is as follows. For ClassNotFoundException : Thrown when an application tries to load in a class through its string name using: The forName method in class Class . The findSystemClass method in class ClassLoader . The loadClass method in class ClassLoader . but no definition for the class with the specified name could be found. For NoClassDefFoundError : Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found. So, it appears that the NoClassDefFoundError occurs when the source was successfully compiled, but at runtime, the required class files were not found. This may be some

Clone database on SQL Server

Method 1: In the SQL Server Management Studio: Right click on the database  Select Tasks Select Copy Database... Follow the step in the Copy Database Wizard Method 2: In the SQL Server Management Studio: Right click on the database Select Tasks Select Back Up... Select the desire database and back up the database to disk Right click on the "Databases" and select New Database... Create a new database with the desire name. Right click on the newly created database Select Tasks Select Restore > Database... to restore the database Select From device to look up the image file.

Remove SQL Server database from single-user mode

Turn off the single-user mode of the database by the following statement: ALTER DATABASE [db_name] SET MULTI_USER WITH NO_WAIT OR exec sp_dboption 'db_user', 'single user', 'FALSE'   If the process is deadlocked, please kill the processed by: select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid where d.name = 'jasper_db_sit' go kill spid

java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser

When you encounter the following error that related to web service. java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser Solution 1: Ensure no xercesImpl.jar in your classpath since the implementation of xerce is built-in wiht JAVA SE 1.6. Solution 2: Use XmlJavaTypeAdapter [ @XmlJavaTypeAdapter(JaxbDateAdapter.class)] to convert XMLGregorianCalendar type to Date type. XMLGregorianCalendar is the built-in Java data type for JAXB mapping with datetime. Example: Binding.xjb <?xml version="1.0" encoding="UTF-8"?> <bindings xmlns="http://java.sun.com/xml/ns/jaxb"                 xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"                 xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"                 xsi:schemaLocation=" http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/binding

Deployment problem casued maven auto generated application.xml

When you encounter  exception like the following Target state: deploy failed on Cluster CmsappsvCorpBrsmainPrd java.io.FileNotFoundException: File not found The application.xml in your ear maybe stating a wrong war or jar file. This is caused by the application.xml that generated by maven automatically. Please remove to remove this application.xml before building ear file.

Force windows to use a specific network connection

  When more than one network connection is available, Windows uses the one with the lowest metric value. By default, it automatically assigns a metric value based on the network connection's rated speed. See An explanation of the Automatic Metric feature for Internet Protocol routes . To force Windows to use a specific network connection, assign a metric value to each one, giving the lowest value to the desired connection: Open the Network Connections folder (Start > Run > ncpa.cpl) Right click the desired connection. Click Properties > Internet Protocol Version 4. Click Properties > Advanced. Un-check "Automatic metric". Enter a number between 1 and 9999 for the "Interface metric".

Enable nview for geforce on windows 7

Download the Quadro driver from http://www.nvidia.com. Extract the driver by Winrar or 7zip. In the nview folder, create a shortcut for nviewsetup.exe Add -f in the target. Run the shortcut.