Friday, August 5, 2011
Tuesday, August 17, 2010
Session Tracking in Java
Maintaining client sessions is the ability for servers to associate multiple stateless http requests within a single session context. Often, implementing session seems to be magic, but an actual mechanism exists by which this is implemented.
The main requirement for maintaing client sessions is the server's ability to associate one request with a previous request. In order to do this, a session id must be generated and passed back from the server to client. The client will then pass this session id in subsequent requests to associate these with the previous request. The main difference between the various methods of maintaing a session is the form of the session id, such as the way the session id is generated or how it is stored on the client and/or on the server.
Java web servers provide a default implementation using Http Session. However, there are several other ways. The server
1) Using HttpSession
Generation: web server
Client Location: cookies or url
Server Location: web server
Server Location: web server
Java web servers by default can maintain http sessions by generating at request a session id, or the JSESSION_ID. Once the session has been established, the Java web developer can save any type of information in the new session when processing the request. The web server is responsible for storing this session and any saved information without any additional coding. Once the request has been processed, a JSESSION ID is passed back to the browser as a cookie. The browser saves the cookie. On subsequent requests to the same web server, the cookie is passed back to the server, and the web server picks up the session cookie and retrieves the JSESSION ID. Once the session id has been identified, the session associated with the id is set on the request.
2) Encrypt and Decrypt
Generation: servlet
Client Location: cookies
Server Location: N/A
Server Location: N/A
When the client makes a request with a particular user-specific id, the server can generate the session id from this user id. The user id
3) Memcached
Generation: servlet
Client Location: cookies
Server Location: N/A
Server Location: N/A
Tuesday, July 27, 2010
LDAP Modify - Changing your password
File contents: mod_attribute.ldif
dn: uid=mtan,ou=People,dc=mlbam,dc=com
changetype: modify
replace: userPassword
userPassword: {clear text password}
ldapmodify -x -h ldap01.mlbam.com -p 389 -D "uid=mtan,ou=People,dc=mlbam,dc=com" -f /Users/tan/mod_attribute.ldif -W
Enter LDAP Password:
Enter your current password.
Possible outcomes:
additional info: invalid password syntax: no numeric character
This indicates your password must contain a numeric character
additional info: invalid password syntax: dictionary word match
This indicates your new password contains a dictionary word, which is not allowed.
additional info: invalid password syntax: no special character
This indicates your new password must contain a special character.
SASL/EXTERNAL authentication started
ldap_sasl_interactive_bind_s: Unknown authentication method (-6)
additional info: SASL(-4): no mechanism available:
You should use the -x option for simple authentication.
Tuesday, September 29, 2009
Mule 2.x Start Error
Message:
Root Exception stack trace:
oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:418)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
Solution:
The Mule 2.x app does not contain the correct Spring library. Please include the spring-context-2.5.jar
Thursday, August 20, 2009
Wednesday, July 29, 2009
Java Performance Diagnosis Tools
prstat / prstat -mLp
- the last number of each column is the NLWP (number light weight processes aka threads) that are currently active.
- prstat -mLp
will show the current threads for one process. The last column is the LWPID (light weight process ID) - LWPID’s increment by one, hence the highest LWPID indicates how many threads have been launched since process creation.
ps -fLp
- indicates how many threads have been launched since process creation.
truss -f -p /
- new system calls for one thread
/usr/jdk/jdk1.6.0_10/bin/jstatd -J-Djava.security.policy=jstatd.all.policy -p 52074
- starts an rmi server on the local host to be able to monitor application running on this host
/usr/jdk/jdk1.6.0_10/bin/jps -q
- determines the running java processes
Thursday, May 21, 2009
Wednesday, February 11, 2009
Mule 1.x: Spring Integration
Integrating a Spring configuration file into a Mule configuration has been the most frustrating thing in the world... well at least for me.
Mule provides documentation for using Spring with Mule 1.x in the following URL:
http://www.mulesource.org/display/MULEUSER/Using+Spring+as+a+Component+Factory
However, after following these instructions, there are a couple of things that were left undocumented for the spring application context xml to be integrated successfully. The following are these undocumented notes:
So, it seems most of these are related to DTD and XML schema definitions.
Mule provides documentation for using Spring with Mule 1.x in the following URL:
http://www.mulesource.org/display/MULEUSER/Using+Spring+as+a+Component+Factory
However, after following these instructions, there are a couple of things that were left undocumented for the spring application context xml to be integrated successfully. The following are these undocumented notes:
- The Spring application context xml file should not include a XML schema definition. It should specify the Mule-specific DTD.
Example Spring XML:
<beans xmlns="http://www.springframework.org/schema/beans" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
......
</beans>
In order for the Spring XML file to be read successfully by the Mule Server, the above Spring XML file must modified to use the DTD file, and not the XML Schema as follows:
<!DOCTYPE beans PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN"
"http://mule.mulesource.org/dtds/spring-beans.dtd">
<beans>
.......
</beans>
If you do not do this, the Mule server will throw the following exception and cause you frustration beyond belief (jk):
nested exception is org.xml.sax.SAXParseException:: XML-20149: (Error) Element 'beans' used but not declared. - When specifying the <contianer-context> element, remember to define it at the appropriate place in the mule configuration xml.
<!ELEMENT mule-configuration (description?,environment-properties?,mule-environment-properties?,container-context*,security-manager?,
transaction-manager?,agents?,connector*,endpoint-identifiers?,transformers?,global-endpoints?,
interceptor-stack*,model*)
From the above DTD element, the container-context element should be after the mule-environment-properties element and before any connector, transformer, and model elements.
If this is not the case, the Mule Server will throw the following exception:
SAXParseException:: XML-20148: (Error) Invalid element 'container-context' in content of 'mule-configuration', expected elements '[connector, endpoint-identifiers, transformers, global-endpoints, interceptor-stack, model]'.
It will indicate the mule-configuration DTD element that does not even contain the container-context element, which may be quite confusing.
So, it seems most of these are related to DTD and XML schema definitions.
Friday, January 23, 2009
Monday, January 5, 2009
Oracle SQL: Calculating on a Running Window
select t1me, m1n, m1n_1, m1n_2, m1n_3, m1n_4, m1n+m1n_1+m1n_2+m1n_3+m1n_4 fiveminspan from
(select
trunc(record_timestamp,'MI') t1me,
count(*),
LEAD(count(*), 0, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n,
LEAD(count(*), 1, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_1,
LEAD(count(*), 2, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_2,
LEAD(count(*), 3, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_3,
LEAD(count(*), 4, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_4
from REP_OWNER.BAM_MEDIA_REPORT where
record_timestamp > TO_DATE('03/30/2008', 'MM/DD/YYYY') and
record_timestamp < TO_DATE('09/29/2008', 'MM/DD/YYYY')
group by trunc(record_timestamp,'MI')
order by count(*) desc)
(select
trunc(record_timestamp,'MI') t1me,
count(*),
LEAD(count(*), 0, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n,
LEAD(count(*), 1, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_1,
LEAD(count(*), 2, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_2,
LEAD(count(*), 3, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_3,
LEAD(count(*), 4, -1) OVER (ORDER BY trunc(record_timestamp,'MI') ASC) m1n_4
from REP_OWNER.BAM_MEDIA_REPORT where
record_timestamp > TO_DATE('03/30/2008', 'MM/DD/YYYY') and
record_timestamp < TO_DATE('09/29/2008', 'MM/DD/YYYY')
group by trunc(record_timestamp,'MI')
order by count(*) desc)
Wednesday, July 30, 2008
Lesson of the Day: Data Integrity
Often, one needs to make sure that the data of one service/application is not inappropriately saved/cached in another service/application. This ensures the integrity of the data.
A single service/application may be responsible for providing a particular type of data. This data should not be cached or saved in another application. In this way, all data of this type is solely accessed from this application/service. All applications/services requesting this data would have to always retrieve it from this single service/application. Typically, however, other applications/services may reference data within this single application with an identifier or id which can be used and passed to the single service to access the actual original data. Therefore, data the actual data would not be replicated by the other services/application.
If the actual data were to be saved/cached in another application/service in order that the original service does not have to be called and thus improve performance, data integrity cannot be ensured. The data would then inadvertently be saved in two locations. If the data needs to change, one would have to update these two locations to ensure the integrity of the data.
This is a basic notion of application design.
Therefore, one needs to be careful in caching actual data that can be accessed from another service as opposed to simply saving the reference to the data which can be used for accessing the data in the originating service/application.
A single service/application may be responsible for providing a particular type of data. This data should not be cached or saved in another application. In this way, all data of this type is solely accessed from this application/service. All applications/services requesting this data would have to always retrieve it from this single service/application. Typically, however, other applications/services may reference data within this single application with an identifier or id which can be used and passed to the single service to access the actual original data. Therefore, data the actual data would not be replicated by the other services/application.
If the actual data were to be saved/cached in another application/service in order that the original service does not have to be called and thus improve performance, data integrity cannot be ensured. The data would then inadvertently be saved in two locations. If the data needs to change, one would have to update these two locations to ensure the integrity of the data.
This is a basic notion of application design.
Therefore, one needs to be careful in caching actual data that can be accessed from another service as opposed to simply saving the reference to the data which can be used for accessing the data in the originating service/application.
Wednesday, May 21, 2008
Database Views
Views should be created if a query is required for accessing data from multiple tables and multiple rows of multiple tables.
Thursday, May 1, 2008
CORE3282: Crash occurred in function
[01/May/2008:11:05:23] fine ( 6208): Successfully initialized web application environment for virtual server [https-bamws]
[01/May/2008:11:05:35] info ( 6208): CORE3282: stdout: WebappClassLoader: Additional JARs have been added : 'hibernate-3.2.3.jar'
[01/May/2008:11:05:39] info ( 6208): WEB2798: [] ServletContext.log(): WEB3945: Scratch dir for the JSP engine is: /opt/sunone/https-mtan/ClassCache/https-bamws/default-webapp
[01/May/2008:11:05:39] info ( 6208): WEB2798: [] ServletContext.log(): WEB3947: IMPORTANT: Do not modify the generated servlets
[01/May/2008:11:05:44] catastrophe ( 6208): CORE3260: Server crash detected (signal SIGSEGV)
[01/May/2008:11:05:44] info ( 6208): CORE3262: Crash occurred in function pblock*NVPairs::dup()const from module /opt/sunone/bin/https/lib/libns-httpd40.so
Scenario:
I removed all jars from WEB-INF/lib with rm -r *, populated it with a new lib directory, restarted the server and the above error occurred. Restarting the server every time still caused this same error.
I tried to remove all references to this web app in the server.xml file, but the error still occurred.
Cause:
This could have been possibly caused by the removal of jars that while the server was still running. Perhaps, an artifact of the jar remained after subsequent restarts and would continuously cause the crash on the server.
Solution:
I removed the hibernate-3.2.3.jar from this lib directory and the web server now starts without error.
[01/May/2008:11:05:35] info ( 6208): CORE3282: stdout: WebappClassLoader: Additional JARs have been added : 'hibernate-3.2.3.jar'
[01/May/2008:11:05:39] info ( 6208): WEB2798: [] ServletContext.log(): WEB3945: Scratch dir for the JSP engine is: /opt/sunone/https-mtan/ClassCache/https-bamws/default-webapp
[01/May/2008:11:05:39] info ( 6208): WEB2798: [] ServletContext.log(): WEB3947: IMPORTANT: Do not modify the generated servlets
[01/May/2008:11:05:44] catastrophe ( 6208): CORE3260: Server crash detected (signal SIGSEGV)
[01/May/2008:11:05:44] info ( 6208): CORE3262: Crash occurred in function pblock*NVPairs::dup()const from module /opt/sunone/bin/https/lib/libns-httpd40.so
Scenario:
I removed all jars from WEB-INF/lib with rm -r *, populated it with a new lib directory, restarted the server and the above error occurred. Restarting the server every time still caused this same error.
I tried to remove all references to this web app in the server.xml file, but the error still occurred.
Cause:
This could have been possibly caused by the removal of jars that while the server was still running. Perhaps, an artifact of the jar remained after subsequent restarts and would continuously cause the crash on the server.
Solution:
I removed the hibernate-3.2.3.jar from this lib directory and the web server now starts without error.
Monday, April 28, 2008
NoSuchMethodError: javax.xml.parsers.DocumnentBuilderFactory.getSchema()
java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.getSchema()Ljavax/xml/validation/Schema;
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
Cause: You are using a different version of the DocumentBuilderFactory class
Solution:
This version of the javax.xml.parsers.DocumentBuilderFactory is used by the xercesImpl.jar and is defined in the jaxp-api.jar
This class is defined in the following jars:
xml-apis.jar
xmlParserAPIs.jar
xercesImpl-2.8.1.jar
jaxp-api.jar
In addition, this class is also include in the JVM. The JVM implementation of this class does not define a getSchema() method.
The only jar that contains an implementation of the DocmentBuilderFactory with the getSchema() method defined is the jaxp-api.jar. In order for this implementation to be used instead of the JVM's implementation or the other jar's implementation, you must either endorse this jar or put this jaxp-api.jar at the top of the classpath.
NoClassDefFoundError: com/sun/org/apache/xerces/internal/dom/DocumentImpl
java.lang.NoClassDefFoundError: com/sun/org/apache/xerces/internal/dom/DocumentImpl
at java.lang.ClassLoader.defineClass0(Native Method)
..........
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.(SOAPPartImpl.java:63)
at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.(SOAPPart1_1Impl.java:29)
at com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.getSOAPPart(Message1_1Impl.java:52)
at
Cause: Missing a class
Solution:
There are two versions of the xercesImpl.jar that define the different classes in different packages. These packages are the following:
com.sun.org.apache
org.apache
The DocumentImpl class is defined in the following packages of each corresponding jar:
com.sun.org.apache.exerces.internal.dom
org.apache.xerces.dom
The jar that contains the DocumentImpl of the NoClassDefFoundError is contained in the first jar. Please include this jar in the classpath before the second version of the jar.
Reference:
http://mail-archives.apache.org/mod_mbox/xerces-j-users/200407.mbox/%3C40F0D3AD.3050201@sun.com%3E
Monday, April 21, 2008
Mule Error: Application does not seem to be starting or is hanging
Error:
Launching a JVM...
Error [125] in bind() call!
err:: Address already in use
Socket transport failed to init.
Transport dt_socket failed to initialize, rc = -1.
FATAL ERROR in native method: No transports initialized
JVM exited while loading the application.
------------------------------------------------------------------------
The JVM is being launched with a debugger enabled and could possibly be
suspended. To avoid unwanted shutdowns, timeouts will be disabled,
removing the ability to detect and restart frozen JVMs.
------------------------------------------------------------------------
The logs display the above error.
This indicates that the port for debugging is already in use, and not the actual mule application's port.
Change the debug port in the wrapper.conf.
wrapper.java.additional.5=-Xrunjdwp:transport=dt_socket,address=5295,server=y,suspend=y
Launching a JVM...
Error [125] in bind() call!
err:: Address already in use
Socket transport failed to init.
Transport dt_socket failed to initialize, rc = -1.
FATAL ERROR in native method: No transports initialized
JVM exited while loading the application.
------------------------------------------------------------------------
The JVM is being launched with a debugger enabled and could possibly be
suspended. To avoid unwanted shutdowns, timeouts will be disabled,
removing the ability to detect and restart frozen JVMs.
------------------------------------------------------------------------
The logs display the above error.
This indicates that the port for debugging is already in use, and not the actual mule application's port.
Change the debug port in the wrapper.conf.
wrapper.java.additional.5=-Xrunjdwp:transport=dt_socket,address=5295,server=y,suspend=y
Tuesday, April 8, 2008
CSS
So, I'm creating a website and I'm noting some things down about CSS I'm learning from an actual site. Cool dudes.
CSS Styles
position: relative |
color: #ABC123
background-color: #ABC123
font:
font-size: XXXpx | XXX
width: XXXpx
margin: XXXpx
margin-bottom: XXXpx
margin-right:
padding:
text-align: center |
border: XXX
CSS Styles
position: relative |
color: #ABC123
background-color: #ABC123
font:
font-size: XXXpx | XXX
width: XXXpx
margin: XXXpx
margin-bottom: XXXpx
margin-right:
padding:
text-align: center |
border: XXX
Monday, March 31, 2008
Lesson of the Day
"We learn something new everyday!" As a tribute to this saying...
We have this large million of records table. An audit table exists to record every single update or deletion of a row in this table. We were thinking of creating an index on this audit table where no indexes existed before. However, every update/deletion would require an update of this new index, therefore, slowing the performance of write operations on this table.
Lesson of the Day: Indexes, although improves the performance of read operations, leads to more overheard if this table is often updated.
I know i'm dumb..
We have this large million of records table. An audit table exists to record every single update or deletion of a row in this table. We were thinking of creating an index on this audit table where no indexes existed before. However, every update/deletion would require an update of this new index, therefore, slowing the performance of write operations on this table.
Lesson of the Day: Indexes, although improves the performance of read operations, leads to more overheard if this table is often updated.
I know i'm dumb..
Saturday, March 29, 2008
Flex Error: ReferenceError: Error #1065
This error often refers to missing assets in the swf file that is expected to be there. For example, if you get the following error:
Variable ExampleView__embed_mxml__assets_png_example_picture_png_1012766830 is not defined.
It refers to a missing asset in an mxml file called ExampleView attempting to reference a png file as in the VBox below:
<mx:VBox backgroundImage="@Embed(source='/assets/png/example_picture.png')" width="100%"
In this instance, you must remember to include these assets into the compiled swf files.
Variable ExampleView__embed_mxml__assets_png_example_picture_png_1012766830 is not defined.
It refers to a missing asset in an mxml file called ExampleView attempting to reference a png file as in the VBox below:
<mx:VBox backgroundImage="@Embed(source='/assets/png/example_picture.png')" width="100%"
In this instance, you must remember to include these assets into the compiled swf files.
Subscribe to:
Posts (Atom)