Google Analytics

 

Wednesday, January 23, 2008

Call Data Source [Websphere] From Java Application

It's 2 Way to Call

1. Use Library From Websphere [Use Rad to Call]

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere .naming.WsnInitialContextFactory"); // Context Name For Call
env.put(Context.PROVIDER_URL, "iiop://localhost:2809/");// IP Address of JNDI Name which you can look at Servers --> Application Server and then Server that use JDBC --> Port (Communications) --> BOOTSTRAP_ADDRESS
InitialContext ctx = new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("jdbc/test");//JNDI Name
PS. You must add Websphere 6.0 Library and JRE [in Websphere]

2. Use Context Sun [But I tested, It still return NULL.]
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi .cosnaming.CNCtxFactory"); // Sun Context
env.put(Context.PROVIDER_URL, "iiop://localhost:2809/");// IP Address of JNDI Name which you can look at Servers --> Application Server and then Server that use JDBC --> Port (Communications) --> BOOTSTRAP_ADDRESS
InitialContext ctx = new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("cell/nodes/Node01/servers/server1/jdbc/test"); //JNDI Name [You call Real Path] --> cell/nodes/< node Name > /servers/< server Name >

Friday, September 7, 2007

Problem Scheduler on Websphere 6.1

This problem about when you deploy application on websphere 6.1 that has many application server (example server1, server2 and server3) after that scheduler can't run.
Because of scheduler add wrong server in database.
You can check in xxx__SCHED_LMGR at LEASEOWNER Column --> This column has value that same server which you deploy application (Example TESTCell01\TESTNode01\server1) and then you delete it until It show the same server that you deploy.

Thursday, June 14, 2007

Example Config Network (For Web Server and Application Server)


From picture, It has two zone (Web Zone and Application Zone)
1. Web Server, It has IP in Lan --> 10.221.7.120 but it access from outside IP 172.20.3.1 (Internet IP) . Sometimes, it will be other system protect (ex. firewall) . The other side which it will access Application Server, it has IP 192.168.0.50(Intranet IP).
2. In case Websphere, It will not load balance between Web Server and Application Server because Websphere can operate load balance itself.

Tuesday, June 12, 2007

How do you check firewall for allow application server or web server

1. Check IP, It can access from internet, intranet or network
- In Network, It can not access from internet to this network. It can access in this network only. (ex. 10.1.1.1)
- In Intranet, It is IP of organization. It use to access in organization.
- In Internet, It can access everywhere.
2. In case Application Server and Web Server, it following
- If your server access outside, you must allow firewall --> Application Server Side.
- If everyone must access your server, You must allow firewall --> Web Server Side.
3. In case Cluster, You must allow firewall --> All server in Cluster.
4. In case Load Balance, You must allow firewall --> at load balance.

Wednesday, June 6, 2007

Method to check Connection of WSDL (On RAD 6.0)

1. Checking Connection by telnet command

#telnet [IP Address] [Port]

If it doesn't timeout, it connection to server is work.
2. Checking for HTTPS. If it is https, it can trust certification (It should trust certification on Server). You can config on Websphere 6.1 following by this link.
3. Test WSDL by right click at wsdl file then select "Web Services a Test with Web Services Explorer"
4. If it test pass in choice 3, then we will generate stub file for call Web Service.--> right click at wsdl file then select "Web Services a Generate Java bean" skeleton and next.
Example Code For Call Web Service
UMarket_PortType service = new UMarket_PortTypeProxy();
StandardBizRequest request = new StandardBizRequest();
StandardBizResponse response = service.activate(request);

4. If you can't call Web Service (Exception about Exception BeanDeSerializable) , you will generate stub file in Eclipse (RAD 6.0 --> axis is old).
Example Code For Call Web Service
PctVoiceFaxServiceSoapBindingStub stub = null;
VoiceFaxServiceServiceLocator locator = new VoiceFaxServiceServiceLocator();
VoiceFaxService faxservice = locator.getPctVoiceFaxService(new java.net.URL(faxURL));
stub =(PctVoiceFaxServiceSoapBindingStub)faxservice;


PS. In case, you ca find wsdl menu. it can add at
1. Window --> Preferences
2. go to Workbence --> Capabilities
3. select all in Web Service Developer

Tuesday, June 5, 2007

Config Trust Certification On Websphere 6.1

It have 2 mehod
1. Reading from IP and Port that you want to certification.
2. use .cer file for adding to server.

Method of adding certification on websphere 6.1
1. Click Menu Security --> SSL certificate and key management
2. Click Key stores and certificates
3. Select NodeDefaultTrustStore
4. Click Signer certificates
5. you can select
     5.1 Retrieve from port --> Using websphere 6.1 retreive from server that you want certification.
     5.2 Config Port --> Using .cer file that you write path (.cer file) for trust certification.
6. Restart Web Server, It will success.

PS. It should only trust certification on Server but shouldn't trust certification on Application.

Monday, June 4, 2007

Solve Problem Broken Pipe on Websphere 6.1

When I use datasource on Websphere, It will broken pipe. It will happen because database is back firewall or router (Set drop connection when connection is ideal.).
I solve by I test connection (every 10 second.) --> It work but system will performance drop.

In Websphere 6.x, Solve following
1. In Admin Console, Going to Resource --> Datasource --> Name of Datasource
2. Click WebSphere Application Server data source properties
3. Select Pretest connection properties (For Config Test Connection)

Config Encode UTF-8 On Websphere 6.1

Java Encode UTF-8 On Websphere 6.1
1. Select Application Server --> choose server that you will change encode.
2. After that select Java and Process Management (in section Server Infrastructure) --> Process Definition
3. After that select Java Virtual Machine (in section Additional Properties)
4. Add data in Generic JVM arguments, It use -Dclient.encoding.override=UTF-8
5. Save then Application Server will encode UTF-8.

Sunday, June 3, 2007

Processing Create .SFF file Format (Structured Fax Format)

It will create from pdf file --> tiff file --> sff file. Important for tiff file, it will only width = 1728 . If you are not use this width, It may not work. Use Library
1. Use iText for create PDF File --> download
2. Use JAI (Java Advance Imaging) For Convert PDF to TIFF File --> download
3. Use mms-computing (mmsc) For Convert TIFF to SFF File --> download

Step Create SFF File
1. Create PDF File.

Example
String filename = "pdfTest.pdf";
Rectangle rectangler = new Rectangle(1728,2292);
Document document = new Document(rectangler);
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(new Paragraph("Hello World",new Font(Font.BOLD,75)));
document.close();


2. Convert PDF to TIFF File.


Example
PdfDecoder decoder = new PdfDecoder();
decoder.openPdfArray(bai);
decoder.setSize(100, 100);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (decoder.isFileViewable()) {
try {
for (int i = 0; i < decoder.getPageCount(); i++) {
int pageNumber = i + 1;
BufferedImage imageTemp = decoder.getPageAsImage(pageNumber);
BufferedImage image = new Binarization(50).filter(imageTemp);
TIFFEncodeParam tiff = new TIFFEncodeParam();
OutputStream outp = (new FileOutputStream("tiffTest.tiff"));
ImageEncoder encoder = com.sun.media.jai.codec.ImageCodec.createImageEncoder("tiff", outp, tiff);
encoder.encode(image);
outp.close();
}
} finally {
if (baos != null) {
baos.flush();
baos.close();
}
}
}
decoder.closePdfFile();


3. Convert TIFF to SFF File. I use open TIFF File and save to SFF File. You can find it by see at uk.co.mmscomputing.application.imageviewer.ImageTab class --> Method save and open.