Building Struts 2 on Mac OS X with Maven using mvn install


When trying to build Struts 2 on Mac OS X (I'm using 10.4.8) you might get an error like:
 class="codeContent" class="codeContent"[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

----------
1) com.sun:tools:jar:1.5.0

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=com.sun -DartifactId=tools \
          -Dversion=1.5.0 -Dpackaging=jar -Dfile=/path/to/file

  Path to dependency: 
        1) org.apache.struts:struts2-core:jar:2.0.3-SNAPSHOT
        2) org.apache.struts:struts-annotations:jar:1.0-SNAPSHOT
        3) com.sun:tools:jar:1.5.0

----------
1 required artifact is missing.

for artifact: 
  org.apache.struts:struts2-core:jar:2.0.3-SNAPSHOT

from the specified remote repositories:
  Maven Snapshots (http://snapshots.maven.codehaus.org/maven2/),
  central (http://repo1.maven.org/maven2),
  opensymphony (http://maven.opensymphony.com),
  apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository),
  snapshots-maven-codehaus (http://snapshots.maven.codehaus.org/maven2)
The problem is that there is no tools.jar on Mac OS X. The analog for tools.jar on Mac OS X is classes.jar. A quick fix to allow the build to continue is to change the sun.jdk dependency in a pom.xml. For this, I edited the
 class="commentblock"pom.xml
located in
 class="commentblock"~/.m2/repository/org/apache/struts/struts-annotations/1.0-SNAPSHOT/
 class="codeContent"    <dependency>
      <groupId>com.sun</groupId>
      <artifactId>tools</artifactId>
      <version>1.5.0</version>
      <scope>system</scope>
      <!-- This line doesn't work on a Mac: <systemPath>${java.home}/../lib/tools.jar</systemPath> -->
      <systemPath>${java.home}/../Classes/classes.jar</systemPath>

    </dependency>

Troubleshooting and other Tips

OutOfMemoryError

If you are getting OutOfMemoryError exceptions when attempting a full build of Mule you may try increasing the max heap and the PermGen space sizes. Either export a MAVEN_OPTS variable in your shell or add it to the original mvn script.

 class="codeContent"MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m

or edit your bash shell

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"
 
 
 
 

How to force do...






























<


How to force download of an attachment/application using JSP.

Many of you guys out there would have experienced the problems associated with the browser interpreting whether to
download an application/attachment or open up in the same browser instance. Whenever microsoft's IE encounters a href tag
pointing to an excel/doc/ppt or any other tool whose plugins have been installed on the client, it opens the attachment
in the same instance of the browser. Hence if a user has to save the file then he has to be smart enuff to click on file
--> save as from the menu and then save to his hard disk.

But most web-applications are designed for ease and not keeping the user's technical skill or knowledge in view. Hence
when a user clicks on a href(which might say click to download pdf version) pointing to say mydownloadable.pdf, what
happens is the pdf downloads the file to his temporary internet files and shows it in the browser.

The code snippet below shows how one can force download a file/app/attachment to the user irrespective of whether the
user has a necessary plugin or not. Even the name of the downloaded file can be specified dynamically.

<!--contents of download.jsp-->
<%@ page import="java.util.*,java.io.*"%>
<!--Assumes that file name is in the request objects query Parameter -->

<%
//read the file name.

File f = new File ("c:/fop/mypdf/" + request.getParameter("file") );
//set the content type(can be excel/word/powerpoint etc..)
response.setContentType ("application/pdf");
//set the header and also the Name by which user will be prompted to save
response.setHeader ("Content-Disposition", "attachment;
filename=\"LicenseAgreement.pdf\"");

//get the file name
String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
//OPen an input stream to the file and post the file contents thru the
//servlet output stream to the client m/c

InputStream in = new FileInputStream(f);
ServletOutputStream outs = response.getOutputStream();
int bit = 256; int i = 0;
try {
while ((bit) >= 0) {
bit = in.read();
outs.write(bit);
}
//System.out.println("" +bit);

} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
// System.out.println( "\n" + i + " byt
// es sent.");
// System.out.println( "\n" + f.length(
// ) + " bytes sent.");
outs.flush();
outs.close();
in.close();
%>




Hope you find this useful...

Happy Programming!!!

 
 
 
 

Implementing favicon.ico with tomcat


If you wish to use  the favicon.ico file, be sure to add the following to the web.xml file in the conf directory:
    <mime-mapping>
        <extension>ico</extension>
        <mime-type>image/x-icon</mime-type>
    </mime-mapping>

Then just put your favicon.ico file in the root directory of your web application.  Voila!

 
 
 
 

Integrating FCKEditor into Roller


For those of you who have worked with FCKeditor, you may wonder how to include this growing product in JRoller.  Well, it is actually pretty easy.  I'll maintain this site from release to release, if these instructions do not work for you, please email me, and I will gladly update them.

Downloading FCKEditor:

  1. Download the tar archive from http://xtian.stonescape.net/downloads/Fck4Roller.tar
  2. Unpack the tar archive, which includes the FCKEditor 2.0 RC2 source (FCKeditor), a README, and the JSP file for use.

Installing:

  1. Copy FCKeditor directory to {roller dir}/editor.
  2. Copy editor-fckeditor.jsp file to {roller dir}/weblog
  3. Go to the admin panel within JRoller, and add the new editor to your list.

Configuring:

  • In editor-fckeditor.jsp, you can easily change the default height of the editor by changing the following line from the default height of 400px: 
    • oFCKeditor.Height=400;
  • In addition, you can alter the components of the editor by changing the toolbar set.  The default set is set to "Roller" in the file editor-fckeditor.jsp.  Make the following modifications:
    1. If you like, alter the name of the toolbar you want to use in file editor-fckeditor.jsp:  oFCKeditor.ToolbarSet="Roller";
    2. Alter the definition of "Roller in the fckconfig.js file located in the  FCKeditor folder.  I have defined the following:
 FCKConfig.ToolbarSets["Roller"] = [
    ['Source','-','Cut','Copy','Paste','PasteText','PasteWord'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    ['Link','Unlink'],
    ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
    ['Table','Rule','SpecialChar','Smiley'],
    ['OrderedList','UnorderedList','-','Outdent','Indent'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
    ['FontFormat','FontName','FontSize','TextColor']
] ;
I have removed the Preview, NewPage, Print, Image, Style, BGColor command as they didn't have a lot of meaning for Roller.  The one command that is questionable is the Image command, because I do not know what the policies for upoading and linking  on a site are.

Other possible items:  the smilies are defaulted in the fckconfig.js file to use the ones with FCKeditor.  You can change the path to load another set of smilies.  The other features, "image browsing", "link upload", etc. are pretty neat, but depend a lot on the specific site.

If you have any questions, please look at the FCKeditor message boards, or email me.
 
 
 
 
 
 

« July 2008
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today
Theme by Christian Stone.