tag:blogger.com,1999:blog-11382082740657677182024-02-07T06:13:27.150-08:00 AWGtek BlogS931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.comBlogger118125tag:blogger.com,1999:blog-1138208274065767718.post-78925049330807734452018-03-20T12:19:00.001-07:002018-03-20T12:50:49.665-07:00Create keypair for Tomcat SSL and import same to Java keystoreCreate the keypair:<br />
<span style="font-family: "courier new" , "courier" , monospace;">keytool -genkeypair -alias tomcat -keyalg RSA -keysize 2048 -keystore tomcat-keystore.jks -validity 730</span><br />
<br />
Export the certificate:<br />
<span style="font-family: Courier New, Courier, monospace;">keytool -export -alias tomcat -file tomcat-keystore.cer -keystore tomcat-keystore.jks</span><br />
<br />
Import to Java keystore:<br />
<span style="font-family: courier new, courier, monospace;">keytool -import -alias tomcat</span><span style="font-family: "courier new", courier, monospace;"> -file tomcat-keystore.cer -keystore C:\jdk1.7.0_51\jre\lib\security\cacerts</span><br />
<br />
Add it to Tomcat's server.xml:<br />
<span style="font-family: "courier new" , "courier" , monospace;"><connector acceptcount="100" clientauth="false" font="" sslenabled="true"></connector></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <Connector SSLEnabled="true" acceptCount="100" clientAuth="false"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">disableUploadTimeout="true" enableLookups="false" maxThreads="25"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> port="8443" keystoreFile="/path/to/<span style="font-family: "Courier New", Courier, monospace;">tomcat-keystore.jks</span>" keystorePass="password"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> secure="true" sslProtocol="TLS" /></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">Now you can avoid errors in java programs like:</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed...</span><br />
<br />
References:<br />
<a href="https://dzone.com/articles/setting-ssl-tomcat-5-minutes">https://dzone.com/articles/setting-ssl-tomcat-5-minutes</a><br />
<a href="https://stackoverflow.com/a/36175384/1714485">https://stackoverflow.com/a/7812567/1714485</a>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-66572746950899040962017-05-31T08:05:00.001-07:002017-05-31T08:50:45.680-07:00Creating a multi-column constraint where one column has nullsTo create a multi-column unique constraint on a table where the new column will have nulls initially<br />
need to ensure that the index associated with the unique constraint is non-unique. This can be done<br />
using 'DEFERRABLE' in the constraint command or by creating a non-unique index first and<br />
referring to it with a USING INDEX __ in the constraint command:<br />
<br />
select name from v$database;<br />
<br />
Alter table MYSCHEMA.MY_TABLE add MY_COLUMN varchar2(250);<br />
<br />
comment on column MY_TABLE.MY_COLUMN is 'a column description';<br />
<br />
ALTER TABLE MYSCHEMA.MY_TABLE ADD CONSTRAINT XYZ1_MY_TABLE UNIQUE (ANOTHER_COLUMN, MY_COLUMN) DEFERRABLE NOVALIDATE;<br />
<br />
commit;<br />
<br />
-- ROLLBACK<br />
(paste the below rollback commands in sql developer worksheet run as script and click commit)<br />
ALTER TABLE MYSCHEMA.MY_TABLE DROP CONSTRAINT XYZ1_MY_TABLE;<br />
<br />
Alter table MYSCHEMA.MY_TABLE drop column MY_COLUMN;<br />
<br />
--verify column, constraint and associated index is deleted:<br />
select index_name,index_type, uniqueness, visibility from dba_indexes where table_name='MY_TABLE' order by index_name;<br />
<br />
select * from dba_constraints where table_name='MY_TABLE';<br />
<div>
<br /></div>
<br />S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-57545372469059273282017-04-23T20:05:00.004-07:002017-04-23T20:07:44.731-07:00Git rebase interactive to move feature to releaseThe scenario was similar to <a href="http://stackoverflow.com/questions/6594881/git-merge-only-the-changes-made-on-the-branch?noredirect=1&lq=1">http://stackoverflow.com/questions/6594881/git-merge-only-the-changes-made-on-the-branch?noredirect=1&lq=1</a><br />
where dev/master was in the middle, getting merged into continuously be various teams and their feature branches. Periodically a release branch is created and devs are stuck with the dilemma of having to merge a feature branch into both dev and release.<br />
<br />
<pre> A release1
/
D---E---F---G development
\
H---I---J feature_for_release1
</pre>
<br />
So, as a proof of concept what I have done is show how feature_for_release1 could be attached onto release1 without including F.<br />
<br />
I first created a staging branch off release1:<br />
<br />
<pre> MINGW64 /c/Work/testing/my_try_git (release1)
$ git checkout -b stage-release1-feature
Switched to a new branch 'stage-release1-feature'
</pre>
<br />
Then merged in feature-for-release1:
<br />
<pre> git merge feature-for-release1
</pre>
<br />
At this point I printed the log and did a rebase interactive:
<br />
<pre> MINGW64 /c/Work/testing/my_try_git (stage-release1-feature)
$ git log --pretty=oneline --graph
* 14b50fed8999aa785e7333a239b532c3f1fe11e0 file added for release1
* b6a8a66b8bd64de49b666d0e627e68de76747ac4 files changed for release1
* e3ee2edbbfbb2ef629170309d5e35cad6181f4d6 Merge pull request #1 from awgtek/feature-for-release2
|\
| * cd091e9f75d8580c34c9a73c0f30aef616816a7f adding changes for release 2
|/
* eb95ed7111130064272be69957644223212d9981 Remove 322
* fde83b085873139a22cef07f069b46e98eeb0fe9 asdflkasjf;dsak
* 7a5797b379afca819f1e5a92bc122e41bbed52ab add all the octa t filesfrom2
* 05d0d336001842e6b4fec2206e6616363b8d9dbe adding redoctober
* 485cdfcd1fdcd5106518a9f19406a1243c91c555 add all the octocat txt files
* 81d5a2cb15e40752c8bf7aba7ffde6728ebfbdb6 add cute octaot story
MINGW64 /c/Work/testing/my_try_git (stage-release1-feature)
$ git rebase -i eb95ed7111130064272be69957644223212d9981
</pre>
In the editor was shown:
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl5kIAQJmRelqC5ob4uOOXiPHGSONAYFNjhSAV7qCIE259J66LMl7QPIY661z5qnNKbDYw4OOP_8DZOKIEFcH_7c8Rc4CSAyTr9OXXi5q5cPTZRZ5WumUnODD_nFbp4_F0m1uy0CLM8f7u/s1600/rebase.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl5kIAQJmRelqC5ob4uOOXiPHGSONAYFNjhSAV7qCIE259J66LMl7QPIY661z5qnNKbDYw4OOP_8DZOKIEFcH_7c8Rc4CSAyTr9OXXi5q5cPTZRZ5WumUnODD_nFbp4_F0m1uy0CLM8f7u/s320/rebase.PNG" width="320" /></a></div>
<br />
As can be seen, I am rebasing to eb95ed which corresponds to point E on the above diagram. I am also dropping cd091e9 from the replaying of this sequence of commits (top to bottom) onto the staging branch which is being rebased to the point just before eb95ed.<br />
<br />
When I saved the file, it got an error:<br />
<br />
<pre>error: could not apply b6a8a66... files changed for release1
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply b6a8a66b8bd64de49b666d0e627e68de76747ac4... files changed for release1
</pre>
<br />
This was because one of the files committed in the dropped commit was also changed in a subsequent kept commit. So I had to edit the offending file remove all the merge conflicts, do a git add, and a git rebase --continue. After which the rebase was completed.<br />
<br />
<pre> MINGW64 /c/Work/testing/my_try_git (stage-release1-feature)
$ git log --pretty=oneline --graph
* 752d1871b4e8632a1daf8fe7579884f08dfa0b17 file added for release1
* faa4e3ba142bc00015bdba7c2988e02319cbfaab files changed for release1
* eb95ed7111130064272be69957644223212d9981 Remove 322
* fde83b085873139a22cef07f069b46e98eeb0fe9 asdflkasjf;dsak
* 7a5797b379afca819f1e5a92bc122e41bbed52ab add all the octa t filesfrom2
* 05d0d336001842e6b4fec2206e6616363b8d9dbe adding redoctober
* 485cdfcd1fdcd5106518a9f19406a1243c91c555 add all the octocat txt files
* 81d5a2cb15e40752c8bf7aba7ffde6728ebfbdb6 add cute octaot story
</pre>
<br />
I could then push stage-release1-feature to github and merge it into release. see <a href="https://github.com/awgtek/my_try_git/commits/release1">here</a>.S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-53074263563236367512016-07-23T07:02:00.002-07:002016-07-23T07:02:46.119-07:00Enabling Debugging in Eclipse for Tomcat InstallationWhen using the option "Use Tomcat installation (takes control of Tomcat installation), to enable debugging from Eclipse, you may need to adjust the VM arguments of the launch configuration as follows:<br />
<br />
Double click the Tomcat server in the Servers tab, then click "Open launch configuration"<br />
In the Arguments tab append the following line to the VM arguments text box:<br />
<span style="font-family: Courier New, Courier, monospace;"> -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</span><br />
<br />
Then restart the server.<br />
<br />
Here is a screenshot:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL9C3Rvl74slMXOEVu33B9SyizU2yNEzFOw9bXEBMwIpjeGzBoz3PjEgtbXPaeEU1_sPYLUt1Q8OV7Jy_kaoBFVLkS7bQpmx5Y7t2CjU0N4tOgOdndmGoD6YtAYKz_a_gw-kc_Cu945iPl/s1600/tomcatdebug.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL9C3Rvl74slMXOEVu33B9SyizU2yNEzFOw9bXEBMwIpjeGzBoz3PjEgtbXPaeEU1_sPYLUt1Q8OV7Jy_kaoBFVLkS7bQpmx5Y7t2CjU0N4tOgOdndmGoD6YtAYKz_a_gw-kc_Cu945iPl/s640/tomcatdebug.PNG" width="563" /></a></div>
<br />S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-44040447058936867982016-03-05T17:26:00.000-08:002016-03-05T17:31:49.143-08:00Two-way authentication with TomcatStart by creating a private key, cert, and keystore using openssl then convert to jks using Java's keytool so it can be used in Tomcat:
<pre>
MyOwnPC+Joe@MyOwnPC ~/temp
$ openssl req -new -x509 -key serverprivatekey.pem -out servercert.pem -days 1095
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:.
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:.
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:myownpc
Email Address []:.
MyOwnPC+Joe@MyOwnPC ~/temp
$ ls
servercert.pem serverprivatekey.pem
MyOwnPC+Joe@MyOwnPC ~/temp
$ openssl pkcs12 -export -out serverkeystore.pkcs12 -in servercert.pem -inkey serverprivatekey.pem -name myownpc -passout pass:changeit
MyOwnPC+Joe@MyOwnPC ~/temp
$ ls
servercert.pem serverkeystore.pkcs12 serverprivatekey.pem
MyOwnPC+Joe@MyOwnPC ~/temp
$ keytool -importkeystore -alias myownpc -srckeystore serverkeystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks -deststoretype JKS
Enter destination keystore password: changeit
Re-enter new password: changeit
Enter source keystore password: changeit
MyOwnPC+Joe@MyOwnPC ~/temp
$ ls
keystore.jks servercert.pem serverkeystore.pkcs12 serverprivatekey.pem
MyOwnPC+Joe@MyOwnPC ~/temp
$ cp keystore.jks ../certs
</pre>
Add (or modify) so that Tomcat's conf/server.xml contains reference to the new keystore:
<pre>
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="C:/cygwin64/home/Joe/certs/keystore.jks" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS" />
</pre>
Restart Tomcat. Then browse to https://myownpc:8443/someapp. Accept the certificate browser warnings and verify that the presented certificate's details contains 'myownpc' as the 'issued for'. Also you can check using the following keytool command to ensure 'myownpc' is an alias for the imported cert: keytool -list -v -keystore keystore.jks
Now create a client certificate and add it to the keystore used by tomcat:
<pre>
MyOwnPC+Joe@MyOwnPC ~/temp
$ openssl genrsa -out clientprivatekey.pem 2048 Generating RSA private key, 2048 bit long modulus
.......................+++
.............+++
e is 65537 (0x10001)
MyOwnPC+Joe@MyOwnPC ~/temp
$ openssl req -new -x509 -key clientprivatekey.pem -out clientcert.pem -days 365
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:.
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:.
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:joe
Email Address []:.
MyOwnPC+Joe@MyOwnPC ~/temp
$ ls
clientcert.pem keystore.jks serverkeystore.pkcs12
clientprivatekey.pem servercert.pem serverprivatekey.pem
MyOwnPC+Joe@MyOwnPC ~/temp
$ openssl pkcs12 -export -out clientkeystore.pkcs12 -in clientcert.pem -inkey clientprivatekey.pem -name joe -passout pass:changeit
MyOwnPC+Joe@MyOwnPC ~/temp
$ keytool -importkeystore -alias joe -srckeystore clientkeystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks -deststoretype JKS
Enter destination keystore password: changeit
Enter source keystore password: changeit
MyOwnPC+Joe@MyOwnPC ~/temp
$ ls
clientcert.pem keystore.jks serverprivatekey.pem
clientkeystore.pkcs12 servercert.pem
clientprivatekey.pem serverkeystore.pkcs12
MyOwnPC+Joe@MyOwnPC ~/temp
$ cp keystore.jks ../certs
</pre>
Now modify the server.xml SSL connector, adding keyAlias, truststoreFile, and truststorePass attributes and set clientAuth to true:
<pre>
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="C:/cygwin64/home/Joe/certs/keystore.jks" keystorePass="changeit"
clientAuth="true" sslProtocol="TLS"
keyAlias="myownpc" truststoreFile="C:/cygwin64/home/Joe/certs/keystore.jks"
truststorePass="changeit"
/>
</pre>
Restart Tomcat. Now loading the https page will give an error like
<pre>
An error occurred during a connection to myownpc:8443. SSL peer cannot verify your certificate. (Error code: ssl_error_bad_cert_alert)
</pre>
So in Firefox, do Options, Advanced, View Certificates, Import and import the file clientkeystore.pkcs12 and enter the password when prompted.
Try loading the page again and Firefox should present you with the option to use the certificate you imported; accept and load the page.
<p>
Refs:
<a href="http://venkateshragi.blogspot.com/2013/04/two-way-ssl-authentication-on-tomcat.html">http://venkateshragi.blogspot.com/2013/04/two-way-ssl-authentication-on-tomcat.html</a> main flow here. Correction, the truststoreFile was actually required for me.<br>
<a href="http://www.cloudera.com/documentation/enterprise/5-3-x/topics/cm_sg_openssl_jks.html">http://www.cloudera.com/documentation/enterprise/5-3-x/topics/cm_sg_openssl_jks.html</a> found correction to above blog, adding -name option to openssl exports.S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-84727449867034356362015-02-21T15:21:00.001-08:002015-02-21T17:28:42.391-08:00Eclipse Classpath Run Configurations being overwrittenEncountered a strange issue with eclipse (both Luna and Mars) on certain run configurations. What happened was when launching I would almost immediately (after some messages from loading classes) get "Error: Could not find or load [name of the class]" or in some other run configuration a java.lang.ClassNotFoundException and then a stack trace.<br />
<br />
This would happen despite cleaning the project, recreating the run configuration, or running eclipse with the -clean option. The project depended on another project to which I traced the unfound class. This told me that it was a classpath issue; however, the project was clearly listed in the Classpath tab of the run configuration. I even tried exporting the project to a jar and adding it to the local client project build path but that didn't work either.<br />
<br />
I then decided to examine the running JVM process. I ran JConsole, attached to the failing process and opened the VM Summary tab. There were a huge number of VM arguments which I scrolled through to get to the Class path entry. The Class path entry had only one entry in it, a single jar file used by the application. There should have been more entries though. I then created a new run configuration using the reverse-engineered items from the output of wmic to get the full command line (see <a href="http://serverfault.com/questions/323795/display-complete-command-line-including-arguments-for-windows-process">http://serverfault.com/questions/323795/display-complete-command-line-including-arguments-for-windows-process</a>). I tried obtaining it from Process Explorer via save but it truncated it because it was very long I guess. The reverse configured run configuration also produced the same errors.<br />
<br />
The I did a search for the single jar file that was assigned to the classpath in the long command line figuring it had to be set there somehow. Sure enough it was being assigned via the -Djava.class.path vm argument. Since the jar was already being loaded via the build path I removed the java.class.path argument -- and that resolved the error. Apparently, adding that argument was causing Eclipse to ignore the Classpath as shown in the Classpath tab of the run configuration. This would only happen though using that particular set of VM arguments. If I only added a few VM arguments in addition to the java.class.path argument Eclipse would run the config and no errors would result. Interestingly JConsole would show only the VM arguments other than java.class.path so apparently Eclipse cleans it up, perhaps recognizing whether the entry is needed or already is reflected in the run configuration classpath (update: <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=126499">this </a>seems to indicate java.class.path is not settable; and I wasn't able to prove otherwise, i.e that it was settable, when using test projects and configurations with classpath tweaking by <a href="http://stackoverflow.com/questions/22198780/how-to-modify-the-eclipse-run-configuration-classpath">removing the default classpath</a> and adding my own under "User entries").<br />
<br />
My guess regarding the error is that the replacing of the run configuration classpath with the value added to java.class.path vm argument is due to either 1) the vm argument list I was using was too long or 2) the vm argument list was corrupted somehow. This cause would be in addition to an existing eclipse state -- most likely the state of the plugins installed. The reason why is that some eclipse installations worked given the same set of vm arguments and all else being equal while other eclipse installations failed. It did so happen that when I uninstalled one custom plugin that did custom run configurations and reinstalled an earlier version of the plugin this solved the issue. However repeating the steps did not solve the issue on other eclipse installations so I could not pinpoint it to the plugin. It therefore must be a combination of plugin installation or absence of and the above faulty set of vm arguments containing the java.class.path entry...<br />
<br />
<br />
refs:<br />
http://www.javahotchocolate.com/tutorials/bad-output-folder.html<br />
<br />S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-46345844483859601042015-02-13T22:18:00.002-08:002015-02-16T01:38:50.319-08:00Creating a sequence diagram from a stack trace<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
Install AmaterasUML:<br />
- download AmaterasUML from <a href="http://amateras.sourceforge.jp/cgi-bin/fswiki_en/wiki.cgi?page=AmaterasUML" style="color: #1155cc;" target="_blank">http://amateras.sourceforge.<wbr></wbr>jp/cgi-bin/fswiki_en/wiki.cgi?<wbr></wbr>page=AmaterasUML</a></div>
<span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">- unzip AmaterasUML_1.3.4.zip</span><br />
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
<div>
- copy the three jars to eclipse plugin folder, e.g. D:\App\eclipse-jee-luna-R-<wbr></wbr>win32-x86_64\eclipse\plugins</div>
<div>
- install Graphical Editing Framework eclipse plugin. It was already installed in mine, maybe through a dependency on BPMN2 Modeler or something else.</div>
<div>
- restart eclipse</div>
<div>
Get the stack trace</div>
<div>
- in Eclipse put a breakpoint in some method you want to analyze via sequence diagram</div>
<div>
- start debug </div>
<div>
- in the debug view right-click the Daemon Thread and click Copy Stack</div>
<div>
- paste into text editor</div>
<div>
Fix up stack trace</div>
<div>
- remove unwanted lines including lines that end with "line: 1" or start with "Daemon Thread" or "owns:" leaving only the lines that start with entities to be added to the sequence diagram</div>
<div>
- save the file e.g. D:\work\AmaterasPrepWork\<wbr></wbr>MyStackTrace.txt</div>
<div>
- create a second text file and paste into it the following awk script:<br />
{<br />
str = $0;\<br />
sub(/^\t/, "", str);\<br />
sub(/\(.*\./,".",str);\<br />
sub(/\$.*\./,".",str);\<br />
match(str, /(.*)\./, arr);\<br />
sub(/^/, "at ", str);\<br />
#print str;\<br />
sub(/\([^\)]*\)/, "(", str);\<br />
sub(/ line: /, arr[1]".java:", str);\<br />
sub(/$/, ")", str);\<br />
sub(/\t\)$/, ")", str);\<br />
print str}</div>
<div>
- save the file as e.g. D:\work\AmaterasPrepWork\<wbr></wbr>AmaterasPrepProg.txt</div>
<div>
- download gawk and run file e.g. gawk-3.1.6-1-setup.exe</div>
<div>
- open a command prompt and cd to e.g. D:\work\AmaterasPrepWork<br />
- execute the following commands:<br />
D:\AmaterasPrepWork>set path=%path%;D:\Program Files (x86)\GnuWin32\bin<br />
D:\AmaterasPrepWork>echo awk -f AmaterasPrepProg.txt MyStackTrace.txt ^> out.txt > run.bat<br />
D:\AmaterasPrepWork>run.bat</div>
<div>
Make sequence diagram in eclipse</div>
<div>
- Do Window, Show View, AmaterasUML, Stack Trace Sample, OK</div>
<div>
- paste the contents of D:\AmaterasPrepWork\out.txt into the window</div>
<div>
- click the 'i' (image of lower case 'i') button in upper right-hand corner of the Stack Trace Sample view</div>
<div>
- select a folder in your project as the destination of new sequence</div>
<div>
- refresh the folder in eclipse</div>
<div>
- open sequence.sqd</div>
<div>
- do finishing touches. It appears e.g. that some entities weren't added and need to be added?? will check on this...</div>
<div>
- save the file as MySequence.sqd or save sequence.sqd and refactor to another name because AmaterasUML uses sequence.sqd as the target file name evidently.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
ref:</div>
<div>
<a href="https://oopsnullpointer.wordpress.com/2010/04/08/creating-uml-sequence-diagrams-from-debug-stack-traces/" style="color: #1155cc;" target="_blank">https://oopsnullpointer.<wbr></wbr>wordpress.com/2010/04/08/<wbr></wbr>creating-uml-sequence-<wbr></wbr>diagrams-from-debug-stack-<wbr></wbr>traces/</a><br />
<a href="http://www.programering.com/a/MjN0kjMwATY.html" style="color: #1155cc;" target="_blank">http://www.programering.com/a/<wbr></wbr>MjN0kjMwATY.html</a></div>
</div>
S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-53178174887568113462014-11-02T11:42:00.002-08:002014-11-02T15:34:06.540-08:00Solving Sruts2 Core Jar File ConflictI was adding a Struts2 application to an embedded Tomcat 6 instance by adding the context and assigning the path to the Struts2 application programmatically. The Struts2 application's WEB-INF/lib was empty similar to what's known as a "skinny war." When attempting to access a jsp page though I would get the error: "/struts-tags" not found.<br />
<br />
This was solved by adding struts2-core-2.3.4.1.jar to the WEB-INF/lib. However then application would not load and I would get:<br />
Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:C:/MyCustomContainer/plugins/struts2-core-2.3.4.1.jar!/struts-default.xml:29:72 - bean - jar:file:/D:/temp/configs/pings/strutssd/WEB-INF/lib/struts2-core-2.3.4.1.jar!/struts-default.xml:29:72<br />
<br />
So I removed struts2-core-2.3.4.1.jar from the plugins dir leaving only the copy in the WEB-INF/lib. This fixed the problem and the Struts2 application finally worked.<br />
<br />
Note this could cause problems if I were to add another Struts2 application to the container although I haven't tried it.<br />
<br />
Related problems with workarounds including removing struts-tags.tld and putting in WEB-INF, or adding Class-Path entries to MANIFEST.MF:<br />
<a href="http://stackoverflow.com/questions/19380836/skinny-war-libraries-in-ear-struts-tags-not-found-error">http://stackoverflow.com/questions/19380836/skinny-war-libraries-in-ear-struts-tags-not-found-error</a><br />
<a href="http://stackoverflow.com/questions/6339323/file-struts-tags-not-found-in-struts-1-3">http://stackoverflow.com/questions/6339323/file-struts-tags-not-found-in-struts-1-3</a><br />
<a href="http://stackoverflow.com/questions/19666413/what-is-the-right-way-to-package-struts2-jar-files">http://stackoverflow.com/questions/19666413/what-is-the-right-way-to-package-struts2-jar-files</a><br />
<a href="http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem">http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem</a>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-64278272377703578042014-03-08T20:19:00.001-08:002014-03-17T09:35:55.593-07:00Deploy Small Java App to OpenShiftThis is the code deploy method. For deploying an existing WAR there are other methods will plenty of how-tos on the web.<br />
<br />
- Create a JBoss Application Server 7 app preferably from the rhc client.<br />
- Create a file TestBean.java under src\main\java\action and paste in the sample TestBean class from this tutorial on JSP actions: http://www.tutorialspoint.com/jsp/jsp_actions.htm<br />
- Create a folder "classes" under src\main\webapp\WEB-INF (although I'm not sure this step is necessary)<br />
- Create a file "main.jsp" under src\main\webapp and paste in the corresponding sample code from the above referenced tutorial<br />
- Git add, commit, and push it up.<br />
- Load it in the browser e.g. http://jbossas-<your namespace>.rhcloud.com/main.jsp<br />
<br />
see also: <a href="http://awgjournal.blogspot.com/2014/03/tomcat-openshift-projects.html">http://awgjournal.blogspot.com/2014/03/tomcat-openshift-projects.html</a>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-49502837402882469812013-11-30T15:14:00.002-08:002013-11-30T15:15:32.226-08:00Create empty file with bcpI wasn't sure if multiple statements (using semicolon as delimiter) could be passed to bcp, so I tried it, specifically prepending a DECLARE statement and it worked, in this case for creating an empty file:
<pre>
DECLARE @FilePath VARCHAR(1000)
DECLARE @FileExists int
DECLARE @nulltable TABLE ( foo integer)
SET @FilePath = 'C:\my\path\somefile.csv'
exec master.dbo.xp_fileexist @FilePath, @FileExists OUTPUT
if not @FileExists = 1
begin
declare @bcpCommand varchar(255), @Result int
set @bcpCommand = 'bcp "DECLARE @nulltable TABLE ( foo integer); Select * from @nulltable" queryout "' + @FilePath + '" -c -t, -T -S '
exec @Result = master..xp_cmdshell @bcpCommand --, no_output
end
</pre>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-17958767577936520472013-08-07T21:34:00.000-07:002013-08-31T21:27:17.547-07:00Get Value of Form ElementI had names to compare only (as they are generated from DB). I needed the value regardless of element type; most would try to detect type then get the value.<br />
<br />
For now I will settle on a one liner expression, and see how it goes in testing:<br />
<br />
<code>
$("input[name='NameOfElement']:checked").val() || document['formName']['NameOfElement'].value || false</code><br />
<br />
This should handle radio buttons and checkboxes first (if checked), then selects and inputs, then false. My use case doesn't require comparing values of textareas or multiselects, so I am not accounting for them for now.
<br />
Note: I found the above to cause "Do you want to continue running scripts on this page?" messages on old clients, namely IE 7 or 8 on single core Windows XP PCs. So I was forced to replace the above jQuery-reliant code with the following more verbose pure JavaScript:<br />
<code>if ( ! ( (document['Form1']['ItemFoo'].length && document['Form1']['ItemFoo'][0].type=="radio" && myGetSelectedRadioValueByName('ItemFoo')=="Yes") || (!document['Form1']['ItemFoo'].disabled && document['Form1']['ItemFoo'].type=="checkbox" && document['Form1']['ItemFoo'].checked==true && document['Form1']['ItemFoo'].value == "Yes") || (!document['Form1']['ItemFoo'].disabled && document['Form1']['ItemFoo'].type!="checkbox" && document['Form1']['ItemFoo'].value == "Yes"))){
var elems = document.getElementsByName('TargetShowHideElement');
for (var i = 0; i < elems.length; i++) {
elems[i].disabled= false;
}
}
</code><br />
<br />
<br />
A side note about the above: It is a work in progress; the language-specific expressions are generated from a DSL (a table of variables and corresponding conditions), in a manner similar to a suggestion by "Doc Brown" at <a href="http://programmers.stackexchange.com/questions/182025/creating-huge-decision-tree">http://programmers.stackexchange.com/questions/182025/creating-huge-decision-tree</a>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-42132173163691377842013-06-21T04:38:00.000-07:002013-06-21T05:07:11.083-07:00Disabling Siblings of Selected Radio ButtonI couldn't find a "contains" selector that applied to html elements, hence the following <strike>hack</strike> less elegent (more verbose than it should be) method that functionally and stylistically disables all <code>li</code> containers that don't contain the radio button that's selected:
<pre>
var enableOnlySelectedListItem = function(parentId, radioItemName) {
$('#' + parentId + ' input:radio[name=' + radioItemName + ']')
.on('click', null,"",function (event) {
$(this).closest('ul')
.find('input[name=' + radioItemName + ']')
.not(this)
.parent()
.find(':input')
.not('input[name=' + radioItemName + ']')
.prop('disabled', true)
.end()
.end()
.addClass('disabledtext');
$(this).closest('li')
.find(':input')
.prop('disabled', false)
.end()
.removeClass('disabledtext');
event.stopPropagation();
});
};
</pre>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-3260800829290180272013-05-19T23:18:00.000-07:002013-05-19T23:18:23.870-07:00Installing Stunnel on CenOS 5Download tar.gz file from <a href="http://www.stunnel.org/downloads.html?extra=/source.html">http://www.stunnel.org/downloads.html?extra=/source.html</a><div>
to ~/temp</div>
<div>
did: </div>
<div>
<span style="font-family: Courier New, Courier, monospace;">gzip -dc stunnel-4.56.tar.gz | tar xvf -</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cd stunnel-4.56</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">./configure</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">make</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">make install</span></div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">vi /usr/local/etc/stunnel/stunnel.conf-sample</span></div>
<div>
add the line</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">fips = no</span></div>
<div>
change cert = line to read</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cert = /usr/local/etc/stunnel/stunnel.pem</span></div>
<div>
adjust service section, e.g. for forwarding smtp securely</div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cp /usr/local/etc/stunnel/stunnel.conf-sample /etc/stunnel/stunnel.conf</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cp /etc/stunnel/stunnel.conf /usr/local/etc/stunnel/stunnel.conf</span></div>
<div>
#this last one to satisfy stunnel from cmd line, the prior for the service</div>
<div>
#perhaps should make them hard linked</div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cp /usr/local/share/doc/stunnel/examples/stunnel.init /etc/init.d/stunnel</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">cd /etc/init.d</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">chmod 755 stunnel</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">vi stunnel</span></div>
<div>
modify top of file to read:</div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#! /bin/sh -e</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"># description: stunnel Start Stop Restart</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"># processname: stunnel</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"># chkconfig: 234 20 80</span></div>
</div>
<div>
<br /></div>
<div>
then in startdeamons() change the install line to read:</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">install -d -o nobody -g nobody /var/run/stunnel</span></div>
<div>
<br /></div>
<div>
save file</div>
<div>
do:</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">echo "ENABLED=1" > /etc/default/stunnel</span></div>
<div>
<br /></div>
<div>
Disable sendmail</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">chkconfig sendmail off; service sendmail stop</span></div>
<div>
<br /></div>
<div>
Enable stunnel</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">chkconfig --add stunnel</span></div>
<div>
In case tests are running:</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">pkill stunnel </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">service stunnel start</span></div>
<div>
<br /></div>
<div>
References:</div>
<div>
<a href="http://www.mrvoip.com.au/blog/secure-zabbix-proxy-communications-stunnel">http://www.mrvoip.com.au/blog/secure-zabbix-proxy-communications-stunnel</a></div>
<div>
<a href="http://blog.tuxforge.com/service-does-not-support-chkconfig/">http://blog.tuxforge.com/service-does-not-support-chkconfig/</a></div>
<div>
<a href="http://pichat-wiki.de/manuals/https_with_stunnel">http://pichat-wiki.de/manuals/https_with_stunnel</a></div>
<div>
<a href="http://nelsoncli.blogspot.com/2012/09/im-setting-up-stunnel-and-will-be.html">http://nelsoncli.blogspot.com/2012/09/im-setting-up-stunnel-and-will-be.html</a></div>
<div>
<br /></div>
<div>
<br /></div>
S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-45743370665009535862013-05-05T13:37:00.000-07:002013-05-05T13:46:48.775-07:00Using vb2jsThis is one of the only tools I've found to automatically convert VBA files to .js files. YMMV.<br />
<br />
- Download via svn. see <a href="https://code.google.com/p/vb2js/source/checkout">https://code.google.com/p/vb2js/source/checkout</a><br />
<br />
- Download Guava (currently guava-14.0.1.jar) - <a href="https://code.google.com/p/guava-libraries/">https://code.google.com/p/guava-libraries/</a>; place downloaded file in 'src' folder of vb2js download<br />
<br />
- Open a text editor and insert this code
<pre>
package com.google.vb2js;
import java.util.*;
import java.io.*;
public class MyVbaJsConverter {
public static void main(String[] args) throws FileNotFoundException, IOException {
if (args.length == 2) {
String entireFileText = new Scanner(new File(args[0]))
.useDelimiter("\\A").next();
FileWriter fstream = new FileWriter(args[1]);
BufferedWriter out = new BufferedWriter(fstream);
out.write(VbaJsConverter.convert(entireFileText));
out.close();
}
}
}
</pre>
- Save the file as "MyVbaJsConverter.java" in the same directory as the unpacked vb2js java files (e.g. in D:\temp\vb2js-read-only\src\com\google\vb2js)
- Create a text file with the following content. Save it as ...\src\testInput.bas
<pre>
Dim MyList As String
Dim MyNum As Integer
</pre>
- Make sure JDK is installed and JDK bin folder is in path environment variable
- Open a command prompt and change to src folder.
- Execute the following commands:
<pre>
d:\temp\vb2js-read-only\src>javac -cp guava-14.0.1.jar com\google\vb2js\*.java
D:\temp\vb2js-read-only\src>java -cp .;guava-14.0.1.jar com.google.vb2js.MyVbaJsConverter testInput.bas testOutput.js
</pre>
- Open testOutput.js and verify that VBA was converted.
<p>
refs:
<a href="http://abhinandanmk.blogspot.com/2012/05/java-how-to-read-complete-text-file.html">http://abhinandanmk.blogspot.com/2012/05/java-how-to-read-complete-text-file.html</a><br>
<a href="http://www.roseindia.net/java/beginners/java-write-to-file.shtml">http://www.roseindia.net/java/beginners/java-write-to-file.shtml</a>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-7820705955364372332013-04-18T12:26:00.002-07:002013-04-18T14:51:02.309-07:00Tomcat Hello World ServletHere's a no-IDE quick-start how-to.
Create the following directories:<br />
<br />
c:\users\John Smith\Documents\scratch\helloTomcat\src<br />
c:\users\John Smith\Documents\scratch\helloTomcat\dist\WEB-INF<br />
<br />
open NotePad++ and create the following two files.<br />
<br />
c:\users\John Smith\Documents\scratch\helloTomcat\dist\WEB-INF\web.xml<br />
<br />
<pre>
<!DOCTYPE web-app PUBLIC
'-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<servlet>
<servlet-name>mihello</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mihello</servlet-name>
<url-pattern>/mihello</url-pattern>
</servlet-mapping>
</web-app>
</pre>
c:\users\John Smith\Documents\scratch\helloTomcat\src\HelloServlet.java<br />
<pre>
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class HelloServlet extends HttpServlet {
public void doGet (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
PrintWriter out = res.getWriter();
out.println("Hello, You!");
out.close();
}
}
</pre>
Open a command prompt
<pre>
C:\Users\John Smith\Documents\scratch\helloTomcat\src>javac -cp "C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar" HelloServlet.java
C:\Users\John Smith\Documents\scratch\helloTomcat\src>mkdir ..\dist\WEB-INF\classes
C:\Users\John Smith\Documents\scratch\helloTomcat\src>copy *.class ..\dist\WEB-INF\classes
C:\Users\John Smith\Documents\scratch\helloTomcat\src>cd ..\dist
C:\Users\John Smith\Documents\scratch\helloTomcat\dist>jar cvf web-arc-test.war
</pre>
Open a command prompt as Administrator
<pre>
C:\Users\John Smith\Documents\scratch\helloTomcat\dist>copy web-arc-test.war "C
:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps"
</pre>
open browser and browse to http://localhost:8085/web-arc-test/mihello
<br/>
Note: change port to whatever tomcat is running on.<br/>
Refs:<br/>
http://keyboardsamurais.de/2004/01/15/tomcat_tutorial_helloworld_for_complete_fools_-_english/<br/>
http://stackoverflow.com/questions/7924687/compiling-a-simple-hello-world-servlet-into-a-war-for-tomcat<br/>
http://www.avajava.com/tutorials/lessons/how-do-i-create-a-war-file-using-the-jar-command.htmlS931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-15941125401192785842013-04-05T12:42:00.000-07:002013-04-05T15:02:46.832-07:00Get Property by an Attribute Property Value using LINQ<pre>
//look up the attribute matching the listid using Reflection and LINQ
Type dtoType = typeof(AppInitParamsDTO);
PropertyInfo pi = dtoType.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(
x => typeof(AppInitParamsSettingsListNameAttribute)
.GetProperty("ListName")
.GetValue(Attribute.GetCustomAttribute(
x, typeof(AppInitParamsSettingsListNameAttribute)), null).ToString()
== listId).First();
</pre>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-1211339304689453002013-03-26T07:57:00.002-07:002013-03-27T05:21:07.064-07:00JSONSelect UsageFor the simple use case of verifying the existence of a "record" in a JavaScript object, you typically need to iterate through all items. There is a one-liner approach though, thankfully.<br />
<br />
Say you want to verify that an ID exists in<br />
<pre>
"Body": {
"GetListCollectionResponse": {
"GetListCollectionResult": {
"Lists": {
"List": [
{
"ID": "{B8B000CC-EB90-4B3D-9A44-79B8A9CFCAAC}",
"RequireCheckout": "False",
"EnableMinorVersion": "False",
...
</pre>
Verify existence with the following function:
<pre>
ListExists = function(listGuid) { //search spsvcListColXmlJson for match
var arr = <span style="background:orange; color:white; ">JSONSelect.match(":has(:root > .ID:val(\""+listGuid+"\"))", </span>
spsvcListColXmlJson.Body.GetListCollectionResponse.GetListCollectionResult.Lists);
var retval = arr.length>0;
return retval;
};
</pre>
Test:
<pre>
test('List Guid found in Lists collection', function() {
ok(ListExists("{B8B000CC-EB90-4B3D-9A44-79B8A9CFCAAC}"),"list should exist");
});
</pre>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-87214213423246642462013-02-28T12:23:00.003-08:002013-02-28T12:54:44.463-08:00DB Access Account error when Adding WFEIf you get this error when attempting to add a WFE to a farm:<br />
<br />
"SharePoint Products and Technologies Configuration Wizard"<br />
"The username entered must be the same as the database access account for the server farm you wish to join. Either choose NT AUTHORITY\NETWORK SERVICE as the username or choose a different database name"<br />
<br />
try <a href="http://technet.microsoft.com/en-us/library/cc288991(v=office.12).aspx">changing the user account</a> used for the Timer service and Central Admin app pool. Supposedly this is the account specified at installation AKA server farm account or AKA Database Access Account (as in the error message).<br />
<br />
Confusing, I know.<br />
<br />
This does the trick:<br />
<br />
<b>stsadm -o updatefarmcredentials -userlogin </b><i><domain username=""></domain></i><b> -password </b><i><newpassword></newpassword></i><br />
<br />
<i>iisreset /noforce</i><br />
<br />
<i> <a href="http://technet.microsoft.com/en-us/library/cc288991(v=office.12).aspx">http://technet.microsoft.com/en-us/library/cc288991(v=office.12).aspx</a></i><br />
<br />
Note: you may also need to enable the SQL Server Browser service on the CA server.<i> </i>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-31975022774305870322013-02-15T07:27:00.002-08:002013-02-15T07:45:47.476-08:00Bind ViewModel Declaratively with Caliburn.Micro in Non-Caliburn.Micro AppI have an existing Silverlight App with Frame based navigation and the app is fairly stable. I wanted to look into logging interception of ViewModels and that is when I started testing Caliburn.Micro (per an answer to my question <a href="http://stackoverflow.com/questions/14845856/interception-of-viewmodels-in-silverlight">here</a>). My aim is to gradually migrate pages over to the Caliburn.Micro framework, but not have CM take over the App at first (i.e. set the RootVisual). The closes discussion on the web I could find regarding this scenario was <a href="http://caliburnmicro.codeplex.com/discussions/260738">http://caliburnmicro.codeplex.com/discussions/260738</a>. To do a proof-of-concept I simply combined the files from the Caliburn.Micro.ViewFirst sample project with a SL Nav template project:<br />
<br />
- Create a new "Silverlight Navigation Application" project<br />
-Add existing files from ViewFirst sample: IShell.cs, MefBootstrapper.cs, and ShellViewModel.cs (change namespaces if desired)<br />
- Add necessary references to MEF and Caliburn.Micro<br />
- In MefBootstrapper, remove the OnStartup override method, since we are not setting the rootvisual, but instead letting the App.xaml do that. Note I thought it was necessary to also override the constructor and set "base(false)" but it seems to work either way, so I left it out.<br />
- Copy the StackPanel element and its content from ShellView.xaml into the ContentStackPanel of About.xaml<br />
- For the declarative binding of VM, also add the following also to About.xaml: cal:Bind.Model="Shell" xmlns:cal="http://www.caliburnproject.org"<br />
- At the top of the App constructor of App.xaml.cs add: new MefBootstrapper();<br />
- Press F5, click "About" and notice that you have a working Caliburn.Micro ViewModel View with Actions all wired up automatically!S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-38206871719800254872013-02-11T08:17:00.000-08:002013-02-11T08:17:02.816-08:00IsolatedStorageException - "Initialization Failed"I got this IsolatedStorageException - message: "Initialization Failed" - when using Enterprise Library. The line giving the error is in StorageAccessor.Silverlight.cs<br />
<code> this.store = IsolatedStorageFile.GetUserStoreForApplication();</code><br />
I've gotten this error before in other circumstances, and usually occur right after I delete the Isolated Storage for a particular URL and reopen the app.<br />
<br />
Tried rebooting, recompiling, reinstalling Silverlight runtime. Finally what worked was deleting this folder: C:\Users\User.Name\AppData\LocalLow\Microsoft\Silverlight<br />
<br />
Apparently there is some corrupted state left over in there. I also noted that around this time I was unable to delete other app stores.S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-59737670184906408012013-01-24T18:58:00.000-08:002013-03-26T08:00:49.535-07:00XML/Javascript Mapping with JsonixI needed a way to edit an XML config pulled from a SharePoint List (via SPServices). So that's when I found Jsonix, which so far in my testing appears to do the job quite well.<br />
<br />
The steps I took were:<br />
- Load the XML in Visual Studio and click XML, Create Schema. This created two .xsd files "MySettings.xsd" and "MySettings1.xsd" (in the same directory) as Visual Studio 2010 split them out by namespace apparently. At any rate, what I had to do was edit the xs:import element in the parent XSD, adding a schemaLocation attribute with the unqualified name of the second .xsd file.<br />
<br />
- Downloaded jsonix-scripts-1.2-all.js and jsonix-full-1.2.jar from http://repo2.maven.org/maven2/org/hisrc/jsonix/ -- note, I tried 1.0 per the how-to on the author's site, but it didn't seem to work for me (got errors which I didn't have the time to troubleshoot); however 1.2 worked like a charm, although the generated objects are rather cryptic.<br />
<br />
- Ran C:\temp\jsonix-samples-po-1.0>java -jar lib/jsonix-full-1.2.jar -d src/main/webapp/js src/main/resources/MySettings.xsd<br />
This generated two folders with a Mappings.js in each folder, corresponding to the two .xsd files. I combined these two .js files into one, putting the code from generated\Mappings.js at the top of the file and the code from settingsuri\Mappings.js (assuming "SettingsURI" is the root xmlns) at the bottom.<br />
<br />
- I then uploaded my sample .xml and the .js files to the SharePoint list and placed the following code in a test .html page.<br />
<br />
<br />
<script type="text/javascript" language="javascript" src="jquery-1.8.3.min.js"></script><br />
<script type="text/javascript" language="javascript" src="jquery.SPServices-0.7.2.min.js"></script><br />
<script type="text/javascript" language="javascript" src="jsonix-scripts-1.2-all.js"></script><br />
<script type="text/javascript" language="javascript" src="BothMappings.js"></script><br />
<br />
<script type="text/javascript" language="javascript"><br />
<br />
$(document).ready(function () {<br />
<br />
var context = new Jsonix.Context([ settingsuri]);<br />
<br />
var unmarshaller = context.createUnmarshaller();<br />
var myURL = "MySettings.xml";<br />
unmarshaller.unmarshalURL(myURL,<br />
<span class="Apple-tab-span" style="white-space: pre;"></span>function (data)<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"></span>var objectFromURL = data;<br />
<span class="Apple-tab-span" style="white-space: pre;"></span>alert(objectFromURL);<br />
<span class="Apple-tab-span" style="white-space: pre;"></span>});<br />
<br />
});<br />
<br />
</script><br />
<div>
<br /></div>
<div>
- Turn on Debugging in IE Developer tools and place a breakpoint in the callback. The local watch clearly shows objectFromURL reflects the mappings of the XML file. Pretty sweet.</div>
S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-48450196695307514752013-01-13T16:20:00.003-08:002013-01-13T17:35:15.731-08:00Dev on Alternate MachineThis is for when you want to work on a different SharePoint 2007 dev machine but not have to change host name configuration entries in your Silverlight code.<br/>
<br/>
- edit the Windows hosts file adding <br/>
127.0.0.1 yourPrimaryServerName<br/>
<br/>
- add yourPrimaryServerName as a public url for the intranet zone of your web app in the alternate access mappings<br/>
<br/>
- add a host header value of "yourPrimaryServerName" to the site's IIS 6
configuration<br/>
<br/>
- set DisableLoopbackCheck see http://support.microsoft.com/kb/896861
<br/>
- add the following files to c:\inetpub\wwwroot (or a subdir, check IIS for the actual root dir the 80 site)<br/>
<br/>
clientaccesspolicy.xml<br/>
<br/>
<?xml version="1.0" encoding="utf-8" ?><br/>
<access-policy><br/>
<cross-domain-access><br/>
<policy><br/>
<allow-from http-request-headers="*"><br/>
<domain uri="*"/><br/>
</allow-from><br/>
<br/>
<grant-to><br/>
<resource include-subpaths="true" path="/"></resource><br/>
</grant-to><br/>
</policy><br/>
</cross-domain-access><br/>
<br/>
</access-policy><br/>
<br/>
crossdomain.xml<br/>
<br/>
<?xml version="1.0" encoding="utf-8"?><br/>
<!-- The file must be configured to allow access to the service from any other domain, <br/>
or it is not recognized by Silverlight 4.<br/>
Save the crossdomain.xml file to the root of the domain where the service is hosted. <br/>
If, for example, the service is hosted in http://fabrikam.com, <br/>
then the file must be located at http://fabrikam.com/crossdomain.xml.<br/>
--><br/>
<!DOCTYPE cross-domain-policy SYSTEM <br/>
"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"><br/>
<cross-domain-policy><br/>
<allow-http-request-headers-from domain="*" headers="*"/><br/>
<br/>
</cross-domain-policy>
<br/><a href="http://blog.mastykarz.nl/easy-access-sharepoint-central-administration-developers/">ref</a>S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-17054010414694122952012-12-13T05:58:00.001-08:002012-12-13T05:58:18.274-08:00Testing Email in SharePoint Dev EnvironmentTried <a href="http://sharethefrustration.blogspot.com/2009/11/test-email-without-smtp.html">this</a>. Installing local dummy SMTP not possible. Finally just configured the local SMTP Virtual Server in IIS 6.0 Manager, setting the FQDN of the local server in Advanced Delivery, leaving Smart host empty. Then in used the local server for Outbound SMTP server in CA Outgoing E-Mail Settings.<br />
<br />
Try adding a user to a group and leaving send email checked, and, bingo, email appears in c:\inetpub\mailroot\Queue.S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-74784112267866301902012-12-03T04:56:00.001-08:002012-12-03T04:57:11.505-08:00Finding Collapsed Groups in DataGridThis question came up <a href="http://social.msdn.microsoft.com/Forums/en-US/silverlightcontrols/thread/09494ca7-34f1-45bd-bd10-aa8ba3898262">here</a>, which I found when searching a solution to same problem.<br />
<br />
Here is some code that solves this issue:<br />
<br />
<pre>
List<string> grpItems = new List<string>();
string groupby = "";
foreach (var control in dataGrid1.GetVisuals().OfType<DataGridRowGroupHeader>())
{
var tog = XamlUtils.FindVisualChild<ToggleButton>(control);
var context = control.DataContext as CollectionViewGroup;
string nm = context.Name.ToString();
bool? chk = tog.IsChecked;
if (chk != null && (bool)chk)
{
grpItems.Add(nm);
}
groupby = control.PropertyName;
}
</pre>
<br/>
The methods in XamlUtils are FindVisualChild and GetVisuals which can be found at http://blogs.msdn.com/b/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-part-ii.aspx and http://blogs.msdn.com/b/kmahone/archive/2009/03/29/visualtreehelper.aspx respectively.
<br/>
Note: To get this to work, for some reason, it required removal of any filters on the PagedCollectionView.S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0tag:blogger.com,1999:blog-1138208274065767718.post-76707525844830252592012-11-01T09:58:00.002-07:002012-11-01T09:58:24.073-07:00GetListItemChangesSinceTokenAsync and PagingIt's possible to page with GetListItemChangesSinceTokenAsync. For instance, if the result returns a ListItemCollectionPositionNext value, you know there are more results.<br />
<br />
When make the call to retrive those results however, you must set changeToken to null. When I inserted the changeToken in a query for more paged results, I got zero results, which may seem counterintuitive, but actually makes sense because adding a changeToken that implicitely pointed to the next result set would be redundant as ListItemCollectionPositionNext already indicates this.S931Coderhttp://www.blogger.com/profile/17609807805714986516noreply@blogger.com0