Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Thursday, June 14, 2012

Install JDK 6 in CentOS 5.5




[root@www jvm]# wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6-downloads-1637591.html;" http://download.oracle.com/otn-pub/java/jdk/6u33-b03/jdk-6u33-linux-x64-rpm.bin


[root@www jvm]# mv jdk-6u33-linux-x64-rpm.bin\?AuthParam\=1339658940_4918ae55fd15b9077dd6590269b247c6  jdk-6u33-linux-x64-rpm.bin


[root@www jvm]# sh ./jdk-6u33-linux-x64-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jdk-6u33-linux-amd64.rpm
  inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
Installing JavaDB
Preparing...                ########################################### [100%]
   1:sun-javadb-common      ########################################### [ 17%]
   2:sun-javadb-core        ########################################### [ 33%]
   3:sun-javadb-client      ########################################### [ 50%]
   4:sun-javadb-demo        ########################################### [ 67%]
   5:sun-javadb-docs        ########################################### [ 83%]
   6:sun-javadb-javadoc     ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....


Done.

[root@www jvm]# rpm -Uvh jdk-6u33-linux-amd64.rpm
Preparing...                ########################################### [100%]
        package jdk-1.6.0_33-fcs.x86_64 is already installed

# sh ./jre-6u30-linux-i586-rpm.bin
# alternatives --config java
There are 2 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
Enter to keep the current selection[+], or type selection number:

Note number of versions, N, and use N+1 (if there is no output from the previous command, just imagine that N=0) - For example, if 2 versions were installed then:
# alternatives --install /usr/bin/java java /usr/java/latest/bin/java 3
# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   3           /usr/java/latest/bin/java
Enter to keep the current selection[+], or type selection number: 3
# java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)



For jre;

export JAVA_HOME="/usr/java/jre1.6.0/bin"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"

For jdk;

export JAVA_HOME="/usr/java/jdk1.6.0/jre/bin"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"


When done creating or editing the file type; 

source /etc/profile.d/java.sh

Now any user root or other wise should be able to use the command;

which java

and the results should read something like;

/usr/bin/java


PS: If you want to load the environment variables within java.sh without having to restart the machine, you can use the source command as in:
$> source java.sh


Monday, October 17, 2011

XSS Summary

For Stripes: -

1. Stripes will HTML escape all input tag values. This behavior bypass PopulationStrategy.
2. LocalizableError *fieldValue* will be escaped.
3. SimpleError will *not* be escaped.
4. SimpleMessage and LocalizableMessage will *not* be escaped.

For JSTL: -
1. will escape by default
2. ${..} will *not* escape
3. ${fn:escapeXml(...)} will call escapeXml function to escape the content.

Therefore: -

1. Always use to render output; don't use ${}
2. If you must use ${somevalue}, use ${fn:escapeXml(somevalue)}
3. All args that contain user input String value passed to MessageDisplay or ValidationErrors must be SafeHtmlUtil.HTMLEntityEncode(arg[n]).



XSS Prevention

https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet

Wednesday, April 21, 2010

The top 10 (more or less) J2EE best practices

Always use MVC.
Apply automated unit tests and test harnesses at every layer.
Develop to the specifications, not the application server.
Plan for using J2EE security from Day One.
Build what you know.
Always use Session Facades whenever you use EJB components.
Use stateless session beans instead of stateful session beans.
Use container-managed transactions.
Prefer JSPs as your first choice of presentation technology.
When using HttpSessions, store only as much state as you need for the current business transaction and no more.
In WebSphere, turn on dynamic caching and use the WebSphere servlet caching mechanism.
Prefer CMP Entity beans as a first-pass solution for O/R mapping due to the programmer productivity benefits.




http://www.ibm.com/developerworks/websphere/techjournal/0405_brown/0405_brown.html#author2

Tuesday, April 20, 2010

Session TIme out in Websphere

HTTP Session time-out Override Precedence Summary

The list below shows the precedence from which the final HTTP Session time-out is derived.

1. Server Level Lowest level
2. Enterprise Application Overrides the Server Level if Override is selected
3. Web Application Overrides the Server and Enterprise Application settings if Override is selected
4. Application Level (web.xml) Overrides Server, Enterprise Application, and Web Application settings
5. Application Code Overrides all other settings

In conclusion, we can load session timeout from local db and overide using application code.

For more info, refer  IBM support

Thursday, July 24, 2008

Retro

Operates by transforming Java class files compiled by a 1.5 compiler into version 1.4 class files which can then be run on any 1.4 virtual machine.

Friday, May 02, 2008

Log4j PatternLayout

ConversionPattern =[%d{ISO8601}] %-5p : : %C{1}.%M : %m%n

Conversion Character Effect
c Used to output the category of the logging event. The category conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.

If a precision specifier is given, then only the corresponding number of right most components of the category name will be printed. By default the category name is printed in full.

For example, for the category name "a.b.c" the pattern %c{2} will output "b.c".

C Used to output the fully qualified class name of the caller issuing the logging request. This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.

If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. By default the class name is output in fully qualified form.

For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass".

WARNING Generating the caller class information is slow. Thus, it's use should be avoided unless execution speed is not an issue.

d Used to output the date of the logging event. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}. If no date format specifier is given then ISO8601 format is assumed.

The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat. Although part of the standard JDK, the performance of SimpleDateFormat is quite poor.

For better results it is recommended to use the log4j date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormat, DateTimeDateFormat and respectively ISO8601DateFormat. For example, %d{ISO8601} or %d{ABSOLUTE}.

These dedicated date formatters perform significantly better than SimpleDateFormat.

F Used to output the file name where the logging request was issued.

WARNING Generating caller location information is extremely slow. It's use should be avoided unless execution speed is not an issue.

l Used to output location information of the caller which generated the logging event.

The location information depends on the JVM implementation but usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses.

The location information can be very useful. However, it's generation is extremely slow. It's use should be avoided unless execution speed is not an issue.

L Used to output the line number from where the logging request was issued.

WARNING Generating caller location information is extremely slow. It's use should be avoided unless execution speed is not an issue.

m Used to output the application supplied message associated with the logging event.
M Used to output the method name where the logging request was issued.

WARNING Generating caller location information is extremely slow. It's use should be avoided unless execution speed is not an issue.

n Outputs the platform dependent line separator character or characters.

This conversion character offers practically the same performance as using non-portable line separator strings such as "\n", or "\r\n". Thus, it is the preferred way of specifying a line separator.

p Used to output the priority of the logging event.
r Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event.
t Used to output the name of the thread that generated the logging event.
x Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.
X

Used to output the MDC (mapped diagnostic context) associated with the thread that generated the logging event. The X conversion character must be followed by the key for the map placed between braces, as in %X{clientNumber} where clientNumber is the key. The value in the MDC corresponding to the key will be output.

See MDC class for more details.

% The sequence %% outputs a single percent sign.



ref

Is it possible to direct log output to different appenders by level?

Is it possible to direct log output to different appenders by level?

Yes it is. Setting the Threshold option of any appender extending AppenderSkeleton, (most log4j appenders extend AppenderSkeleton) to filter out all log events with lower level than the value of the threshold option.


ref

Rolling File and errors to email

Log messages with Level info to fatal to a file and send messages from error to fatal by email. The file should be rolled every 100 KB.

You need mail.jar and activation.jar libraries from J2EE to send emails. Further properties of the SmtpAppender are described here:

http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SMTPAppender.html

log4j.properties

### file appender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=100KB
log4j.appender.file.maxBackupIndex=5
log4j.appender.file.File=test.log
log4j.appender.file.threshold=info
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

#email appender
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
#defines how othen emails are send
log4j.appender.mail.BufferSize=1
log4j.appender.mail.SMTPHost="smtp.myservername.xx"
log4j.appender.mail.From=fromemail@myservername.xx
log4j.appender.mail.To=toemail@myservername.xx
log4j.appender.mail.Subject=Log ...
log4j.appender.mail.threshold=error
log4j.appender.mail.layout=org.apache.log4j.PatternLayout
log4j.appender.mail.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.rootLogger=warn, file, mail


ref

Reconfigure a running log4j configuration

If you analyse a problem you frequently want to change the log level of a running application server. This chapter explains how you can do this. I used Tomcat as example server but you can use any application server you like.

The XML actually offers a method to watch changes in config files.

http://logging.apache.org/log4j/docs/api/org/apache/log4j/xml/DOMConfigurator.html#configureAndWatch(java.lang.String)

The problem is that it seems not to work in some situations. But this is no problem as it is quite easy to develop a short tool by yourself. We have two options. We could change the log level during runtime:

Logger root = Logger.getRootLogger();
root.setLevel(Level.WARN);

or we can reload the configuration:

// PropertyConfigurator.configure(url);
DOMConfigurator.configure(url);

The following example will check the configuration file in defined intervals and reconfigure log4j if any changes are found.

We need to create three things:

a) a monitor thread, monitoring the configuration file and reconfiguring log4j if needed

b) a servlet starting and stopping the monitor thread

c) an entry in the web.xml, to initialize the servlet

The following class monitors the logj4 configuration file and checks with the last change date has changed:

package de.laliluna.logexample;

import java.io.File;
import java.net.URL;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.xml.DOMConfigurator;

public class MonitorThread implements Runnable {

private static Logger log = Logger.getLogger(MonitorThread.class);

boolean interruped;

private long checkIntervalMillis = 10000;

private URL url;

private File file;

// stores the last modification time of the file
private long lastModified = 0;

public void run() {
System.out.println("Initialize " + url.getPath());
file = new File(url.getPath());
// PropertyConfigurator.configure(url);
DOMConfigurator.configure(url);
lastModified = file.lastModified();

monitor();
}

private void monitor() {
log.info("Starting log4j monitor");

while (!interruped) {

// check if File changed
long temp = file.lastModified();
if (lastModified != temp) {
log.info("Initialize log4j configuration " + url.getPath());
// PropertyConfigurator.configure(url);
DOMConfigurator.configure(url);

lastModified = temp;

} else
log.debug("Log4j configuration is not modified");
try {
Thread.currentThread().sleep(checkIntervalMillis);
} catch (InterruptedException e) {
interruped = true;
}
}
log.info("Shutting down log4j monitor");

}

public URL getUrl() {
return url;
}

public void setUrl(URL url) {
this.url = url;
}

public long getCheckIntervalMillis() {
return checkIntervalMillis;
}

/**
* Sets the interval for checking the url for changes. Unit is
* milliseconds, 10000 = 10 seconds
*
* @param checkIntervalMillis
*/
public void setCheckIntervalMillis(long checkIntervalMillis) {
this.checkIntervalMillis = checkIntervalMillis;
}

public boolean isInterruped() {
return interruped;
}

public void setInterruped(boolean interruped) {
this.interruped = interruped;
}

}

The servlet starts and stops the monitor thread:

package de.laliluna.logexample;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class Log4jConfigLoader extends HttpServlet {

private Thread thread;

@Override
public void destroy() {
thread.interrupt();
super.destroy();
}

public void init() throws ServletException {
super.init();
MonitorThread monitorThread = new MonitorThread();
monitorThread.setCheckIntervalMillis(10000);
monitorThread.setUrl(Log4jConfigLoader.class.getResource("/log4j.xml"));
thread = new Thread(monitorThread);
thread.start();
}

}

We add the servlet to the web.xml to initialize it.



xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

log4j-init
de.laliluna.logexample.Log4jConfigLoader
10




ref

Wednesday, April 30, 2008

log4j

log4j.rootCategory=debug, rolling
# log4j.rootCategory=warn, stdout, rolling, socketLogger, lf5, xml, lf5Rolling

# Example of adding a specific package/class at a different
# logging level...
# --log everything in the com.johnmunsch package at debug level
# ..even better, send it to a different appender. Note, however, that
# this doesn't mean that any loggers from a lower level won't be used:
# everything still inherits, so this new logger is used _in_addition_to_
# the loggers it would have otherwise already used.
log4j.category.com.johnmunsch=debug, socketLogger

# --on the other hand, everything in the
# com.johnmunsch.stuff class _shouldn't_ log
# unless the log message is at 'warn' level or worse.
# (It just so happens that stuff generates a _lot_ of
# logging when it's used)
log4j.category.com.johnmunsch.stuff=warn

# --also, it just so happens that we have a different
# appender that we're using that we want to have
# log information from a specific location, and we
# don't want to send that information anywhere else.
log4j.category.com.johnmunsch.otherstuff=warn, xml
log4j.additivity.com.johnmunsch.otherstuff=false

# BEGIN APPENDER: CONSOLE APPENDER (stdout)
# first: type of appender (fully qualified class name)
log4j.appender.stdout=org.apache.log4j.ConsoleAppender

# second: Any configuration information needed for that appender.
# Many appenders require a layout.
log4j.appender.stdout.layout=org.apache.log4j.TTCCLayout
# log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout

# Possible information overload?
# log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# additionally, some layouts can take additional information --
# like the ConversionPattern for the PatternLayout.
# log4j.appender.stdout.layout.ConversionPattern=%d %-5p %-17c{2} (%30F:%L) %3x
- %m%n
# END APPENDER: CONSOLE APPENDER (stdout)

# BEGIN APPENDER: ROLLING FILE APPENDER (rolling)
# first: type of appender (fully qualified class name)
log4j.appender.rolling=org.apache.log4j.RollingFileAppender

# second: Any configuration information needed for that appender.
# Many appenders require a layout.
log4j.appender.rolling.File=example.log

log4j.appender.rolling.MaxFileSize=100KB
# Keep one backup file
log4j.appender.rolling.MaxBackupIndex=1

log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
log4j.appender.rolling.layout.ConversionPattern=%p %t %c - %m%n

# Possible information overload?
# log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# additionally, some layouts can take additional information --
# like the ConversionPattern for the PatternLayout.
# log4j.appender.stdout.layout.ConversionPattern=%d %-5p %-17c{2} (%30F:%L) %3x
- %m%n
# END APPENDER: ROLLING FILE APPENDER (rolling)

# BEGIN APPENDER: SOCKET APPENDER (socketLogger)
# Note: if you don't have anything configured to accept the events
# from the socketLogger appender, you'll see an exception on program
# startup (to console), and occasional status messages (to console)
# on if the log4j system has managed to connect to the specified
# socket..
log4j.appender.socketLogger=org.apache.log4j.net.SocketAppender
log4j.appender.socketLogger.RemoteHost=localhost
log4j.appender.socketLogger.Port=4445
log4j.appender.socketLogger.LocationInfo=false
# END APPENDER: SOCKET APPENDER (socketLogger)

# BEGIN APPENDER: LogFactor5 APPENDER (lf5)
# LogFactor5 is a Swing window that directly receives logging messages and
# displays them. It offers filtering, searching etc. similar to Chainsaw or
# Lumbermill but you don't have to use a socket appender so it should be faster
# when the logging display is on the same machine as the program issuing
# messages.
log4j.appender.lf5=org.apache.log4j.lf5.LF5Appender
log4j.appender.lf5.MaxNumberOfRecords=1000
# END APPENDER: LogFactor5 APPENDER (lf5)

# BEGIN APPENDER: XML APPENDER (xml)
# A standard file appender where we have put an XML layout onto the output
# event records. A file put out using this technique can be loaded after
# the fact into Chainsaw for viewing, filtering, searching, etc.
log4j.appender.xml=org.apache.log4j.FileAppender
log4j.appender.xml.file=example_xml.log
log4j.appender.xml.append=false
log4j.appender.xml.layout=org.apache.log4j.xml.XMLLayout
# END APPENDER: XML APPENDER (xml)

# BEGIN APPENDER: LogFactor5 Rolling APPENDER (lf5Rolling)
# Like the XML appender above, this is a specialized format designed to be read
# from a tool. In this case LogFactor5 can load up files in this format for
# after the fact review.
log4j.appender.lf5Rolling=org.apache.log4j.RollingFileAppender
log4j.appender.lf5Rolling.File=example_lf5.log
log4j.appender.lf5Rolling.layout=org.apache.log4j.PatternLayout

log4j.appender.lf5Rolling.layout.ConversionPattern=[slf5s.start]%d{DATE}[slf5s.DATE]%n
%p[slf5s.PRIORITY]%n%x[slf5s.NDC]%n%t[slf5s.THREAD]%n%c[slf5s.CATEGORY]%n
%l[slf5s.LOCATION]%n%m[slf5s.MESSAGE]%n%n
# END APPENDER: LogFactor5 Rolling APPENDER (lf5Rolling)

ref
========================================


# Set root logger level to (ALL, DEBUG, INFO, WARN, ERROR, FATAL).
#log4j.rootCategory=INFO, CONSOLE
#log4j.rootCategory=INFO, CONSOLE, LOGFILE
#log4j.rootCategory=INFO, CONSOLE, LOGFILE, adminLogger
log4j.rootCategory=ALL, CONSOLE, LOGFILE


# -----------------------------
# Setup category logger
# -----------------------------
#log4j.category.com.cv.tibs=ERROR, adminLogger
#log4j.category.com.cv.tibs.enquiry=DEBUG, CONSOLE, LOGFILE, adminLogger
#log4j.category.com.cv.tibs.service.util.TIBSFilter=DEBUG, CONSOLE, LOGFILE, adminLogger
#log4j.category.com.cv.tibs.service.internal=ERROR, adminLogger
#log4j.category.com.cv.tibs.service.internal.util=ERROR, adminLogger
#log4j.category.com.cv.tibs.service.internal.UserEnquiry=ERROR, adminLogger

#log4j.additivity.com.cv.tibs=false


# -----------------------------
# Set the enterprise logger priority to FATAL
# -----------------------------
log4j.logger.org.apache.axis2.enterprise=INFO
log4j.logger.de.hunsicker.jalopy.io=INFO
log4j.logger.httpclient.wire.header=INFO
log4j.logger.org.apache.commons.httpclient=INFO

#log4j.logger.com.cv.tibs=DEBUG
#log4j.logger.com.cv.tibs.service.internal.UserEnquiry=ERROR
#log4j.logger.com.cv.tibs.service.internal=ERROR
#log4j.logger.com.cv.tibs.service.internal.util=ERROR


# -----------------------------
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
# -----------------------------
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
#log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
log4j.appender.CONSOLE.layout.ConversionPattern =[%d{yyyy-MM-dd HH:mm:ss,SSS}] | [%t] | %-5p | %c | %m | %n


# -----------------------------
# LOGFILE is set to be a File appender using a PatternLayout.
# -----------------------------
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
#log4j.appender.LOGFILE.File=axis2.log
log4j.appender.LOGFILE.File=C:\\clicks\\wsear\\axis2.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
#log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
log4j.appender.LOGFILE.layout.ConversionPattern =[%d{yyyy-MM-dd HH:mm:ss,SSS}] | [%t] | %-5p | %c | %m | %n
# Keep 100 old files around.
log4j.appender.LOGFILE.MaxBackupIndex=10
log4j.appender.LOGFILE.MaxFileSize=10240KB

# -----------------------------
# TIBSWS wsAppender
# -----------------------------
# wsLogger is set to be a FileAppender.
log4j.logger.com.cv.tibs.chequemanagement=DEBUG, wsLogger
log4j.logger.com.cv.tibs.enquiry=DEBUG, wsLogger
log4j.logger.com.cv.tibs.favaccountmanagement=DEBUG, wsLogger
log4j.logger.com.cv.tibs.onetimeownft=DEBUG, wsLogger
log4j.logger.com.cv.tibs.remittance=DEBUG, wsLogger
log4j.logger.com.cv.tibs.security=DEBUG, wsLogger
log4j.logger.com.cv.tibs.transaction=DEBUG, wsLogger
log4j.logger.com.cv.tibs.usermanagement=DEBUG, wsLogger
log4j.logger.com.cv.tibs.service.util.TIBSFilter=DEBUG, wsLogger
log4j.appender.wsLogger=org.apache.log4j.RollingFileAppender
log4j.appender.wsLogger.File=C:\\clicks\\wsear\\io.log
log4j.appender.wsLogger.layout=org.apache.log4j.PatternLayout

# Keep 100 old files around.
log4j.appender.wsLogger.MaxBackupIndex=100
log4j.appender.wsLogger.MaxFileSize=10240KB

# Format almost same as WebSphere's common log format.
log4j.appender.wsLogger.layout.ConversionPattern =[%d{yyyy-MM-dd HH:mm:ss,SSS}] %-5p %c %x - %m %n

Monday, November 05, 2007

Looking up an EJB home with JNDI

Sometimes it is more convenient for an application to use a corbaname URL as the lookup name. Container-based JNDI clients and thin Java clients can use a corbaname URL. An example of a lookup with a corbaname URL is also included in this section

JNDI lookup from an application running in a container

  java.lang.Object ejbHome =
initialContext.lookup(
"java:comp/env/com/mycompany/accounting/AccountEJB");

JNDI lookup from an application that does not run in a container

java.lang.Object ejbHome = initialContext.lookup(
"cell/nodes/Node1/servers/MyServer/com/mycompany/accounting/AccountEJB");

Server cluster
java.lang.Object ejbHome = initialContext.lookup(
"cell/clusters/MyCluster/com/mycompany/accounting/AccountEJB");

Fixed qualified names
java.lang.Object ejbHome = initialContext.lookup(
"cell/persistent/com/mycompany/accounting/AccountEJB");

JNDI lookup with a corbaname URL
java.lang.Object ejbHome = initialContext.lookup(
"corbaname:iiop:someHost:2809#com/mycompany/accounting/AccountEJB");


ref



Example: Getting an initial context by setting the provider URL property

You can use two different provider URL forms with WebSphere Application Server's initial context factory:

  • A CORBA object URL (new for J2EE 1.3)
  • An IIOP URL

Using a CORBA object URL

env.put(Context.PROVIDER_URL, "corbaloc:iiop:myhost.mycompany.com:2809");

Using a CORBA object URL with multiple name server addresses

env.put(Context.PROVIDER_URL,
"corbaloc::myhost1:9810,:myhost1:9811,:myhost2:9810");

Using a CORBA object URL from an non-WebSphere Application Server JNDI implementation

env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.somecompany.naming.TheirInitialContextFactory");
env.put(Context.PROVIDER_URL,
"corbaname:iiop:myhost.mycompany.com:9810/NameServiceServerRoot");

Using an IIOP URL

env.put(Context.PROVIDER_URL, "iiop://myhost.mycompany.com:2809");

ref


Wednesday, October 31, 2007

Calling EJB deplyed in Websphere from Standalone Java client

Example :
java -cp /usr/WebSphere/AppServer/properties/:/usr/WebSphere/AppServer/lib/namingclient.jar
-jar TestJndiEJBLookup.jar

Might need this if include EjbClient.jar
\WebSphere\AppServer\lib\j2ee.jar
\WebSphere\AppServer\properties
\WebSphere\AppServer\lib\naming.jar;
\WebSphere\AppServer\lib\namingclient.jar;
\WebSphere\AppServer\java\jre\lib\server.jar


ref

Thursday, September 13, 2007

Notes on creating a Java "jar" file for an application

If you have an appliation that you want to package so that it can be executed using a command like:

        java -jar myjarfile.jar arg1 arg2

you will need to create the ".jar" file properly. This means that the class containing the main method must be identified and that you have included any necessary support ".jar" files. You must also include a class path.

If you are using RAD, u may create "Application Client Project" with contain MyJarFileEar and MyJarFile project.