tag:blogger.com,1999:blog-39213991341650748782024-03-22T00:16:08.250+02:00Marios' Java Programming Experience CornerExperience on various Java technologies inluding Google App Engine and Google Web Toolkit, and also JSF, JSP, Glassfish, OC4J, MYSql, Oracle DB, NetBeans, Eclipse, JDeveloper and others.komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-3921399134165074878.post-81968111470702798392017-01-06T19:30:00.001+02:002017-01-06T19:30:41.483+02:00Android SQLite GMS Extension<div dir="ltr" style="text-align: left;" trbidi="on">
Hi all.<br /><br />While I was creating a new drawing android game for children, I needed a database implementation to store all the Tales/Scenes/Objects etc. And also I wanted an SQL solution. So I picked up SQLite that is very easy to use.<br />But not for Game Maker Studio!<br />So I had to create an extension. And the result is an Extension for GMS that provides easy access to Android's embedded database library for SQLite (android.database.sqlite). With this extension one can port his SQLite database file with the distribution of his game. <br />The extension provides all the most common functionality of an SQLite DataBase. (e.g. insert, update, delete, query/cursor, create/alter/drop tables/indexes).<br />I am planning on enriching the extension further regarding database upgrades in the future.<br />Special care has been taken to provide fine grained Exception Handling. All Android Java Exceptions are caught and forwarded to Game Maker Studio, so that the game always knows what has happened with the execution of every method. Error Handling messages return either the expected result, or in case of an exception a String with the following Template : {ClassName}:{MethodName}:Exception:{ExceptionMessage].<br />Feel free to contact me if you have any questions or need something more from this extension.<br /><br />You can find the extension here :<br />https://marketplace.yoyogames.com/assets/4969/sqlite-android-gms-extension<br /><br />I hope you will find it as useful as i did! </div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-56152693780959542992016-04-22T13:40:00.000+03:002016-04-22T16:38:48.850+03:00The most valuable tip towards writing highly legible code<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
As programmers/coders we all have to revisit/review/debug our own code as well as others'. Some times the code can be as large as thousands of LoC (=Lines of Code)! Large projects have a large overhead on understanding, before someone is able to add new functionality or fix a bug! Even my own projects seem somewhat incomprehensible at first, when I revisit them after a large period of time! I was always intrigued by simple solutions, but I could never form a few simple guidelines of code legibility that one could follow anywhere, anyhow, with any GUI and with any Framework!<br />
<br />
That was before I read the recently published book <b>"Building Maintainable Software"</b> by <b>Joost Visser</b>. The title does not do the book justice. I would very much prefer the following title :<br />
<b><i>"Simple guidelines that can drive any developer to create highly legible code in any programming language!"</i></b><br />
<br />
The book was a pleasant read. But when I finished reading it, I felt uneasy. I needed to see if the guidelines were as good as they seemed! So I gave the first principle a try. <b>"Keep each method below the threshold of 15 LoC".</b> And that's when the magic happened!<b><br /></b><br />
<br />
I had an opportunity to give this guideline a spin, on a hobby game project I was working on, which was not in Java but in gml (Game Maker's own scripting language). While reviewing my code I realized that I had more than a few methods that counted at 20-30 LoC each. And I always had a feeling of uneasiness whenever I had to add more functionality after a significant anount of development pause! So I started refactoring my code, so that each method was as short as possible (less than 15 LoC). I also tried to keep each method simple and reusable, while trying to come up with good names on my methods. There was not really much difference at first. But when I started adding more functionality to the project, I realized the following :</div>
<div style="text-align: justify;">
<br />
<i>- Revisiting my code was as simple as reading the methods name (given that its name was a good one!)</i></div>
<div style="text-align: justify;">
<i><br />- For those methods that had less of a good naming, revisiting its code was only a matter of seconds</i></div>
<div style="text-align: justify;">
<i><br />- <b>My mind seemed to work faster!</b> I had to work with a lot of functions, but that was not really a problem in the end! Because I did not spend so much time reading and re-reading code until I could get hold of it. I was simply glancing through my methods fast! Very fast! And that was the incredible part! My initial fear that partitioning my code would create some incomprehensible code was false! Incomprehensibility does not seem to come with partitioning but with large chunks of code!</i></div>
<div style="text-align: justify;">
<br />
Psychologists have discovered that the <i><b>human mind's working memory amounts to about seven items!</b></i> So we have a buffer of seven items! The magic number 7!<br />
<b>Subsequently, the best tip you will probably ever get at programming is "keep your functions at about 7 LoC". </b><br />
<br />
Reading the book, you will discover that there are 10 simple guidelines that will increase your code's legibility in most situations. The first 4 guidelines are generic and they can be applied on any programming language or framework :</div>
<div style="text-align: justify;">
<br />
<i>- Limit the length of functions to 15 LoC<br />- Limit "if" statements per function to no more than 4<br />- Do not copy code. Write reusable functions</i></div>
<div style="text-align: justify;">
<i>- Keep each function's arguments to no more than 4</i><br />
<br />
Putting these guidelines to the test is the only way to find out if your code's legibility will increase or not. Try them out and drop a comment with the results!<br />
<br />
<b>Further information:</b><br />
1. You can find the <b>book </b><a href="https://www.sig.eu/en/building-maintainable-software" target="_blank">here</a>.<br />
<br />
2. You can find a <b>review of the book</b> <a href="http://bobbelderbos.com/2016/03/building-maintainable-software/" target="_blank">here</a>.</div>
<div style="text-align: justify;">
<br />
3. For those of you interested in my hobby game project, it is a simple android puzzle game called <b>"Puzzle Cats"</b> which you can download from <a href="https://play.google.com/store/apps/details?id=marso.games.PuzzleCats" target="_blank">here</a>. I am preparing a new version written entirely in highly maintainable code! And I am also adding PvP functionality! The new version will be released in the following months!</div>
<div style="text-align: justify;">
<br /></div>
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com1tag:blogger.com,1999:blog-3921399134165074878.post-57487176905173099452016-03-08T10:31:00.003+02:002016-03-08T10:32:54.148+02:00Installing screenshare on red5 server<div dir="ltr" style="text-align: left;" trbidi="on">
A client of mine asked me to install screenshare on his red5 server and I found very little resources on the subject. After successfully configuring it I decided I will share the solution so that those that come after, will spend less time that I did!!!<br />
So to the task :<br />
I will suppose that you already have a working red5 server. My deployment was on red5-server-1.0.6-RELEASE-server.<br />
Now download screenshare:<br />
Go to https://github.com/deleolajide/red5-screenshare and press "Download Zip".<br />
Inside the zip you will find a directory webapps/screenshare. Extract this screenshare directory to your red5 server's webapps folder.<br />
Inside the screenshare you need to edit two files. <br />
Edit the <b>screenshare.jnlp</b> as follows<br />
<br />
<?xml version='1.0' encoding='utf-8'?><br /><jnlp spec='1.0+' codebase='<b>http://localhost:5080/screenshare</b>'><br /> <information><br /> <title>Red5 ScreenShare</title><br /> <vendor>Dele Olajide</vendor><br /> <homepage>http://code.google.com/p/red5screnshare/</homepage><br /> <description>Red5 ScreenShare</description><br /> <description kind='short'>An Open Source Screen Share Java application for Adobe Flash using Red5</description><br /> <offline-allowed/><br /> </information><br /> <security><br /> <all-permissions/><br /> </security> <br /> <resources><br /> <j2se version='1.6+'/><br /> <jar href='screenshare.jar'/><br /> </resources><br /> <application-desc main-class='org.redfire.screen.ScreenShare'><br /><b> <argument>localhost</argument><br /> <argument>screenshare</argument></b><br /> <argument>1935</argument><br /> <argument>screen_share</argument> <br /> <argument>flashsv2</argument> <br /> <argument>10</argument> <br /> <argument>1024</argument> <br /> <argument>768</argument> <br /> </application-desc><br /></jnlp><br />
<br />
If you run a public server, replace localhost with your public IP.<br />
Then edit <b>screenviewer.html</b> as follows (some lines are not shown since they do not contain configuration):<br />
<br />
...<br /> var stream = getPageParameter('stream', 'screen_share');<br /><b> var url = getPageParameter('url', 'rtmp://localhost:1935/screenshare');</b><br /> var control = getPageParameter('control', 'true');<br />...<br />
<br />
If you run a public server, replace localhost with your public IP.<br />
And that is all.<br />
Do not forget to add your site on java security tab or the java client will be blocked:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghITLVZOhGJSxhnscLy2qwBG1zN9tKhdmZjKrfhfnKok-esbeR9uQtU5kzxJOyi4H0zT2Rd3l2_kHmmr_MHxsJ3dMIbFihvpPv389JQcHlraIKRKP_3JzAUn1nV3ikI43apOHe7b8MN0Ni/s1600/java.security.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghITLVZOhGJSxhnscLy2qwBG1zN9tKhdmZjKrfhfnKok-esbeR9uQtU5kzxJOyi4H0zT2Rd3l2_kHmmr_MHxsJ3dMIbFihvpPv389JQcHlraIKRKP_3JzAUn1nV3ikI43apOHe7b8MN0Ni/s320/java.security.png" width="320" /></a></div>
Then run on one PC (to share):<br />
http://YOUR_PUBLIC_IP:5080/screenshare/screenshare.jnlp<br />
And on the other PC (to view):<br />
http://YOUR_PUBLIC_IP:5080/screenshare/screenviewer.html<br />
Replace YOUR_PUBLIC_IP with localhost to test on your pc!<br />
<br />
P.S.<br />
If you run a server on a public IP, do not forget to open port 1935 on your server's firewall! </div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-36454154508611544212014-08-17T13:43:00.001+03:002014-08-17T13:44:18.755+03:00Perfofming SEO friendly site redirection on a java app server to another domain<div dir="ltr" style="text-align: left;" trbidi="on">
Hello everybody,<br />
<br />
Today I will analyze a very simple and successful way to redirect you old domain hosted in a java app server (Tomcat for our example) to your new domain so that search engines understand that the old domain does not exist anymore and has moved to a new location (SEO friendly : Search Engine Optimizations friendly). All you need to do is set up your old domain to respond with an http status code 301 that means "Moved Permanently" for any request.<br />
<br />
First, in the root directory of your old domain create a jsp with the name redirect.jsp containing the following code :<br />
<br />
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><br />
<%<br />
response.setStatus(301);<br />
response.setHeader( "Location", "http://www.NEW-DOMAIN.com");<br />
response.setHeader( "Connection", "close" );<br />
%><br />
<br />
Replace "http://www.NEW-DOMAIN.com" with the url of your new domain.<br />
<br />
Next add the following lines inside the root directory's web.xml (for Tomcat installations inside webapps/ROOT/WEB-INF/web.xml):<br />
<br />
<br />
<servlet> <br />
<servlet-name>redirectorrr</servlet-name><br />
<jsp-file>/redirect.jsp</jsp-file><br />
</servlet><br />
<servlet-mapping><br />
<servlet-name>redirectorrr</servlet-name><br />
<url-pattern>/*</url-pattern><br />
</servlet-mapping>
<br />
<br />
And we're done. You may notice that the servlet name is totally irrelevant, so you can change it to anything you like (change it in both lines to a new servlet name).<br />
<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-89814404694822585332011-04-23T13:03:00.000+03:002014-08-17T10:55:17.456+03:00Glassfish 2.1.1 on Linux: Performance Tuning Essentials<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
Glassfish may be the best J2EE Application Server out there. It is stable, it is fully j2ee 1.5 compatible, it runs all technologies and it is open source! I love this application server.<br />
Here are some tips that will make it respond faster and increase its capacity in requests per second.<br />
<br />
<b>1. Disable application auto-deployment and </b><b>dynamic class reloading</b> :<br />
Stand-Alone Instances > server (Admin Server) > Advanced tab<br />
-> Auto Deploy --> uncheck<br />
-> Reload --> uncheck<br />
<br />
<b>2 Disable dynamic JSP reloading :</b><br />
Edit "default-web.xml" inside the config directory of each instance and change the init-param <b>development </b>to <b>false </b>for the <b>org.apache.jasper.servlet.JspServlet</b> (instance restart is required):<br />
<br />
<b>3. Minimize logging.</b><br />
Logger writes to disk and that is very expensive. So you can rearrange logging levels to "SEVERE" for all the loggers (since this setting is dynamic and you can change it to diagnose without restarts, Cool!). <br />
Admin Console > Logger Settings page > Log Levels tab<br />
<br />
<b>Further log minimizing:</b><br />
Tail your server.log at peak hours and watch carefully at the messages. Catch the loggers that print unnecessary messages and either speak to the programmer to minimize the messages of their applications or you can <u>immediately</u> adjust the logging level for that logger subsystem!<br />
Add a new property with the logger name and set the level to SEVERE or even OFF!!! <br />
<br />
<b>4. Tuning HTTP File Caching in memory</b> for faster response to static resources:<br />
Configurations > <b>config-name</b> > HTTP Service (HTTP File Cache)<br />
<b>Globbally : </b>true <br />
<b>Max Files Count</b> : 128 - 512 (is a good start for small applications but it really depends on the applications static resources)<br />
<b>Max Age</b> : 86400 (1 day) - 604800 (7 days) is a good start for non dynamic reloading applications (see tip No 3)<br />
<br />
<b>5. JVM Parameters:</b><br />
Configurations > config-name > JVM Settings (JVM Options). <br />
<br />
-server [maximum program execution speed by advanced optimized compilation]</div>
<div>
</div>
<div>
-XX:+UseConcMarkSweepGC [using the Concurrent Mark Sweep garbage collector can cause a drop in throughput for heavily utilized systems, because it is running more or less constantly, but it prevents long pauses, so it is best for real time applications]</div>
<div>
-XX:+DisableExplicitGC [Disable explicit full gc collections (System.gc() calls) since it would only interfere with the garbage collection algorithms and create big pause times]</div>
<div>
-Xms=-Xmx [having the same starting and maximum heap memory will avoid spending time on any kind of unnecessary resizing of the heap memory]</div>
<div>
-Xmn [Set at most half of the heap memory, since the garbage collection here should faster, more often and contains short lived objects. A good start is 1/5 of the heap size.]</div>
<div>
-Xss128k [128k Stack Size is a very good start. If you get Stack Overflow error increase it by 128k at a time until you reach a point where you no longer get the error. You might even lower it to 64k (or lower) if your application is really lightweight, and then you will be able to serve more concurrent clients ]</div>
<div>
-XX:SurvivorRatio=8 [survivor space and eden ratio will be 1:8. If survivor spaces are too small, copying collection overflows directly into the old generation. If survivor spaces are too large, they will be empty.]</div>
<div>
-XX:MaxPermSize=-XX:PermSize [If you get an "java.lang.OutOfMemoryError: PermGen space", you need to increase this value, since the default is 64MB. If you set the initial size and maximum size to equal values you may be able to avoid some full garbage collections that may occur if/when the permanent generation needs to be resized.]<br />
<br />
-XX:+CMSClassUnloadingEnabled [Enables the CMS Garbage collector (if you use it) to cleanup the PermGen space too. ]</div>
<div>
-XX:+UseParNewGC [this parallel young generation collector can be used with the concurrent low pause collector that collects the tenured generation.]</div>
<div>
-XX:ParallelGCThreads [If number of cpus is less than 8 then put the number of cpus else add (3 + (5/8) * (number of cpus)) ] </div>
<div>
-XX:TargetSurvivorRatio=90 [Allows 90% of the survivor spaces to be occupied instead of the default 50%, allowing better utilization of the survivor space memory. ]<br />
<br />
-XX:MaxTenuringThreshold=30 <br />
<br />
-Djava.awt.headless=true<br />
-Dcom.sun.enterprise.server.ss.ASQuickStartup=false<br />
<br />
JVM Parameters example:</div>
<div>
<b><span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">-server -Xmx2g -Xms2g -Xmn800m -Xss128k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=30 </span><span style="font-family: "Courier New",Courier,monospace;">-Djava.awt.headless=true -Dcom.sun.enterprise.server.ss.ASQuickStartup=false</span></span></b><br />
<br />
<tt></tt><br />
<br />
<b>6. Tuning Linux :</b><br />
Start by checking system limits for file descriptors with this command:<br />
<pre style="font-family: "Courier New",Courier,monospace;">$ cat /proc/sys/fs/file-max
8192</pre>
The current limit shown is 8192. To increase it to 65535, use the following command (as root):<br />
<pre style="font-family: "Courier New",Courier,monospace;">$ echo "65535" > /proc/sys/fs/file-max</pre>
To make this value to survive a system reboot, add it to <tt>/etc/sysctl.conf</tt> and specify the maximum number of open files permitted:<br />
<pre style="font-family: "Courier New",Courier,monospace;">fs.file-max = 65535</pre>
Note: The parameter is not <tt>proc.sys.fs.file-max</tt>, as one might expect.<br />
To list the available parameters that can be modified using <tt>sysctl</tt>:<br />
<pre style="font-family: "Courier New",Courier,monospace;">$ sysctl -a</pre>
To load new values from the <tt>sysctl.conf</tt> file:<br />
<pre style="font-family: "Courier New",Courier,monospace;">$ sysctl -p /etc/sysctl.conf</pre>
To check and modify limits per shell, use the following command:<br />
<pre style="font-family: "Courier New",Courier,monospace;">$ limit</pre>
The output will look something like this:<br />
<pre style="font-family: "Courier New",Courier,monospace;">cputime unlimited
filesize unlimited
datasize unlimited
stacksize 8192 kbytes
coredumpsize 0 kbytes
memoryuse unlimited
descriptors 1024
memorylocked unlimited
maxproc 8146
openfiles 1024</pre>
The <a href="http://www.blogger.com/post-create.g?blogID=3921399134165074878" name="indexterm-277"></a><tt>openfiles</tt> and <tt>descriptors</tt> show a limit of 1024. To increase the limit to 65535 for all users, edit <tt>/etc/security/limits.conf</tt> as root, and modify or add the <tt>nofile</tt> setting (number of file) entries:<br />
<pre style="font-family: "Courier New",Courier,monospace;">* soft nofile 65535
* hard nofile 65535</pre>
The character “<tt>*</tt>” is a wildcard that identifies all users. You could also specify a user ID instead.<br />
Then edit <tt>/etc/pam.d/login</tt> and add the line:<br />
<pre style="font-family: "Courier New",Courier,monospace;">session required /lib/security/pam_limits.so</pre>
On Red Hat, you also need to edit <tt>/etc/pam.d/sshd</tt> and add the following line:<br />
<pre style="font-family: "Courier New",Courier,monospace;">session required /lib/security/pam_limits.so</pre>
On many systems, this procedure will be sufficient. Log in as a regular user and try it before doing the remaining steps. The remaining steps might not be required, depending on how pluggable authentication modules (PAM) and secure shell (SSH) are configured.<br />
<br />
<b>Tune the TCP/IP settings </b>:<br />
<br />
Add the following entry to /etc/rc.local<br />
<pre style="font-family: "Courier New",Courier,monospace;">echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
echo 60000 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 15000 > /proc/sys/net/ipv4/tcp_keepalive_intvl
echo 0 > /proc/sys/net/ipv4/tcp_window_scaling</pre>
<br />
Add the following to /etc/sysctl.conf<br />
<br />
<pre style="font-family: "Courier New",Courier,monospace;"># Disables packet forwarding
net.ipv4.ip_forward = 0
# Enables source route verification
net.ipv4.conf.default.rp_filter = 1
# Disables the magic-sysrq key
kernel.sysrq = 0
net.ipv4.ip_local_port_range = 1204 65000
net.core.rmem_max = 262140
net.core.rmem_default = 262140
net.ipv4.tcp_rmem = 4096 131072 262140
net.ipv4.tcp_wmem = 4096 131072 262140</pre>
<pre style="font-family: "Courier New",Courier,monospace;">net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_window_scaling = 0
net.ipv4.tcp_keepalive_time = 60000
net.ipv4.tcp_keepalive_intvl = 15000
net.ipv4.tcp_fin_timeout = 30</pre>
<pre></pre>
<pre>Add the following as the last entry in <tt>/etc/rc.local</tt></pre>
<pre style="font-family: "Courier New",Courier,monospace;">sysctl -p /etc/sysctl.conf</pre>
Reboot the system.<br />
<br />
Use this command to increase the size of the transmit buffer:<br />
<br />
<pre style="font-family: "Courier New",Courier,monospace;">tcp_recv_hiwat ndd /dev/tcp 8129 32768</pre>
<br />
Make the OS to use swap file only on emergencies:<br />
<div style="font-family: "Courier New",Courier,monospace;">
swappiness=0</div>
<div style="font-family: "Courier New",Courier,monospace;">
swap off; swap on</div>
<br />
<b>7. Disable the Security Manager</b> only if your application server is inside an intranet or inside a very well protected environment (If you are sure that no malicious code will be run on the server and you do not use authentication within your application, then you can disable the security manager). It is generally not recommended but it could provide a significant performance boost (since the security manager has expensive calls).<br />
Configurations > <b>config-name</b> > JVM Settings (JVM Options)<br />
delete the option that contains the following text: <br />
<b><span style="font-family: "Courier New",Courier,monospace;">-Djava.security.manager</span></b><br />
<br />
<b> </b><br />
<b>8. Performance monitoring tools:</b><br />
<b>jconsole :</b> jmx instance monitoring<br />
<b>jvisualvm :</b> will give you a clear view of the cpu utilization, the garbage collections, perm gen size and jvm options. It can also profile and create thread dumps.<br />
<b>Applications Manager :</b> is a nice commercial monitoring tool. Has good support for GlassFish (There is a Free Licence for up to 5 Glassfish instances through jmx).<br />
<b>nmon :</b> nice open source linux monitoring command line gui.<br />
<br />
<b>9. Disable monitoring</b> if you have no problems to detect and resolve.<br />
Configurations > <b>config-name</b> > Monitoring<br />
Change all levels to Low if you still need a little monitoring, or Off if your applications are running smoothly. <br />
<br />
<div style="text-align: left;">
<b>10. Update</b> your software as often as your infrastructure availability/downtime permits. Update your jdk, since bug fixes and optimizations may increase the performance of your application server and make some weird errors go away! The same goes for the operating system, as well as the jdbc drivers or any other libraries your applications use.</div>
<div style="text-align: left;">
<b><br />
</b></div>
<div style="text-align: left;">
<b>11. Patch Glassfish 2.1.x with the latest Grizzly 1.0.x releases.</b></div>
<div style="text-align: left;">
The Grizzly thread manager library is the heart of GlassFish. Since oracle is not planning to release another v2 release, this kind of patch is significant and relatively easy. Unless you decide to move on to v3 release!</div>
<br />
First Check the current Grizzly version by setting the JVM property: "<span style="font-size: x-small;"><b style="font-family: "Courier New",Courier,monospace;">-Dcom.sun.enterprise.web.connector.grizzly.displayConfiguration=true</b></span>".<br />
Make sure the web-container log level is INFO. Restart Glassfish instance and check server.log. You should see an output like this :<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"><i><b>Grizzly 1.0.30</b> running on Mac OS X-10.5.8 under JDK version: 1.6.0_15-Apple Inc.<br />
port: 8080<br />
maxThreads: 5<br />
ByteBuffer size: 4096<br />
useDirectByteBuffer: 8192<br />
maxKeepAliveRequests: 250<br />
keepAliveTimeoutInSeconds: 30<br />
Static File Cache enabled: false<br />
Pipeline : com.sun.enterprise.web.portunif.PortUnificationPipeline<br />
Round Robin Selector Algorithm enabled: false<br />
Round Robin Selector pool size: 1<br />
Asynchronous Request Processing enabled: true|#]</i></span></div>
<br />
where Grizzly version is 1.0.30. Please note, that if you'll see a similar output, but without Grizzly version in it, it means that your version is older than 1.0.30, so a Grizzly upgrade is recommended. Download latest Grizzly 1.0.x binary file from:<br />
<span style="font-size: x-small;"><b style="font-family: "Courier New",Courier,monospace;">http://download.java.net/maven/2/com/sun/grizzly/grizzly-framework-http/</b></span><br />
and save it to a directory, for example :<br />
<b style="font-family: "Courier New",Courier,monospace;">/home/gfuser/grizzly/grizzly-framework-http-1.0.30.jar</b><br />
<br />
Then set Glassfish prefix-classpath to "<span style="font-size: x-small;"><b style="font-family: "Courier New",Courier,monospace;">/home/gfuser/grizzly/grizzly-framework-http-1.0.30.jar</b></span>" to force Glassfish use the latest Grizzly classes instead of the embedded ones. Restart Glassfish and check the server.log again to confirm the success of the patch. Reset the web-container log level to SEVERE.<br />
<br />
<br />
<span style="font-size: large;"><b>Further reading.</b></span> <br />
<br />
<b>Java Tuning White Paper :</b><br />
http://java.sun.com/performance/reference/whitepapers/tuning.html<br />
<br />
<b>Frequently Asked Questions about Garbage Collection :</b><br />
http://www.oracle.com/technetwork/java/faq-140837.html<br />
<br />
<b>Tuning Garbage Collection :</b><br />
http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html<br />
<br />
<b>Java HotSpot VM Options :</b><br />
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html<br />
<br />
<b>Sun Java System Application Server 9.1 Performance Tuning Guide :</b><br />
http://download.oracle.com/docs/cd/E19159-01/819-3681/ <br />
<br />
<br />
Any comments, suggestions, problems or requests will be warmly welcomed.<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied. <br />
<br />
<br />
<br /></div>
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com2tag:blogger.com,1999:blog-3921399134165074878.post-60964618605677261812010-11-24T23:45:00.001+02:002014-08-30T21:36:53.766+03:00Install Apache Geronimo (as service) on Ubuntu Linux<div dir="ltr" style="text-align: left;" trbidi="on">
Apache Geronimo is an Open Source J2EE server. And it can be installed rather easily on Ubuntu Linux (10.04).<br />
<span style="font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;"><span style="font-size: small;"><br /></span></span>
<span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;"><i><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">As a reminder, the following instructions presume that one uses its current ubuntu account. For an enterprise environment it is recommended to create a new user account, for example g_user, that will own all the geronimo files and will start and stop the server (will be referred from now on as GERONIMO_OWNER and ${user})</span></span></i><span style="font-family: "Courier New",Courier,monospace;"><i><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"> and add this user to the sudoers as needed.</span></span></i></span></span></span><br />
<br />
<br />
- First step is to install sun java.<br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">sudo apt-get update</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">sudo apt-get install sun-java6-jdk</span></span><br />
<br />
- Second step is to download and extract (install) Geronimo:<br />
Download from :<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">http://geronimo.apache.org/apache-geronimo-v22-release.html</span></div>
I downloaded the latest stable release with tomcat:<br />
<div style="font-family: "Courier New",Courier,monospace;">
geronimo-tomcat6-javaee5-2.2-bin.tar.gz</div>
<div style="font-family: "Courier New",Courier,monospace;">
<br /></div>
Then md5sum it (to gain problem-solving time):<br />
<div style="font-family: "Courier New",Courier,monospace;">
md5sum geronimo-tomcat6-javaee5-2.2-bin.tar.gz</div>
and crosscheck it with the md5 sum on the site.<br />
<br />
Extract the archive:<br />
<div style="font-family: "Courier New",Courier,monospace;">
tar -xvzf geronimo-tomcat6-javaee5-2.2-bin.tar.gz</div>
<div style="font-family: "Courier New",Courier,monospace;">
<br /></div>
Rename the extracted directory to something smaller:<br />
<div style="font-family: "Courier New",Courier,monospace;">
mv geronimo-tomcat6-javaee5-2.2 geronimo.2.2</div>
<div style="font-family: "Courier New",Courier,monospace;">
From now on when we will refer to the full path of the geronimo.2.2 directory as ${GERONIMO_HOME}.<br />
</div>
Open .bashrc file:<br />
<span style="font-family: "Courier New",Courier,monospace;">gedit /home/${user}/.bashrc</span><br />
<br />
Add JAVA_HOME, JRE_HOME and JAVA_OPTS at the end of .bashrc:<br />
<div style="font-family: "Courier New",Courier,monospace;">
export JAVA_HOME=/usr/lib/jvm/java-6-sun <br />
export JRE_HOME=/usr/lib/jvm/java-6-sun/jre<br />
export JAVA_OPTS="-Xmx256m -XX:MaxPermSize=128m"</div>
<div style="font-family: "Courier New",Courier,monospace;">
</div>
Run .bashrc (just this once):<br />
<div style="font-family: "Courier New",Courier,monospace;">
. .bashrc</div>
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: Arial,Helvetica,sans-serif;">Or close the terminal and open a new one.</span> </span><br />
<br />
- Last step is to start the server:<br />
<div style="font-family: "Courier New",Courier,monospace;">
cd ${GERONIMO_HOME}/bin</div>
<div style="font-family: "Courier New",Courier,monospace;">
./geronimo start</div>
<br />
And the server is up and running!<br />
You can browse the Administration console at<br />
<div style="font-family: "Courier New",Courier,monospace;">
http://localhost:8080/</div>
Click the link "Administration -> console" on the left.<br />
Provide the default credentials :<br />
<span style="font-family: "Courier New",Courier,monospace;">system/manager </span><br />
And geronimo is at your disposal!<br />
<br />
To maximize security, it is time to change the default admin username and password. You need to stop geronimo:<br />
<span style="font-family: "Courier New",Courier,monospace;">cd ${GERONIMO_HOME}/bin</span> <br />
<div style="font-family: "Courier New",Courier,monospace;">
./geronimo.sh stop --user system --password manager</div>
Open user/passwords file<br />
<div style="font-family: "Courier New",Courier,monospace;">
gedit ${GERONIMO_HOME}/var/security/users.properties</div>
and add a new line with the new administrator user and his password like this:<br />
<div style="font-family: "Courier New",Courier,monospace;">
g_admin=g_admin_pass</div>
Next time you start the server the password will be automatically encrypted.<br />
Open permission/groups file:<br />
<div style="font-family: "Courier New",Courier,monospace;">
gedit ${GERONIMO_HOME}/var/security/groups.properties</div>
Assign administration and monitoring privileges only to the new user. Change the two uncommented lines like this:<br />
<span style="font-family: "Courier New",Courier,monospace;">admin=g_admin</span><br />
<span style="font-family: "Courier New",Courier,monospace;">monitor=g_admin</span><br />
Lastly you should change the file permissions on these files:<br />
<span style="font-family: "Courier New",Courier,monospace;">chmod -R 600 ${GERONIMO_HOME}/var/security</span><br />
<br />
To create a service in order to automate startup open/create the following file:<br />
<div style="font-family: "Courier New",Courier,monospace;">
sudo gedit /etc/init.d/geronimo2</div>
Add the following code. You only need to set correctly for your system the variables GERONIMO_HOME, GERONIMO_OW<span style="font-family: "Courier New",Courier,monospace;"></span><span style="font-family: "Courier New",Courier,monospace;"></span>NER, GERONIMO_ADMIN and GERONIMO_PASS inside the script.<br />
<br />
<blockquote>
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;">#!/bin/bash</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"># chkconfig: 234 20 80</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"># description: Geronimo Server start/stop script</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"># processname: geronimo2</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">JAVA_HOME=/usr/lib/jvm/java-6-sun</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">JRE_HOME=/usr/lib/jvm/java-6-sun/jre</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">JAVA_OPTS="-Xmx256m -XX:MaxPermSize=128m"</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">GERONIMO_HOME=/home/gfuser/geronimo.2.2</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">GERONIMO_OWNER=g_user</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">GERONIMO_ADMIN=g_admin</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">GERONIMO_PASS=g_admin_pass</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">export JAVA_HOME JRE_HOME JAVA_OPTS GERONIMO_HOME GERONIMO_OWNER GERONIMO_ADMIN GERONIMO_PASS</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">start() {</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> geronimo_state=`ps -ef | grep "geronimo" | grep "/bin/server.jar" | grep -v grep | wc -l`</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> if [ $geronimo_state -gt 0 ]; then</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "Geronimo is already UP!"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> else </span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo -n "Starting geronimo: "</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> cd $GERONIMO_HOME/bin</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> su $GERONIMO_OWNER -c "$GERONIMO_HOME/bin/geronimo.sh start"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> sleep 20</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "done."</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> fi</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">}</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">stop() {</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> geronimo_state=`ps -ef | grep "geronimo" | grep "/bin/server.jar" | grep -v grep | wc -l`</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> if [ $geronimo_state -gt 0 ]; then</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo -n "Gracefully stoping geronimo: "</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> su $GERONIMO_OWNER -c "$GERONIMO_HOME/bin/geronimo.sh stop --user $GERONIMO_ADMIN --password $GERONIMO_PASS"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> sleep 10</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "done."</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> else</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "Geronimo is already DOWN!"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> fi</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">}</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">force_stop() {</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> geronimo_state=`ps -ef | grep "geronimo" | grep "/bin/server.jar" | grep -v grep | wc -l`</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> if [ $geronimo_state -gt 0 ]; then</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo -n "Forcefully stoping geronimo: "</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> su $GERONIMO_OWNER -c "$GERONIMO_HOME/bin/geronimo.sh stop --force --user $GERONIMO_ADMIN --password $GERONIMO_PASS"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "done."</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> else</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "Geronimo is already DOWN!"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> fi</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">}</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">status() {</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> geronimo_state=`ps -ef | grep "geronimo" | grep "/bin/server.jar" | grep -v grep | wc -l`</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> if [ $geronimo_state -gt 0 ]; then</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "Geronimo is UP!"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> else</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "Geronimo is DOWN!"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> fi</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">}</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">case "$1" in</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> start)</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> start</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">;;</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> stop)</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> stop</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">;;</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> status)</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> status</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">;;</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> force_stop)</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> force_stop</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">;;</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> restart)</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> stop</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> sleep 2</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> start</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">;;</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> *)</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> echo "Usage: $0 {start|stop|force_stop|restart|status}"</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">esac</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">exit 0</span></span></blockquote>
<br />
Now you need to change the file permissions: <br />
<span style="font-family: "Courier New",Courier,monospace;">sudo chmod 755 /etc/init.d/geronimo2 </span><br />
<br />
Next create the upstart conf file:<br />
<div style="font-family: "Courier New",Courier,monospace;">
sudo gedit /etc/init/geronimo2.conf</div>
and add the following code<br />
<br />
<blockquote>
<span style="font-family: "Courier New",Courier,monospace;"># geronimo2</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">start on runlevel [2345]</span><br />
<span style="font-family: "Courier New",Courier,monospace;">stop on runlevel [16]</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">respawn</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">pre-start exec /etc/init.d/geronimo2 start</span><br />
<span style="font-family: "Courier New",Courier,monospace;">post-stop exec /etc/init.d/geronimo2 stop</span></blockquote>
<br />
<br />
Reload upstart configuration:<br />
<span style="font-family: "Courier New",Courier,monospace;">sudo initctl reload-configuration</span><br />
Start geronimo service :<br />
<span style="font-family: "Courier New",Courier,monospace;">sudo initctl start geronimo2</span><br />
<br />
And the geronimo service is securely installed and will be started on every boot.<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied. </div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com4tag:blogger.com,1999:blog-3921399134165074878.post-18370108353318026712010-11-21T19:25:00.015+02:002014-08-17T10:55:31.027+03:00GlassFish 2 Cluster Configuration on the Same Machine<div dir="ltr" style="text-align: left;" trbidi="on">
This tutorial will guide you through a GlassFish 2.1.1 Cluster with two instances on the same machine. We are going to use the CLI interface to make our life simpler.<br />
<i>[Whenever you encounter the \ symbol in one of the commands, it means that the command continues on the following line. So you have to copy both lines (including the \ symbol) at your terminal.]</i><br />
After a successful installation of glassfish with cluster profile (setup-cluster.xml), as explained on the download page:<br />
<br />
<a href="https://glassfish.dev.java.net/downloads/v2.1.1-final.html">https://glassfish.dev.java.net/downloads/v2.1.1-final.html</a><br />
<br />
Go to directory ${GF_HOME}/bin and delete default domain domain1 (or you can just ignore it).<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin delete-domain domain1</span><br />
and create a new domain with adminport 4000, name das :<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin create-domain --adminport 4000 </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse;">--profile cluster </span></span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">das</span><br />
Use the following credentials (or your own, just make sure to make the changes on the password file later on)<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">Admin user : admin</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">Admin pass : admin111</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">Master pass : admin111</span><br />
We are going to use a password file inside ${GF_HOME}/bin in order to make the steps quicker with the following three lines :<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">AS_ADMIN_ADMINPASSWORD=admin111</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">AS_ADMIN_PASSWORD=admin111</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">AS_ADMIN_MASTERPASSWORD=admin111</span><br />
You should better change the file preferences so that no one else can view this file except the GF admin:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">chmod 600 passwords</span><br />
First step is to start the new domain:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin start-domain --user admin --passwordfile passwords das</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Create the first node agent, connecting on DAS at 4000 port,</span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> (and then start it)</span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin create-node-agent --user admin --port 4000 \</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> --passwordfile passwords agent1</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin start-node-agent --user admin --passwordfile passwords agent1</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Create the cluster farm named cl1 (connecting</span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> on DAS at 4000 port</span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">) that will group both of the clustered instances:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin create-cluster --user admin --passwordfile passwords \</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> --port 4000 cl1</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Create the first instance (gf1 on http port 9080) and the second instance (gf2 on http port 9090) that communicate to the domain (DAS on port 4000) through the node agent (agent1) and reference our cluster (cl1):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin create-instance --user admin --passwordfile passwords \</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> --port 4000</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> --nodeagent agent1 --systemproperties \</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> HTTP_LISTENER_PORT=9080</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> --cluster cl1 gf1</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">and</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin create-instance --user admin --passwordfile passwords \</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> --port 4000 </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">--nodeagent agent1 --systemproperties \</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> HTTP_LISTENER_PORT=9090 --cluster cl1 gf2</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Last step is to start the cluster and the instances with the following command:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin start-cluster --user admin --port 4000 \</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"> --passwordfile passwords cl1</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Now when you point your browser to http://localhost:4000/ and login as admin/admin111 you will see on your left the "Clusters" Task, with cl1 child. And cl1 will have two children gf1 and gf2. To deploy an application to the cluster, all you need to do is remove the target "server" and add the target "cl1" (either at deployment or after deployment).</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">You will also see the "Node Agents" Task that has the agent1 node agent.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Here are the startup commands :</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin start-domain --user admin --passwordfile passwords das</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin start-node-agent --user admin --passwordfile passwords agent1</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin start-cluster --port 4000 --passwordfile passwords cl1</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">and the shutdown commands:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin stop-cluster --user admin --passwordfile passwords cl1</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin stop-node-agent agent1 </span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">asadmin stop-domain das</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">p.s.</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: small;">Here are all the commands one after another in order to run them as a script:</span></span><br />
<span class="Apple-style-span" style="font-size: x-small;"></span><br />
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin create-node-agent --user admin --port 4000 --passwordfile passwords agent1</span></span></div>
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin start-node-agent --user admin --passwordfile passwords agent1</span></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin create-cluster --user admin --passwordfile passwords --port 4000 cl1</span></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">asadmin create-instance --user admin --passwordfile passwords --port 4000 \</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"></span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> --nodeagent agent1 --systemproperties HTTP_LISTENER_PORT=9080 --cluster cl1 gf1</span></span></div>
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">asadmin create-instance --user admin --passwordfile passwords --port 4000 \</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"></span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> --nodeagent agent1 --systemproperties HTTP_LISTENER_PORT=9090 --cluster cl1 gf2</span></span></div>
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin start-cluster --user admin --port 4000 --passwordfile passwords cl1</span></span></div>
<div>
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">And the shutdown-delete commands in order to clean up your installation.</span> </span></span><br />
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"></span></span></span><br />
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin stop-cluster --user admin --passwordfile passwords cl1</span></span></span></span></div>
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin stop-node-agent agent1 </span></span></span></span></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin delete-instance --user admin --passwordfile passwords --port 4000 gf1</span></span></span></span><br />
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin delete-instance --user admin --passwordfile passwords --port 4000 gf2</span></span></span></span></div>
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin delete-cluster --port 4000 --user admin --passwordfile passwords cl1</span></span></span></span></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<div style="font-family: 'Times New Roman';">
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin delete-node-agent agent1</span></span></span></span></div>
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 10px; -webkit-border-vertical-spacing: 10px; font-size: xx-small;">asadmin delete-node-agent-config --port 4000 --user admin --passwordfile passwords agent1</span></span></span></span></span><br />
<div style="font-family: 'Times New Roman';">
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin stop-domain das</span></span></span></span></div>
</div>
<div style="font-family: 'Times New Roman'; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-style-span"><span class="Apple-style-span"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">asadmin delete-domain das</span></span></span></span><br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied. <br />
</div>
</div>
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-43618162852609775372010-10-07T22:49:00.001+03:002014-08-17T10:55:40.868+03:00Compile apache 2 with mod_deflate on Linux<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: inherit; font-size: small;"></span><br />
<div style="font-family: inherit;">
<span style="font-size: small;">I have always had trouble finding a simple "How to" to compile apache with exactly what I needed, meaning the common modules plus the mod_deflate. It turns out it is very simple. And that is probably why no one has bothered putting down the steps.</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;"><br />
</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;">This installation will install apache 2.0.63 and zlib 1.2.5, on an ubuntu 10.04 machine. But I can rather safely presume, that the following steps will be the same for any *nix that has already installed the c compiler.</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;"><br />
</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;">First of all, I downloaded the latest apache source package from httpd.apache.org [ http-2.0.63.tar.gz ].</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;"><br />
</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;">Next , I downloaded the latest zlib source package from zlib.net [ zlib-1.2.5.tar.gz ].</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;"><br />
</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;">I copied both packages inside /opt/packages and run the following commnads from a terminal:</span></div>
<div style="font-family: inherit;">
<span style="font-size: small;"><br />
</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: small;">cd /opt/packages</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<style type="text/css">
p { margin-bottom: 0.08in; }
</style> </div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">tar -xvf httpd-2.0.63.tar.gz</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">tar -xvf zlib-1.2.5.tar.gz</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;"><br />
</span> </div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">cd zlib-1.2.5</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">./configure –prefix=/usr/local/zlib</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">make</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">sudo make install</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;"><br />
</span> </div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">cd ../httpd-2.0.63</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<br /></div>
<div style="font-family: Arial,Helvetica,sans-serif; margin-bottom: 0in;">
(The following three lines is one command. Just copy it with the slashes and it will run correctly. Slash tells the terminal that the command will continue in the next line!)</div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">./configure --prefix=/usr/local/apache2 \</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">--enable-mods-shared="all" --enable-deflate \</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;"> –with-z="/usr/local/zlib"</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<br /></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">make </span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;">sudo make install</span></div>
<div style="font-family: inherit; margin-bottom: 0in;">
<br /></div>
<div style="font-family: inherit; margin-bottom: 0in;">
<span style="font-size: small;">So zlib is now installed in /usr/local/zlib and apache inside /usr/local/apache2 which are the default install locations.</span></div>
<div style="font-family: inherit; margin-bottom: 0in;">
<span style="font-size: small;"><br />
</span></div>
<div style="font-family: inherit; margin-bottom: 0in;">
<span style="font-size: small;">And now to enable mod_deflate for most common files by editing httpd.conf:</span></div>
<div style="font-family: "Courier New",Courier,monospace; margin-bottom: 0in;">
<span style="font-size: small;"><br />
</span></div>
<pre style="font-family: "Courier New",Courier,monospace;"><span style="font-size: small;">LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so</span></pre>
<pre style="font-family: inherit;"><span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/javascript application/x-javascript</span></span></pre>
<pre style="font-family: inherit;"><span style="font-size: small;"></span></pre>
<pre style="font-family: inherit;"><span style="font-size: small;">
</span></pre>
<pre style="font-family: inherit;"><span style="font-size: small;"><span style="font-family: inherit;">I hope this little "how to" will save you a lot of time and trouble.</span></span></pre>
<pre style="font-family: inherit;"><span style="font-size: small;">Especially for all of you making your first steps with apache.</span></pre>
<pre style="font-family: inherit;"><span style="font-size: small;"> </span></pre>
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied. <br />
<pre style="font-family: inherit;"><span style="font-size: small;"> </span></pre>
<div style="font-family: inherit;">
</div>
<div style="font-family: inherit; margin-bottom: 0in;">
</div>
<div style="font-family: inherit;">
</div>
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com1tag:blogger.com,1999:blog-3921399134165074878.post-28130708613397403582010-07-17T09:59:00.001+03:002014-08-17T10:55:55.778+03:00Configure MySQL Connection Pool in Glassfish V3<div dir="ltr" style="text-align: left;" trbidi="on">
The MySQL connection pool in GlassFish V3, is actually as easy as it was in V2!<br />
<br />
First of all, we need to download from www.mysql.com the latest jdbc driver:<br />
<br />
http://dev.mysql.com/downloads/connector/j/5.1.html<br />
<br />
Extract the downloaded archive and take the mysql-connector-java-x.x.x-bin.jar from the compressed archive and put it in {glassfish_installation}/glassfish/lib directory and restart glassfish (from {glassfish_installation}/glassfish/bin directory):<br />
<br />
asadmin stop-domain domain1 <br />
asadmin start-domain domain1<br />
<br />
Now we need to navigate to the administrator application:<br />
http://localhost:4848/<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New'.<br />
Fill in the Connection Pool 'Name' with a suitable name like MySQLPool.<br />
Select 'Resource Type' : 'javax.sql.DataSource'.<br />
Select 'Database Vendor' : 'MySQL'.<br />
Select 'Next'.<br />
<br />
At the next page go down at the additional Properties.<br />
Find and edit the following properties :<br />
Fill in property 'User' with the 'Value' : {db_user}<br />
Fill in property 'Password' with the 'Value' : {db_user_pass}<br />
Fill in property 'URL' with the 'Value' :<br />
jdbc:mysql://[host]:[port]/[database name]<br />
Select 'Finish'.<br />
<br />
Navigate to Connection Pools and select the pool you just created.<br />
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.<br />
Fill the JNDI Name like 'jdbc/myconnnection'.<br />
Select from 'Pool Name' combo box the pool we just created.<br />
And select 'OK'.<br />
<br />
The Connection Pool is ready!<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com7tag:blogger.com,1999:blog-3921399134165074878.post-66191303400093429362010-05-18T21:33:00.006+03:002011-04-06T20:07:38.880+03:00Cuda 3.0 installation on Ubuntu Linux 10.04<div dir="ltr" style="text-align: left;" trbidi="on">I need to point out, that it is somewhat appalling the need to write a new tutorial for every time either a linux version or a product (pick your favourite) version is released. That said, I am off to provide the tutorial. <br />
<br />
I had to read many tutorials and walkthroughs, as well as forum threads to succeed in the installation. So some parts might look very familiar!<br />
<br />
First of all we will need to install the cuda graphics driver. Afterwards the cuda toolkit, followed by the cuda sdk. Finally we 'll install gcc 4.3 beacuse Cuda cannot cooperate with gcc 4.4 with which Ubuntu 10.04 ships. The linux version I am using is i386. I presume the instructions will work as well with x86_64 kernel.<br />
<br />
Go to the official nvidia-CUDA download page:<br />
http://developer.nvidia.com/object/cuda_3_0_downloads.html#Linux<br />
<br />
Download the CUDA Toolkit and the CUDA SDK:<br />
<br />
CUDA Toolkit for Ubuntu Linux 9.04 (32-bit)<br />
GPU Computing SDK code samples and more<br />
<br />
-----------------------------<br />
Installing the NVIDIA driver:<br />
-----------------------------<br />
We'll need the latest cuda development driver available (195.xx), but first we'll uninstall the existing drivers.<br />
<br />
1. Uninstall existing NVIDIA drivers and nvidia-glx.<br />
<br />
(if you have enabled nvidia in system->administration->hardware drivers, then disable them first and possibly reboot)<br />
<br />
sudo apt-get purge nvidia-* <br />
<br />
2. Stop gdm service by running<br />
<br />
sudo service gdm stop<br />
<br />
3. Install drivers from nvidia repository<br />
<br />
sudo add-apt-repository ppa:nvidia-vdpau/ppa<br />
sudo apt-get update<br />
sudo apt-get install nvidia-185-modaliases nvidia-glx-185 nvidia-settings<br />
sudo nvidia-xconfig<br />
<br />
4. Reboot and log back in.<br />
<br />
5. Run<br />
<br />
nvidia-settings<br />
<br />
to verify that your driver version is at least 195. Look for the driver version in the window:<br />
The 195.xx NVIDIA Driver for use with CUDA.<br />
<br />
----------------------------<br />
Installing the CUDA Toolkit:<br />
----------------------------<br />
<br />
After having installed the driver we now need to install the CUDA toolkit itself.<br />
<br />
1. Run:<br />
<br />
sudo sh cudatoolkit_3.0_linux_32_ubuntu9.04.run<br />
<br />
2. Press enter to install at the default location.<br />
<br />
/usr/local/cuda<br />
<br />
3. Register the new library files:<br />
<br />
sudo gedit /etc/ld.so.conf.d/cuda.conf &<br />
<br />
and add the following to the empty file<br />
<br />
/usr/local/cuda/lib<br />
<br />
Save the file and close gedit.<br />
Then run:<br />
<br />
sudo ldconfig<br />
<br />
Create a link to the libcuda.so library:<br />
<br />
cd /usr/lib<br />
sudo ln -s nvidia-current/libcuda.so libcuda.so<br />
<br />
Also add to the end of your ~/.bashrc file.<br />
<br />
export PATH=/usr/local/cuda/bin:$PATH<br />
export LD_LIBRARY_PATH=/usr/local/cuda/lib<br />
<br />
restart bash<br />
<br />
----------------------------------------------------------<br />
Installing the CUDA SDK and Compiling the Example Programs<br />
----------------------------------------------------------<br />
<br />
We will now install the CUDA SDK to our own home directory (we can experiment with the supplied demos):<br />
<br />
1. Install SDK to the default location<br />
<br />
sh gpucomputingsdk_3.0_linux.run<br />
<br />
2. As CUDA does not yet work with GCC 4.4 we will have to install gcc-4.3:<br />
<br />
sudo apt-get install gcc-4.3 g++-4.3 g++-4.4<br />
sudo update-alternatives --remove-all gcc<br />
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 43 --slave /usr/bin/g++ g++ /usr/bin/g++-4.3 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.3<br />
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 44 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.4<br />
sudo update-alternatives --config gcc ### choose gcc 4.3<br />
<br />
3. Install CUDA SDK requirements<br />
<br />
sudo apt-get install libglut3-dev libxi-dev libxmu-dev<br />
<br />
4. Go to SDK source dir:<br />
<br />
cd ~/NVIDIA_GPU_Computing_SDK/C$<br />
<br />
5. You should now be able to compile everything by running<br />
<br />
make<br />
<br />
This should now compile all the examples in the SDK without errors.<br />
<br />
---------------------------------------------<br />
Verify Installation<br />
---------------------------------------------<br />
<br />
We can now verify that everything is working:<br />
<br />
1. Run (from ~/NVIDIA_GPU_Computing_SDK/C):<br />
<br />
bin/linux/release/deviceQuery<br />
<br />
On my machine I get the following output (depending on your harware, you output may be different. mine is a GeForce 8500 GT):<br />
<br />
------------------------------------------------<br />
bin/linux/release/deviceQuery Starting...<br />
<br />
CUDA Device Query (Runtime API) version (CUDART static linking)<br />
<br />
There is 1 device supporting CUDA<br />
<br />
Device 0: "GeForce 8500 GT"<br />
CUDA Driver Version: 3.0<br />
CUDA Runtime Version: 3.0<br />
CUDA Capability Major revision number: 1<br />
CUDA Capability Minor revision number: 1<br />
Total amount of global memory: 536150016 bytes<br />
Number of multiprocessors: 2<br />
Number of cores: 16<br />
Total amount of constant memory: 65536 bytes<br />
Total amount of shared memory per block: 16384 bytes<br />
Total number of registers available per block: 8192<br />
Warp size: 32<br />
Maximum number of threads per block: 512<br />
Maximum sizes of each dimension of a block: 512 x 512 x 64<br />
Maximum sizes of each dimension of a grid: 65535 x 65535 x 1<br />
Maximum memory pitch: 2147483647 bytes<br />
Texture alignment: 256 bytes<br />
Clock rate: 1.57 GHz<br />
Concurrent copy and execution: Yes<br />
Run time limit on kernels: Yes<br />
Integrated: No<br />
Support host page-locked memory mapping: No<br />
Compute mode: Default (multiple host threads can use this device simultaneously)<br />
<br />
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 134566327, CUDA Runtime Version = 3.0, NumDevs = 1, Device = GeForce 8500 GT<br />
<br />
<br />
PASSED<br />
<br />
Press <enter> to Quit...<br />
-----------------------------------------------------------<br />
-----------------------------------------------------------<br />
<br />
That was it. It was a little hard, but it is worth the effort.<br />
<br />
Let us only hope that we will not be obligated to write a new one for every release!!!</enter></div>komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com13tag:blogger.com,1999:blog-3921399134165074878.post-7371162600666785772010-05-17T11:38:00.001+03:002014-08-17T10:56:17.196+03:00Load Oracle OCI driver on GlassFish (linux)<div dir="ltr" style="text-align: left;" trbidi="on">
I had a really hard time finding the way to load the Oracle native libraries (Oracle runtime 10gR2 installation) on GlassFish (2.1.1) in linux (CentOS 5.4). Apparently GlassFish ignores the famous LD_LIBRARY_PATH variable for unknown reasons. I even tried setting it at the system wide profile. Nothing worked. <br />
<br />
The java error was :<br />
java.lang.UnsatisfiedLinkError: no ocijdbc10 in java.library.path<br />
<br />
I wrote a small java class that loaded the oci driver successfully. I was sure the parameters were correct. GlassFish still ignored them. I realised that GlassFish was the problem. I tried setting -Djava.library.path. It still didn't work.<br />
<br />
To make a long story short the answer is to set it at the GlassFish Admin GUI :<br />
Configuration --><br />
server-config --><br />
JVM-settings --><br />
Tab: Path Settings --><br />
Native Library Path Prefix : /path/to/oracle/client/installation/lib<br />
<br />
I hope this will save you the time I spent searching fruitlessly the internet.<br />
Cheers<br />
<br />
p.s.Do not forget to give the Oracle native libraries the rx permissions to the FlassFish Admin user!<br />
<br />
p.s.2<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied. <br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com2tag:blogger.com,1999:blog-3921399134165074878.post-62698230056943637722010-03-16T23:32:00.003+02:002014-08-17T10:56:30.157+03:00Run php pages on tomcat!<div dir="ltr" style="text-align: left;" trbidi="on">
Today I feel the urge to congratulate some of our colleagues that strive to bring helpful extensions to our favourite open source software. The subject at hand is Tomcat and it's capability to run php!<br />
<br />
As a java based server, tomcat serves jsp and java servlets. It has also embedded libraries for cgi should anyone would like to use it. But now an open source project called php-java-bridge brings php web projects to Tomcat. The installation is rather simple for a single php application, while making tomcat run php by default is hardly difficult!<br />
<br />
I am not going to write any kind of tutorial this time, because the original tutorial that I have found <a href="http://php-java-bridge.sourceforge.net/pjb/tomcat6.php">here</a> is complete.<br />
<br />
Good job boys. <br />
Keep Tomcat the best application server!<br />
<br />
P.S. <br />
I only need to add one thing missing from the tutorial mentioned. In my ubuntu box I needed first to install php5 and php-cgi (along with all its dependencies!) with:<br />
sudo apt-get install php5 php-cgi<br />
<br />
<br />
p.s.2<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied. <br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-67116848834296581132010-03-07T21:25:00.002+02:002010-03-08T21:28:28.718+02:00Nmon on ubuntu 9.10My favourite operating system is linux. At home I use ubuntu 9.10. A colleague of mine introduced me to a monitoring tool that can monitor almost anything! It is called nmon and it is provided by ibm as open source for linux. The latest binaries are for ubuntu 8.10 which do not work, so I had to compile from the source. I run onto a couple of problems and since I could not find anywhere a complete walkthrough for installing nmon in ubuntu, I decided to write one!<br />
<br />
What we are going to need is g++, ncurses and nmon. What we are going to do is install g++, download ncurses, compile them and install them, and lastly we are going to compile nmon.<br />
<br />
1) Open a terminal and run :<br />
sudo apt-get install g++<br />
2) download latest ncurses release (the moment this was written the ncurses-5.7.tar.gz was the latest) from ftp://ftp.gnu.org/gnu/ncurses/ and save it in a directory. For this example it will be inside /downloads<br />
3) open a terminal and cd to the directory :<br />
cd /downloads<br />
4) Unzip and then untar the ncurses<br />
gunzip ncurses-5.7.tar.gz<br />
tar -xvf ncurses-5.7.tar<br />
5) cd to the ncurses directory<br />
cd ncurses-5.7<br />
6) run configure and make<br />
./configure<br />
make<br />
7) install as root<br />
sudo make install<br />
8) browse for nmon source code at http://nmon.sourceforge.net/pmwiki.php?n=Site.CompilingNmon<br />
and<br />
9) save lmon13d.c (or the latest source code) and makefile in /downloads<br />
10) rename lmon13d.c to lmon.c<br />
mv lmon13d.c lmon.c<br />
11) make<br />
make nmon_x86_ubuntu810<br />
12) rename nmon_x86_ubuntu810<br />
mv nmon_x86_ubuntu810 nmon<br />
13) copy nmon to /usr/bin in order to be available in the path (or any other directory in the $PATH variable).<br />
<br />
That is all. nmon is a rather complete tool for monitoring a linux system.<br />
I hope you like it.komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com2tag:blogger.com,1999:blog-3921399134165074878.post-37858137552738540742010-01-27T12:36:00.000+02:002010-01-27T12:36:24.543+02:00Comparing GlassFish and OAS costsI made a comparison in one of my previous posts that needs some corrections. So I'll just start the comparison from the beginning to avoid any confusion.<br />
<br />
The purpose of this post is to compare, from an application server administrator's perpspective, GlassFish and OAS. Say we have 55.000 Euros to spend for a linux application server, hardware and software. <br />
<br />
In case we buy oas enterprise edition 10g, its price goes to about 25.000 Euros per core (More like per two cores according to Oracle). So with 50.000 Euros we get a dual core (4 cores) license and with the remaining 5.000 we can get a machine with the best quad core in the market, and 8GB of memory. Let's assume that the rest of the hardware will be the same. <br />
<br />
In case we choose glassfish, the oracle ADF Framework licensing amounts to 4000 Euros per core (per two cores). So, with 40.000 Eurow we get a 10 core (20 cores) licensing and with the remaining 15.000 Euros we get a machine (from dell's site) with 20 cores (2x6cores + 2X4cores) and 40GB memory.<br />
<br />
With both servers we get clustering and support. And I need to add that glassfish community support is as good as oracle's.<br />
<br />
It doesn't matter how fast OAS is compared to GlassFish. It may even be twice as fast (which isn't true). With those money and GlassFish one can buy 5 times more cpu power and memory.<br />
<br />
And as a last stroke, I need to add the yearly support fee to Oracle. Instead of paying support and licensing fees, which amount to about 20% the initial cost per year. If we save this money, we can invest them in a new system every four or five years. (And the rest of the money can go to seminars!)<br />
<br />
A clear win for open source and glassfish against oracle application server!komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-10735488523847378702010-01-10T10:39:00.000+02:002014-08-17T10:57:05.946+03:00GlassFish and Toplink ( ..continued )<div dir="ltr" style="text-align: left;" trbidi="on">
My experience with GlassFish has increased since my last post. <br />
<br />
There is already an ADF Faces - JPA eclipselink application that runs smoothly now for a few weeks on GlassFish. The only problem that came up after the successful code tests, was the Connection Pool leakage. There are some differences between the OAS and the <a href="http://mariosgaee.blogspot.com/2009/12/oracle-connection-pool-in-glassfish.html">GlassFish Connection Pooling</a>. As a result, I had to tweak the preferences a little. In the 'General' tab I disabled the 'Connection Validation Required' checkbox to save time on connection gets. Also, at the 'Advanced' tab I set the 'Leak Reclaim' to true and the 'Leak Timeout' to 120 secs. The leak timeout may vary depending on the application. These two tweaks have stabilized the application.<br />
<br />
The other important thing that I need to mention, is the difficulty that I found in installing two different versions of toplink. So the workaround is to install a new GlassFish installation for every toplink version (because the toplink libraries are installed in the installations's lib directory). I am lucky to have only two toplink versions (10.1.3.5 and 10.1.3.3) to handle!<br />
<br />
But it is a serious thing to be considered in the following GlassFish versions: The library loader per version and the grouping of libraries. It is the one thing that I miss OAS for!<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
<br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-70115740252518644722009-12-15T00:33:00.002+02:002014-08-17T10:56:52.424+03:00Firebird Connection Pool in Glassfish 2.x.x<div dir="ltr" style="text-align: left;" trbidi="on">
We will create in a few easy steps a Firebird Connection Pool on GlassFish 2.1.1.<br />
<br />
First of all, we need to download the latest jdbc driver from:<br />
<br />
http://www.firebirdsql.org/index.php?op=files&id=jaybird<br />
<br />
Extract the downloaded archive and take the jaybird-full-x.x.x.jar from the compressed archive and put in {glassfish}/lib directory and restart glassfish:<br />
<br />
asadmin stop-domain domain1 <br />
asadmin start-domain domain1<br />
<br />
Now we need to navigate to the administrator application:<br />
http://localhost:4848/<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.<br />
Fill in the Connection Pool 'Name'.<br />
Select 'Resource Type' : 'javax.sql.ConnectionPoolDataSource'.<br />
Select 'Next'.<br />
<br />
At the next page complete the 'Datasource Classname' with :<br />
<br />
org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource<br />
<br />
Then go down at the additional Properties.<br />
Find and edit the following properties :<br />
Select 'Name' : 'userName' and 'Value' : {db_user}<br />
Select 'Name' : 'password' and 'Value' : {db_user_pass}<br />
Select 'Name' : 'databaseName' and 'Value' : {host_name}:{db_path} <br />
for example:<br />
localhost:/my_data_files/mydb.fdb<br />
Select 'Finish'.<br />
<br />
Navigate to Connection Pools and select the pool you just created.<br />
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.<br />
Fill the JNDI Name like 'jdbc/myconnnection'.<br />
Select from 'Pool Name' combo box the pool we just created.<br />
And select 'OK'.<br />
<br />
The Connection Pool is ready!<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
<br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com15tag:blogger.com,1999:blog-3921399134165074878.post-23576945449832745782009-12-14T22:55:00.004+02:002014-08-17T10:57:23.467+03:00Create Postgresql Connection Pool in Glassfish 2.x.x<div dir="ltr" style="text-align: left;" trbidi="on">
We will create a PostgreSQL (8.4) Connection Pool on a GlassFish 2.1.1 [and GlassFish v3].<br />
<br />
First of all, we need to download the latest jdbc driver:<br />
<br />
http://jdbc.postgresql.org/download.html<br />
<br />
Copy the downloaded archive postgresql-x.x.-xxx.jdbc4.jar in {glassfish}/lib directory and restart glassfish:<br />
<br />
asadmin stop-domain domain1 <br />
asadmin start-domain domain1<br />
<br />
Now we need to navigate to the administrator application:<br />
http://localhost:4848/<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.<br />
Fill in the Connection Pool 'Name'.<br />
Select 'Resource Type' : 'javax.sql.DataSource'.<br />
Select 'Database Vendor' : 'PostgreSQL'.<br />
Select 'Next'.<br />
<br />
At the next page go down at the additional Properties.<br />
Find and edit the following properties :<br />
Select 'Name' : 'User' and 'Value' : {db_user}<br />
Select 'Name' : 'Password' and 'Value' : {db_user_pass}<br />
Select 'Name' : 'DatabaseName' and 'Value' : {db_name}<br />
Select 'Name' : 'ServerName' and 'Value' : {server_hostname}<br />
If your dqatabase is not in the default port (5432) you might also need to edit the following attribute :<br />
Select 'Name' : 'PortNumber' and 'Value' : {port_number}<br />
Select 'Finish'.<br />
<br />
Navigate to Connection Pools and select the pool you just created.<br />
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.<br />
Fill the JNDI Name like 'jdbc/myconnnection'.<br />
Select from 'Pool Name' combo box the pool we just created.<br />
And select 'OK'.<br />
<br />
The Connection Pool is ready!<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com11tag:blogger.com,1999:blog-3921399134165074878.post-57641935549214372762009-12-14T21:31:00.002+02:002014-08-17T10:57:34.067+03:00Mysql Connection Pool in GlassFish 2.x.x<div dir="ltr" style="text-align: left;" trbidi="on">
As a followup to a previous post, regarding the creation of an oracle connection pool in GlassFish 2.1.1, we will create a MySQL connection pool.<br />
<br />
First of all, we need to download from www.mysql.com the latest jdbc driver:<br />
<br />
http://dev.mysql.com/downloads/connector/j/5.1.html<br />
<br />
Extract the downloaded archive and take the mysql-connector-java-x.x.x-bin.jar from the compressed archive and put in {glassfish}/lib directory and restart glassfish:<br />
<br />
asadmin stop-domain domain1 <br />
asadmin start-domain domain1<br />
<br />
Now we need to navigate to the administrator application:<br />
http://localhost:4848/<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.<br />
Fill in the Connection Pool 'Name'.<br />
Select 'Resource Type' : 'javax.sql.DataSource'.<br />
Select 'Database Vendor' : 'MySQL'.<br />
Select 'Next'.<br />
<br />
At the next page go down at the additional Properties.<br />
Find and edit the following properties :<br />
Select 'Name' : 'User' and 'Value' : {db_user}<br />
Select 'Name' : 'Password' and 'Value' : {db_user_pass}<br />
Select 'Name' : 'URL' and 'Value' :<br />
jdbc:mysql://[host]:[port]/[database name]<br />
Select 'Finish'.<br />
<br />
Navigate to Connection Pools and select the pool you just created.<br />
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.<br />
Fill the JNDI Name like 'jdbc/myconnnection'.<br />
Select from 'Pool Name' combo box the pool we just created.<br />
And select 'OK'.<br />
<br />
The Connection Pool is ready!<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com32tag:blogger.com,1999:blog-3921399134165074878.post-46773741287155813552009-12-14T21:03:00.001+02:002014-08-17T10:57:47.777+03:00Install eclipselink in Glassfish 2.x.x<div dir="ltr" style="text-align: left;" trbidi="on">
Installing eclipselink in glassfish is a piece of cake.<br />
<br />
First step is to download the eclipselink.jar from :<br />
<br />
http://www.eclipse.org/eclipselink/downloads/<br />
<br />
Second step is to put ecllipselink.jar (some might also need the persistence.jar) in {glassfish_home}/lib so that the library is available to all domains.<br />
<br />
Third step is to create a connection pool. Use the following tutorial for an oracle pool:<br />
<br />
http://mariosgaee.blogspot.com/2009/12/oracle-connection-pool-in-glassfish.html<br />
<br />
And last, deploy your eclipselink application.<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-40089885038674960362009-12-07T15:08:00.006+02:002014-08-17T10:57:59.359+03:00Oracle Connection Pool in GlassFish 2.x.x<div dir="ltr" style="text-align: left;" trbidi="on">
Glassfish does not ship with oracle jdbc drivers. The oracle driver needs to be added manually. The driver can be found either in a JDeveloper or oracle client or database installation in {install_path}/jdbc/lib, or from oracle's site:<br />
<br />
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html<br />
<br />
Glassfish needs at least ojdbc14.jar to work properly. Older drivers do not work. Put the ojdbc14.jar in {glassfish}/lib directory and restart glassfish:<br />
<br />
asadmin stop-domain domain1 <br />
asadmin start-domain domain1<br />
<br />
Now you need to navigate to the administrator application:<br />
http://localhost:4848/<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.<br />
Fill in the Connection Pool 'Name'.<br />
Select 'Resource Type' : 'javax.sql.ConnectionPoolDataSource'.<br />
Select 'Database Vendor' : 'Oracle'.<br />
Select 'Next'.<br />
<br />
At the next page go down at the additional Properties.<br />
Select all the properties and select 'Delete Properties'.<br />
Select 'Add Property', fill 'Name' : 'user' and 'Value' : {db_user}<br />
Select 'Add Property', fill 'Name' : 'password' and 'Value' : {db_user_pass}<br />
Select 'Add Property', fill 'Name' : 'url' and 'Value' :<br />
jdbc:oracle:thin:@[host][:port]:SID<br />
or <br />
jdbc:oracle:thin:@//[host][:port]/SID<br />
Select 'Finish'.<br />
<br />
Navigate to Connection Pools and select the pool you just created.<br />
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.<br />
<br />
Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.<br />
Fill the JNDI Name like 'jdbc/myconnnection'.<br />
Select from 'Pool Name' combo box the pool we already created.<br />
And select 'OK'.<br />
<br />
The Connection Pool is ready!<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
<br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com13tag:blogger.com,1999:blog-3921399134165074878.post-74717741925028983052009-12-07T05:25:00.005+02:002014-08-17T10:58:20.422+03:00GlassFish and Adf Toplink 10g (2)<div dir="ltr" style="text-align: left;" trbidi="on">
As a followup to the previous post I feel the obligation to add my testing experience of a small but full featured <b>ADF Faces and ADF Toplink</b> application in <b>glassfish</b>.<br />
<br />
<div style="text-align: justify;">
The basic problem I stumbled upon was the External Transaction Controller. Toplink.jar does not provide a TransactionController for GlassFish, although there is one for <b>Oc4j, JBoss, WebSphere and Weblogic</b>. As a result, we have to create one on our own.</div>
<br />
The way to call the Transaction Manager in Glassfish is:<br />
<b>java:appserver/TransactionManager</b><br />
<br />
We need to create a new class named <b>GFTransactionController</b>:<br />
===============================================v<br />
<b>package oracle.toplink.transaction.gf;<br />
<br />
import javax.transaction.TransactionManager;<br />
import oracle.toplink.transaction.JTATransactionController;<br />
<br />
public class GFTransactionController extends JTATransactionController {<br />
<br />
public GFTransactionController() { }<br />
<br />
protected TransactionManager acquireTransactionManager() throws Exception {<br />
return (TransactionManager)jndiLookup("java:appserver/TransactionManager");<br />
}<br />
<br />
public static final String JNDI_TRANSACTION_MANAGER_NAME = "java:appserver/TransactionManager";<br />
}</b><br />
===============================================<br />
<div style="text-align: justify;">
In order to compile this class one needs <b>toplink.jar</b> ({jdev_install}/toplink/jlib) and <b>j2ee.jar</b> ({glassfish_install}/lib) in the classpath. </div>
<div style="text-align: justify;">
Then we open toplink.jar (the one inside glassfish) with winrar. We navigate to folder oracle/toplink/transaction. Right click --> Create new folder --> gf. Navigate to gf and drag and drop the GFTransactionController.class file inside. Our new toplink.jar is ready. We copy the new toplink.jar in {glassfish_install}/lib.</div>
<br />
We also need to change the Transaction Controller in our project.<br />
Open your adf model project in Jdeveloper and follow these instructions:<br />
===============================================<br />
<b>1. In the Applications Navigator, select DataModel --> Application Sources --> TopLink.<br />
2. Select sessions.xml. In the Structure pane, double-click 'default' (or whatever you have named it).<br />
3. On the General page, select the External Transaction Controller check box in Options.<br />
4. Enter the following transaction class:<br />
oracle.toplink.transaction.gf.GFTransactionController</b><br />
===============================================<br />
<br />
<div style="text-align: justify;">
The other problem that I found was at web.xml. JDeveloper creates by default a new web project with a 2.4 xsd for <b>web.xml</b>. We need to change that to a 2.5 xsd. So we open our web.xml and replace our</div>
===============================================<br />
<b>< web-app 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" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" ></b><br />
===============================================<br />
with<br />
===============================================<br />
<b>< web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5" ></b><br />
===============================================<br />
<br />
Now redeploy your project and all ejb junctionality is working correctly.<br />
<br />
<div style="text-align: justify;">
Another minor change is the result of this command: <b>getServletConfig().getServletContext().getRealPath("/test/");</b></div>
<div style="text-align: justify;">
Oc4j returns a slash at the end, while Glassfish does not. A simple solution is to add the last slash after the command:</div>
<b>getServletConfig().getServletContext().getRealPath("/test")+"/";</b><br />
<br />
As I have already mentioned in a previous post, 90% of the problems is a path translation error, because the two servers handle paths a little differently.<br />
<br />
<div style="text-align: justify;">
As a conlcusion, I need to note that GlassFish can <b>successfully</b> run an ADF Faces with ADF Toplink (EJB 3) Application with only a few configuration changes and some slight code modifications! Apart from TransactionController, all the others pass in OC4J too. So, there is no need to start using glassfish as a testing server if you are already using JDeveloper!<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
<br />
</div>
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-25390732093918930912009-12-06T18:05:00.012+02:002010-01-27T12:37:23.258+02:00GlassFish and Adf Toplink 10gAfter my success in deploying an ADF Faces web application in <span style="font-weight: bold;">Glassfish (2.1.1)</span>, I got a crazy idea. Why not try deploying an ADF Faces with <span style="font-weight: bold;">ADF Toplink (EJB 3.0 SessionBean with Pojos) </span>enterprise application in GlassFish? Oracle has deploying instructions for JBoss and WebLogic. What these application Servers have more than GlassFish? Exactly. Nothing!<br />
<br />
So I put my thoughts into work. The first success came when I put toplink.jar in ${glassfish}/lib, restarted the server and the model was successfully deployed with no errors! Then I started adding one by one all the runtime libraries that where reported missing by glassfish deployer. Finally I reached a point where deployment was successful, but there were still runtime errors. I continued adding more libraries, one by one. But when I added xmlparserv2.jar library I returned to square one. The deployment was once again unsuccessful. I googled the error: <br />
<br />
<span style="font-weight: bold;">------------------------------------------------<br />
java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"<br />
at javax.xml.parsers.DocumentBuilderFactory.setSchema(DocumentBuilderFactory.java:561)<br />
...<br />
-----------------------------------------------</span><br />
<br />
All hits I got for this error was about using an older xml parser. But I could not figure out why. I searched inside the xmlparserv2.jar and found some javax.* classes apart from oracle.* classes. So I deleted all javax.* classes from inside the jar in order not to override the default classes, and I created a new xmlparserv2.jar (I also removed from xmlparserv2.jar the directory META-INF/services). I renamed it to oxmlparserv2.jar and added it to project libraries.<br />
<br />
The application was deployed once again. I was really happy. But my troubles weren't over yet. Not even a simple query would run without giving the error:<br />
<br />
<span style="font-weight: bold;">----------------------------------------------<br />
javax.servlet.ServletException: javax.el.MethodNotFoundException: Method not found: findItemByName.execute(javax.faces.event.ActionEvent)<br />
root cause<br />
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: Method not found: findItemByName.execute(javax.faces.event.ActionEvent)<br />
root cause<br />
javax.el.MethodNotFoundException: Method not found: findItemByName.execute(javax.faces.event.ActionEvent)<br />
----------------------------------------------</span><br />
<br />
This was an even more obscure error. I presumed it would still have to do with some missing library. All I needed was to find which library. But there was no error 'noClassDefFoundError' to help me this time! Then I remembered that JDeveloper supports installing all of its runtime libraries to various applications servers, why not glassfish too? Since there is no glassfish installation process in JDeveloper, I improvised. I downloaded a <span style="font-weight: bold;">JBoss v4</span> and installed it. I opened <span style="font-weight: bold;">JDeveloper 10.1.3.5</span> and then I followed the menu:<br />
<span style="font-weight: bold;"> Tools --> ADF Runtime Installer --> JBoss.</span><br />
I completed the installation throught the wizard. Jdev then displayed a summary of the installed libraries. Based on this list I figured out that I only needed to use those libraries that were installed in {server}/default/lib directory of JBoss. The others did not seem very important. Here is a list of those that worked form me:<br />
<br />
<span style="font-weight: bold;">----------------------------------------------------<br />
adf-connections.jar<br />
adfbinding.jar<br />
adfcm.jar<br />
adfm.jar<br />
adfmtl.jar<br />
adfmweb.jar<br />
adfshare.jar<br />
adfui.jar<br />
antlr.jar<br />
bc4jct.jar<br />
bc4jctejb.jar<br />
bc4jdomgnrc.jar<br />
bc4jdomorcl.jar<br />
bc4jimdomains.jar<br />
bc4jmt.jar<br />
bc4jmtejb.jar<br />
cache.jar<br />
collections.jar<br />
commons-cli-1.0.jar<br />
commons-el.jar<br />
concurrent.jar<br />
dc-adapters.jar<br />
dms.jar<br />
http_client.jar<br />
jazncore.jar<br />
jdev-cm.jar<br />
jsp-el-api.jar<br />
libs.txt<br />
mdsrt.jar<br />
ojdbc14.jar<br />
ojpse.jar<br />
oracle-el.jar<br />
oraclepki.jar<br />
ordhttp.jar<br />
ordim.jar<br />
osdt_cert.jar<br />
osdt_core.jar<br />
osdt_saml.jar<br />
osdt_wss.jar<br />
osdt_xmlsec.jar<br />
oxml.jar<br />
oxmlparserv2.jar<br />
runtime12.jar<br />
share.jar<br />
toplink-agent.jar<br />
toplink.jar<br />
translator.jar<br />
xmlef.jar<br />
xsqlserializers.jar<br />
xsu12.jar<br />
----------------------------------------------------</span><br />
<br />
So I copied them to my {glassfish}/lib dir. Except for<span style="font-weight: bold;"> xml.jar and xmlparserv2.jar</span>. For those two I deleted all javax.* classes from the jar and then I copied them with new names, as oxmlparserv2.jar and oxml.jar, in order to distinguish them in the future.<br />
<br />
The result was astounding. The application was deployed successfully and run a query! Total Success! <br />
<br />
All that is left to do now, is run thorough tests on every adf-toplink application that needs to be deployed in glassfish, so as to find any minor inconsistencies. <span style="font-weight: bold;">As a hint, I have found that the path is handled differently between the two servers. This thought will solve almost 90% of the rest of the incompatibility problems.</span><br />
<br />
Concluding, I need to say that glassfish server has already surpassed my expectations. It is a free open source application server that can compete evenly with other commercial application servers. And if it can run oracle's applications, then it can run any j2ee application!<br />
<br />
<strike>I want to add as a last thought, as a big organization's application server administrator, a comparison, between glassfish and oas. Say we have 35.000 Euros to spent for a linux application server, hardware and software. <br />
<br />
In case we buy oas enterprise edition, its price goes to about 15.000 Euros a core. So with 35.000 Euros we get a dual core license and that leaves 5.000 to get a machine with the best dual core in the market, and at least 10GB of memory. Let's assume that the rest of the hardware will be the same. <br />
<br />
In case we choose glassfish, all the money goes to hardware. What do we buy with 35.000 Euros? Two machines (as I saw at dell's site) with 24 cores ( 4 x Intel 6cores) and 48GB memory <span style="font-weight: bold;">each</span>. Which sums up to 48 cores running almost at top speed and 96GB of memory. With both servers we get clustering and support. And I need to add that glassfish community support is as good as oracle's.<br />
<br />
What I make of it? I don't care how fast oas is. It may even be twice as fast (or even thrice as fast) as glassfish. Who cares? With those money and glassfish one can buy 24 times more cpus and memory.<br />
<br />
And as a last stroke, I need to add the yearly support fee to oracle. Instead of paying support and licensing fees, which amount in around 20% a year. If we save this money, we can invest them in a new system every four or five years. (And all the rest of the money can go to seminars!)<br />
<br />
A clear win for open source and glassfish against oracle application server!</strike><br />
<br />
P.S. <br />
There is an error in this comparison. While GlassFish is open source and therefore free, the use of ADF framework is not. I have a more accurate comparison <a href="http://mariosgaee.blogspot.com/2010/01/comparing-glassfish-and-oas-costs.html">here</a>.komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com5tag:blogger.com,1999:blog-3921399134165074878.post-55907052133216809762009-12-05T16:24:00.006+02:002014-08-17T10:58:32.670+03:00Glassfish and Adf Faces<div dir="ltr" style="text-align: left;" trbidi="on">
A friend told me that glassfish is the best Application Server for Java based web projects. So I installed GlassFish 2.1.1, in three easy steps, which are well documented in the download site. I wanted to see if adf faces would run at all.<br />
I downloaded the adf faces demo 10.1.3.0.4 from oracle's site. I deployed it and everything run smoothly! well, almost everything! whenever I needed to open a popup window, for example the chooseDate component, the server would reply with the error:<br />
=================<br />
javax.servlet.ServletException: viewId:/__ADFv__ - View /__ADFv__ could not be restored.<br />
root cause<br />
javax.faces.application.ViewExpiredException: viewId:/__ADFv__ - View /__ADFv__ could not be restored.<br />
=================<br />
I searched the internet but found nowhere any references to it. After reading that glassfish project is providing the portability of adf faces to glassfish without modifications, I filed a bug. The reply came only a few hours later. The answer was simple. The problem was already solved but not well documented. All, I had to do was put these two lines in the web.xml file:<br />
=================<br />
< context-param><br />
< param-name>com.sun.faces.enableRestoreView11Compatibility< /param-name><br />
< param-value>true< /param-value><br />
< /context-param><br />
=================<br />
After that the adf faces demo run, literally, without any modifications!<br />
<hr />
As a conclusion, I need to congratulate the GlassFish Project community, for its immediate answer and professionality, something we don't find easily these days. Keep up the good work guys.<br />
<br />
<br />
p.s.<br />
You can find me on <a href="http://www.fiverr.com/marios_debug" target="_blank">fiverr </a>for
more personalized requests on any java app server configuration problem
or java error that you encounter, with deliverance of less than a day
(true!) and money back guarantee if not satisfied.<br />
<br />
</div>
komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-13394899245953249992009-12-04T19:42:00.006+02:002009-12-08T02:00:17.883+02:00Running gwt project errorI thought giving gwt a chance, so I opened a tutorial for gwt and eclipse. Very soon I had the code for a little HelloWorld example ready to run. But when I hit 'run as --> Web Application' there was a sinister error waiting for me!!! <br />
<br />
- libstdc++.so.5: cannot open shared object file: No such file or directory<br />
<br />
So I thought I'll apt-get my way through! But stdlibc++.so.5 is no longer available on ubuntu 9.10! <br />
So I googled the library and I had to install almost manually. Here is the download mirrors list for libstdc++5 library.<br />
<br />
http://packages.ubuntu.com/jaunty/i386/libstdc++5/download.<br />
<br />
After downloading and installing it, gwt worked fine. Though my code was a mess! lol.<br />
And I need to add that linux is a beauty. I did not have to restart eclipse. I just hit 'Run' one more time and it worked!komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0tag:blogger.com,1999:blog-3921399134165074878.post-75078507553202973522009-11-24T16:27:00.005+02:002010-06-14T16:17:26.856+03:00Install Google App Engine Plugin for Eclipse<span style="font-size: 100%;"><span style="font-family: verdana;">First things first. Google is offering a plugin for Eclipse. So I had to download and install eclipse. The thing is I recently switched to ubuntu linux (9.10) and was so fascinated with its easy-to-use interface that I immediately jumped to Applications --> Ubuntu Software Center and installed eclipse. All went fine. Until I started following google's installation instrunctions for the plugin. The setup would never finish, because there were some missing libraries. I started searching the internet for help. I found that ubuntu's release of eclipse is a slightly different one that lacks update support. I tried using the update sites of the mainstream release of eclipse, but that didn't do the trick either.</span><br />
<span style="font-family: verdana;">I was frustrated. I uninstalled the ubuntu release and downloaded the official release. Things went smoothly, because eclipse doesn't need installing! Only extracting! When I arrived at the installation plugin screen I realised that some things were not viewable. That was really weird. Just as if I was looking at a non stable release! As a consequence, I was unable to install the plugin.</span><br />
<span style="font-family: verdana;">I was even more frustrated, but I didn't quit just yet. I starting searching the internet blindly. With no luck. Then I started looking at all the Google App Engine pages just in case. And there I found it. At a google blog there was one easy step to solve all of my problems! So all I had to do was create a new file in the eclipse home directory with the following lines:</span><br />
<span style="font-family: verdana;"><br />
------------</span><br />
<span style="font-family: verdana;">#!/bin/sh </span><br />
<span style="font-family: verdana;">export GDK_NATIVE_WINDOWS=1 </span><br />
<span style="font-family: verdana;">./eclipse </span><br />
<span style="font-family: verdana;">------------<br />
<br />
and run eclipse through it.</span><span style="font-family: verdana;"> All of my troubles were over. All the instructions for the plugin installation were completing successfully! For your reference the google installation instructions are at the following urls:</span><br />
</span><code><span style="font-size: 100%;"><span style="font-family: verdana;"><br />
<a href="http://code.google.com/eclipse/docs/getting_started.html#installing" rel="nofollow" target="_blank"><span id="lw_1259073240_1">http://code.google.com/eclipse/docs/getting_started.html#installing</span></a></span><br />
<span style="font-family: verdana;">[<a href="http://dl.google.com/eclipse/plugin/3.5" rel="nofollow" target="_blank"><span id="lw_1259073240_2">http://dl.google.com/eclipse/plugin/3.5</span></a>]<br />
<br />
</span><span style="font-family: verdana; font-weight: bold;">After a few days I tried repeating the above procedure at a windows xp sp3 machine. I was surprised to find out that the installation process was flawless, without a glitch! This is a clear win for windows! Although eclipse is an open source software, it's installation on an ubuntu machine was far more troublesome that in windows.</span></span> </code>komarioshttp://www.blogger.com/profile/10641918396968542194noreply@blogger.com0