cktechnical
Friday, January 28, 2005
 
IBM WebSphere Session Management
We have multiple WAR projects that we want to have share a single login. That means that we must share the session object throughout all of our web applications. Ibm websphere allows us to do this by enabling a "Shared session context" on the overview tab of the Application Deployment Descriptor in Ibm Webpshere Studio. We must include all of our WAR projects under this main Application but then we will be able to share our session data between our applications.

IBM WebSphere Session Management: "Shared Session Context

Before leaving the session management options, there is one additional option that can be configured in the Application Server Toolkit (ASTK), WebSphere Studio, or the Application Assembly Tool (AAT). This is a J2EE extension that allows for the session object to be shared across the multiple Servlet contexts inside a single enterprise application. While this is a useful option when migrating pre-J2EE applications (Servlet 2.1) to J2EE compliance, we recommend that this be avoided if at all possible. Sharing session in this fashion tends to lead to large session objects that in turn are usually detrimental to application performance. This option is enabled in the ASTK or Studio by selecting the check box indicated in Figure 22-6.

Figure 22.6Figure 22-6 Session sharing option in ASTK.
Distributed Sessions

As previously noted, distributed sessions provide for failover in case of application server outage, allowing an end user to continue using a web site without any loss of an application state that could require a re-login or navigation through previously viewed pages. While local sessions only provide for a single copy of the session object, distributed sessions provide at least one copy of the session object in addition to the local copy that is cached in the application server JVM. It's worth mentioning that aside from ensuring that the information placed into the HTTP session is serializable, there's no impact to application development when choosing to use this option."
Friday, January 21, 2005
 
MimeMessages sending them with Spring
Alright, so I am charting new territory. I have my shiny new SMTP server up and running and I am currently testing the Spring email functionality. So far this is what I have for a test:

public void send(){
final FileSystemResource res = new FileSystemResource(new File("c:/girls2.jpg"));
if(res == null){
System.out.println("The resource is null!");
}else{
System.out.println(res.getFile().getAbsolutePath());
}
mailSender.send(new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws MessagingException {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8");
message.setFrom("chriskwiatkowski@charter.net");
message.setTo(new InternetAddress("chriskwiatkowski@charter.net"));
message.setSubject("my subject");
message.setText("my text <img src='cid:girls2'>", true);
message.addInline("girls2", res );
message.addAttachment("girls2.jpg", res);
}
});
}

I ran this method and so far, not so good. I must be missing something... because when I receive an email it comes out looking like this:

This message contains multimedia content (MIME type=type/unspecified)
that cannot be displayed in your browser. If you have an external player
or plugin that supports this type, you can click here to launch your player.
If you do not have a compatible external player, click the link below.

Multimedia Message: Display parts separately
My initial reaction is that I need to specify a MIME type on this badboy.
The following link was helpful:
http://monkeymachine.co.uk/spring/xref/org/springframework/mail/javamail/MimeMessageHelper.html

Well after trying to find a way to set the MIME Type of the file I was attaching I finally went to the API and started looking at the addAttachment method (good idea looking at the API huh?)
public void addAttachment(String attachmentFilename,

File file)
throws MessagingException
Add an attachment to the MimeMessage, taking the content from a java.io.File.

The content type will be determined by the name of the given content file. Do not use this for temporary files with arbitrary filenames (possibly ending in ".tmp" or the like)!

Parameters:
attachmentFilename - the name of the attachment as it will appear in the mail
file - the File resource to take the content from
Throws:
MessagingException - in case of errors
See Also:
addAttachment(String, org.springframework.core.io.InputStreamSource), addAttachment(String, javax.activation.DataSource)
The key is the part that says file - the File resource to take the content from and the content type will be determined from the name of the given content file. This gave me reason to believe that I needed to move the reference to my file system resource to within the mailSender.send method. Well that didn't work... but then I go to thinking... why am I using a FileSystemResource when the method declaration in the API says I should be using just a File object in the addAttachment method.
Testing ;)
message.addAttachment("girls2.jpg", new File("c:/girls2.jpg"));
Ok so that didn't work.


Try this:
message.addAttachment("girls2.jpg", new FileSystemResource("c:/girls2.jpg"));
Testing ;)

That didn't work... still the same message when I attempt to view the email.

I am giving up for right now... I will come back to this later.

Ok, I have another observation.

I went ahead and sent the very same test message from my UGA email account to my Charter email account and I noticed that their is a difference in the email headers that may or may not be significant in my issue:
multipart/mixed on my UGA email with attachment
multipart/related on my java based test email from JUNIT

Now I am trying to send emails with attachments without using the MimeMessageHelper class.
I got it working with the following code ripped from the JGURU site:

// Define message
MimeMessage message = mailSender.createMimeMessage();
message.setFrom(new InternetAddress("ckwiat@uga.edu"));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress("chriskwiatkowski@charter.net"));
message.setSubject("Hello JavaMail Attachment");

// create the message part
MimeBodyPart messageBodyPart =
new MimeBodyPart();

//fill message
messageBodyPart.setText("Hi");

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);

// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source =
new FileDataSource(new File("c:/girls2.jpg"));
messageBodyPart.setDataHandler(
new DataHandler(source));
messageBodyPart.setFileName("girls2.jpg");
multipart.addBodyPart(messageBodyPart);

// Put parts in message
message.setContent(multipart);

// Send the message
mailSender.send( message );

Now I am really done for a little while... my eyes hurt.


 
SMTP Server
I was attempting to add the option to run an SMTP server on my development machine to IIS on a Windows XP box. Well, IIS didn't appreciate me adding the Simple Mail Transfer Protocol after IIS was installed previously and kept giving me an error that told me that the SMTP service failed to find the specified path: Error 3. So I went ahead and dropped IIS completely off my box and restarted my computer. Then I reinstalled IIS with SMTP selected this time and I got a successful installation! Yay!

The next step was to set up the properties for my SMTP server which involved setting up "Relay Restrictions" under the Access tab of the Default SMTP Virtual Server Properties. I selected the radio button for "Only the list below" and clicked on Add to grant Access to IP Address 127.0.0.1 (localhost). Then I ran my JUNIT test to make sure that the email was flowing freely. It was. I was happy. Now on to appending attachments to my emails.
This link was helpful in diagnosing my issue.
 
Radio Button Sleuth Page
This is an example of how to use javascript to find the value of the checked radio button in a form.

< html >


< head >


< script >


function checkValue() {

var groupLevelArrayLength = document.forms[0].routeToLevel.length;

for(var i = 0; i < groupLevelArrayLength; i++ ){

if(eval("document.forms[0].routeToLevel["+i+"].checked") == true){

var routeToLevel = document.forms[0].routeToLevel[i].value;

}

}

alert("routeToLevel selected is = " + routeToLevel);

return false;

}

</ script >

</ head >

< body >

< form onsubmit = " return checkValue();" >

< input type = " radio" name = " routeToLevel" value = " 100" >

< input type = " radio" name = " routeToLevel" value = " 150" >

< input type = " radio" name = " routeToLevel" value = " 200" >

< input type = " radio" name = " routeToLevel" value = " 300" >

< input type = " radio" name = " routeToLevel" value = " 400" >

< input type = " submit" value = " Check Value" onclick = " return checkValue();" >

</ form >

</ body >

</ html>


Friday, January 14, 2005
 
AmbiguousTableName dbUnit error initializing test for DB2 running against an OS/390 mainframe.
list via 'link external data' to OS/390?: "Open your local DB2 Client Configuration Assistant.
1. Select the db alias name of your OS/390 ODBC connection and click properties.
2. Click Settings.
3. Click Yes and login to DB.
4. Click Advanced.
5. Select the Entirprise tab.
6. Select the Schema List Parameter.
7. Select & Add any specific schema(s) from the available list of schemas on your OS/390 system."

There were no available schemas available in the list when I performed the above steps.


Darn.


Thursday, January 13, 2005
 
Spring Framework :: View topic - OpenSessionInView ignores Hibernate collection insertions
Client client = null;
Iterator clients = getHibernateTemplate().iterate("FROM ClientImpl AS client"
+ " WHERE client.codeClient = ?"
+ " AND client.actif=?",
new Object[] {codeClient, Boolean.TRUE},
new Type[] {Hibernate.STRING, Hibernate.BOOLEAN});
if (clients.hasNext())
client = (Client) clients.next();
return client;

Using Hibernate types.
Tuesday, January 04, 2005
 
SQL30082N Attempt to establish connection failed with security reason "15"
SQL30082N Attempt to establish connection failed with security reason "" ("").

Explanation: The attempt to connect to the remote database server was rejected due to invalid or incorrect security information. The cause of the security error is described by the and corresponding value.

The following is a list of reason codes and corresponding reason strings:

0 (NOT SPECIFIED)
The specific security error is not specified.

1 (PASSWORD EXPIRED)
The password specified in the request has expired.

2 (PASSWORD INVALID)
The password specified in the request is not valid.

3 (PASSWORD MISSING)
The request did not include a password.

4 (PROTOCOL VIOLATION)
The request violated security protocols.

5 (USERID MISSING)
The request did not include a userid.

6 (USERID INVALID)
The userid specified in the request is not valid.

7 (USERID REVOKED)
The userid specified in the request has been revoked.

8 (GROUP INVALID)
The group specified in the request is not valid.

9 (USERID REVOKED IN GROUP)
The userid specified in the request has been revoked in the group.

10 (USERID NOT IN GROUP)
The userid specified in the request is not in the group.

11 (USERID NOT AUTHORIZED AT REMOTE LU)
The userid specified in the request is not authorized at the remote Logical Unit.

12 (USERID NOT AUTHORIZED FROM LOCAL LU)
The userid specified in the request is not authorized at the remote Logical Unit when coming from the local Logical Unit.

13 (USERID NOT AUTHORIZED TO TP)
The userid specified in the request is not authorized to access the Transaction Program.

14 (INSTALLATION EXIT FAILED)
The installation exit failed.

15 (PROCESSING FAILURE)
Security processing at the server failed.

16 (NEW PASSWORD INVALID)
the password specified on a change password request did not meet the server's requirements.

17 (UNSUPPORTED FUNCTION)
the security mechanism specified by the client is invalid for this server. Some typical examples:

* The client sent a new password value to a server that does not support the DRDA change password function.
* The client sent DCE authentication information to a server that does not support DCE.
* The client sent SERVER_ENCRYPT or DCS_ENCRYPT authentication information to a server that does not support password encryption.
* The client sent a userid (but no password) to a server that does not support authentication by userid only.

18 (NAMED PIPE ACCESS DENIED)
The named pipe is inaccessible due to a security violation.

19 (USERID DISABLED or RESTRICTED)
The userid has been disabled, or the userid has been restricted from accessing the operating environment at this time.

20 (MUTUAL AUTHENTICATION FAILED)
The server being contacted failed to pass a mutual authentication check. The server is either an imposter, or the ticket sent back was damaged.

21 (RESOURCE TEMPORARILY UNAVAILABLE)
Security processing at the server was terminated because a resource was temporarily unavailable. For example, on AIX, no user licenses may have been available.

User Response: Ensure that the proper userid and/or password is supplied.

The userid may be disabled, the userid may be restricted to accessing specific workstations, or the userid may be restricted to certain hours of operation.

For reason code 17, retry the command with a supported authentication type.

For reason code 20, make sure the authentication mechanism for the server is started, and retry.

sqlcode: -30082

sqlstate: 08001
 
connection pooling using DB2 connect or an application server
Help



DB2 Connect Connection Pooling versus Application Server Connection Pooling

Connection pooling is a must for any web technologies based application that is to support large volumes of transactions. Most web application servers now provide their own way of pooling database connections. For example, both Microsoft(R) MTS (COM+) and IBM WebSphere(R) provide connection pooling.

Application pooling mechanisms implemented by these servers differ significantly from what is provided by the DB2 Connect servers. Since application servers pool connections only for their own use they typically presume that user id, password, isolation levels and so on will be exactly the same for all connections. Even more important, application servers only pool connections initiated by the same process. This means that connections from other machines, users or processes are not pooled. While these application server pooling techniques are effective for reusing connections established by the same instance of an application they are absolutely ineffective for pooling connections from multiple users, servers etc.

Connection pooling, provided by the DB2 Connect servers, is completely application, machine and user independent. Connections from multiple clients, application servers all with different user ids can all reuse each other's connections resulting in a much better utilization of the pooled resources.

Which type of connection pooling is the right one to use? Both. Generally, using both DB2 Connect connection pooling and Application Server connection pooling is a good strategy since they don't interfere with each other. Even when application server connection pooling is enabled, DB2 Connect connection pooling can provide connection reuse for multiple application servers as well as other clients using the DB2 Connect server.


Powered by Blogger