A Technology Blog About Code Development, Architecture, Operating System, Hardware, Tips and Tutorials for Developers.
Showing posts with label TIPS. Show all posts
Showing posts with label TIPS. Show all posts
Tuesday, September 20, 2016
Sunday, December 9, 2012
asm-3.1.jar; error in opening zip file
I encountered a Maven error caused by asm-3.1.jar. The error message was saying:
1 | error: error reading /home/satish/.m2/repository/asm/asm/3.1/asm-3.1.jar; error in opening zip file |
I found soon that asm-3.1.jar in .m2 was not a (corrupt) jar file but an HTML file whose content was as follows:
1 2 3 4 5 6 7 | <html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx/0.6.39</center> </body> </html> |
It seems 'mvn' cannot handle '301 Moved Permanently' properly. So, I downloaded asm-3.1.jar from the central repository.
1 2 3 | cd ~/.m2/repository/asm/asm/3.1 wget http://search.maven.org/remotecontent?filepath=asm/asm/3.1/asm-3.1.jar mv remotecontent\?filepath\=asm%2Fasm%2F3.1%2Fasm-3.1.jar asm-3.1.jar rm -f asm-3.1.pom |
Be sure to delete the old jar and .pom file.
Sunday, November 25, 2012
Have you run APT to generate them?
While deploying a document style web service, you may get the following exception.
1 2 | SEVERE: WSSERVLET11: failed to parse runtime descriptor: runtime modeler error: Wrapper class com.techiekernel.ws.jaxws.document.jaxws.CallFooBar is not found. Have you run APT to generate them? com.sun.xml.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.techiekernel.ws.jaxws.document.jaxws.CallFooBar is not found. Have you run APT to generate them? |
If you remember in my article "RPC-style vs Document-Style Web Service", I have said in document style web service there are no overheads of marshalling and de marshalling associated with SOAP engine. So you have to generate the artifacts for the web services. You can use the wsgen tool from JDK to generate the artifacts or you can use the maven plugin to achieve that. I am doing to show both way to generate the artifacts.
1 | wsgen -verbose -keep -cp target/classes/ com.techiekernel.ws.jaxws.document.FooBarImpl -d src/main/java/ |
After adding the plug in the pom.xml will look like this.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.techiekernel</groupId> <artifactId>webservice-JAX-WS-Web</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>webservice-JAX-WS-Web Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> <version>2.1.5</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <!-- wsgen for web service artifact generation --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>1.11</version> <executions> <execution> <id>document</id> <goals> <goal>wsgen</goal> </goals> <configuration> <sei>com.techiekernel.ws.jaxws.document.FooBarImpl</sei> <genWsdl>true</genWsdl> <keep>true</keep> <verbose>true</verbose> </configuration> </execution> <execution> <id>mtom</id> <goals> <goal>wsgen</goal> </goals> <configuration> <sei>com.techiekernel.ws.jaxws.mtom.FileImageServer</sei> <genWsdl>true</genWsdl> <keep>true</keep> <verbose>true</verbose> </configuration> </execution> </executions> </plugin> </plugins> <finalName>webservice-JAX-WS-Web</finalName> </build> </project> |
Now the artifacts needed for document style web service will be generated automatically. Now you are good to deploy the application.
Embedded error: com/sun/mirror/apt/AnnotationProcessorFactory
You may encounter the following error while executing the maven. Try changing the plugin version of jaxws-maven-plugin. In my case, it worked from changing it from 1.10 to 1.11.
1 2 3 4 5 6 | print 'hello world!'a[ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to execute wsgen Embedded error: com/sun/mirror/apt/AnnotationProcessorFactory com.sun.mirror.apt.AnnotationProcessorFactory |
Monday, November 12, 2012
Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
I started using JDK 7 now and recently i found one problem while executing "mvn install" for a web project using maven2. So I am sharing the fix here.
The only thing you need to do is to specify previous version of maven-war-plugin in your pom.xml.
The only thing you need to do is to specify previous version of maven-war-plugin in your pom.xml.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
<finalName>webservice-JAX-WS</finalName>
</build>
Sunday, November 11, 2012
Install sublime in ubuntu
The easy way to install the sublime editor is use the following commands
This command will add the sublime source to Ubuntu apt repository so that you can install as well as you can get the updates in the Ubuntu update Manager.
This command will add the sublime source to Ubuntu apt repository so that you can install as well as you can get the updates in the Ubuntu update Manager.
sudo add-apt-repository ppa:webupd8team/sublime-text-2;
sudo apt-get update;
Now You can give the command for installation
sudo apt-get install sublime-text
Friday, November 9, 2012
annotations are not supported in -source 1.3
annotations are not supported in -source 1.3
If you are using Maven 2 and you see this issue when you are building your applications, then easy way out is to add the following snippet to your pom.xml.
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
Wednesday, November 7, 2012
Upgrading Ubuntu from jaunty 9-04 to lucid 10-04
Recently the lack of support for the version of Ubuntu I was lumped
with on my VPS (9.04) was starting to be a major hindrance to
development. It appears that once an Ubuntu version gets too old all the
packages get deprecated completely, rendering the package manager apt
completely useless.
Obviously I had put off upgrading long enough, so went searching on
the best way to migrate to the newest version. The first command I found
seemed pretty simple;
sudo do-release-upgrade
This should automagically download the latest kernel source and upgrade all packages to the newest supported version, awesome. However, if it was that simple then I wouldn’t be blogging about it right? Right.
It appears that this command gets deprecated when you fall more than one version behind. So although it can be used effectively to upgrade from Karmic to Lucid, it doesn’t work when upgrading from Jaunty. For reference, the the command gives the following output:
It appears that this command gets deprecated when you fall more than one version behind. So although it can be used effectively to upgrade from Karmic to Lucid, it doesn’t work when upgrading from Jaunty. For reference, the the command gives the following output:
sudo do-release-upgrade
Checking for a new ubuntu release
Done Upgrade tool signature
Done Upgrade tool
Done downloading
extracting 'lucid.tar.gz'
authenticate 'lucid.tar.gz' against 'lucid.tar.gz.gpg'
tar: Removing leading `/' from member names
Reading cache
Checking package manager
Can not upgrade
An upgrade from 'jaunty' to 'lucid' is not supported with this tool.
In order to pull this off we firstly need to upgrade to Karmic. Luckily
there is a small hack that allows us to upgrade all our packages to
Karmic versions, including the kernel.
Edit the apt sources list so that it looks like this:
Edit the apt sources list so that it looks like this:
sudo nano /etc/apt/sources.list
## EOL upgrade sources.list
# Required
deb http://archive.ubuntu.com/ubuntu/ karmic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ karmic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ karmic-security main restricted universe multiverse
# Optional
#deb http://archive.ubuntu.com/ubuntu/ karmic-backports main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu/ karmic-proposed main restricted univ
Now, if we run a system upgrade, all Karmic packages will be downloaded and installed, including the new kernel.
sudo apt-get update && apt-get upgrade
Now we are running Karmic we can upgrade to Lucid using:
sudo do-release-upgrade
Hopefully you should not have any issues with this, but I had a couple with the old kernel files.
Explained by this StackOverflow post by me, I was stuck with some old kernel modules that would not uninstall because the kernels no longer existed. This was giving me this error message every time I ran apt:
Explained by this StackOverflow post by me, I was stuck with some old kernel modules that would not uninstall because the kernels no longer existed. This was giving me this error message every time I ran apt:
The following packages will be REMOVED
linux-restricted-modules-2.6.28-11-server
linux-restricted-modules-2.6.28-19-server
Thank god for StackOverflow or I would still be stuck on it now. Check
the link above for the given solution. Apart from that, and a few issues with my Apache server, it was a relatively smooth upgrade.
Thursday, August 30, 2012
Workspace in use or cannot be created - Eclipse
Eclipse is saying that the "Workspace in use or cannot be created" in Ubuntu. I say ok, probably a lock file was left behind and so I do:
rm ~/workspace/.metadata/.lock
No error (so the file was left behind), yet the problem is not solved. I tried clearing out the workspace path. Same problem.
Googleing, I found this post, so I ran:
sudo gedit /usr/share/eclipse/configuration/.settings/org.eclipse.ui.ide.prefs
removed the RECENT_WORKSPACES line. It works now.
Reference:
http://abautu.blogspot.in/2009/05/eclipse-says-workspace-in-use-or-cannot.html
Touch pad is not working on Ubuntu 11.04
Following is blog post with respect to the problem which I faced on my dell vostro laptop with Ubuntu 11.04. My mouse pad(Touch pad) was not working after login screen.
After some googling I found forum articles which describing same problem. Those peoples have different version of Ubuntu with different manufactures of laptop. But I didn't found an exact cause of this issue.
Anyways following is the solution,
Execute following command on terminal
gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true
Reference:
http://blog.railsupgrade.com/2011/05/touch-pad-is-not-working-on-ubuntu-1104.html
Thursday, February 24, 2011
IMAGE FLUSHING IN JSF
Recently in my project we got one problem that we are getting wrong barcodes. We use to call one API which used to give us a byte array which is a barcode. We are using ice faces and we were rendering the byte array as bellow.
<ice:graphicImage value="#{bytearray}" height="32px" width="150px" rendered="true">
Initially we thought it is the barcode API, which is giving the wrong barcode. I spent some time to find the root cause and tried creating the barcode image file in each layer of the application. Even I found the correct barcode in my MBean, but the moment it goes to the UI it came wrong. That is how we conclude that there is no problem with the barcode API, rather there is a problem with image flushing in JSF. Next task as to find a alternative solution and we came up with a solution to use a servlet to get the byte array. And we used the url to call the servlet from the graphicImage object. The demo solution is bellow.
JSF:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<jsp:directive.page contentType="text/html;charset=ISO-8859-1"
pageEncoding="ISO-8859-1" />
<f:view>
<ice:graphicImage id="autogenbookmark2"
url="${testBean.imgUrl}"
/>
</f:view>
</jsp:root>
MBean:
public class TestBean {
private static int i =0;
public String imgUrl;
public TestBean() {
imgUrl = "/barcode?i=" + i + "&p=" + System.currentTimeMillis();
i++;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
}
Servlet:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class TestServlet extends HttpServlet {
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
@SuppressWarnings("deprecation")
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("img/gif");
System.out.println(request.getParameter("i"));
ServletOutputStream os = response.getOutputStream();
FileInputStream fis = null;
int i = Integer.parseInt(request.getParameter("i"));
if(i % 2 == 0) {
fis = new FileInputStream("d://1.gif");
}
else {
fis = new FileInputStream("d://2.gif");
}
byte b[] = new byte[fis.available()];
response.setContentLength(fis.available());
fis.read(b);
os.write(b);
os.flush();
os.close();
}
}
Sunday, December 19, 2010
JSESSIONID & APACHE STICKY SESSION
Recently I and my team implemented the sticky session feature from apache to our application. After that we started getting frequent session time out issue from testing team. After a long analysis we found, the browser is not flushing the JSESSIONID each time the new session get created from the server. So if the cached session is of node 1 and new session is get created from node 2 the user used to get the session time out problem as apache used to redirect the request to node 1, where there is no session available.We found out this after analyzing the request header and server logs.
So we came up with a solution to flush the JSESSIONID each time the user comes to login page. Bellow is the java script code for the same.
<script>
setCookiesecure("JSESSIONID", getCookie("JSESSIONID"), -1, "/", null, true);
</script>
function setCookiesecure (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + value + ((expires) ? "; expires=" + expires : "") + ((path) ? ";path=" + path : "") + ((domain) ? "; domain=" +domain :"") + ((secure) ? "; secure" : "");
}
function getCookie( name )
{
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring(0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
So we came up with a solution to flush the JSESSIONID each time the user comes to login page. Bellow is the java script code for the same.
<script>
setCookiesecure("JSESSIONID", getCookie("JSESSIONID"), -1, "/", null, true);
</script>
function setCookiesecure (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + value + ((expires) ? "; expires=" + expires : "") + ((path) ? ";path=" + path : "") + ((domain) ? "; domain=" +domain :"") + ((secure) ? "; secure" : "");
}
function getCookie( name )
{
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring(0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
Tuesday, June 1, 2010
OBJECT ORIENTED PROGRAMING WITH JAVASCRIPT
JavaScript is a object based language and Java is a object oriented language. There are lot of object oriented features comes with java like static and non-static members, private and public members, inheritance etc. So why can't we have all these in JavaScript??? After googling and discussing with some of the JavaScript developers, finally we could able to demonstrate the object oriented features using JavaScript. We made use of JavaScript function and prototype to achieve this.
Work Flow:
1. One base class is created.
2. Another child class created extending the base class to demonstrate the inheritance.
3. One subclass created extending the second class to demonstrate the multilevel inheritance.
I am sharing the source code to better understand, what we did.
Note:
1. All the classes will be having static, non-static, private and public members.
2. In the test client we are demonstrating some of these features.
3. To test the other features, additional caller codes has to be added.
4. What ever we worked out is not the actual object oriented features in JavaScript. But certainly works like that.
5. There can be many other ways to do the same.
Shared Items:
1. Source Code