Wednesday 5 December 2012

eclipse could not find default drools runtime

Problem Statement: eclipse could not find default drools runtime

Solution: 
Edit .project file in your project directory, from the .project file delete following:

<buildCommand>
     <name>org.drools.eclipse.droolsbuilder</name>
     <arguments>
     </arguments>
</buildCommand>

then re-import your project into workspace. Delete it, without deleting from file system, and then import it as existing project.

Sunday 1 July 2012

Maven 2.2.1 Java Code Review

Following POM.xml template is a cool and automated way to generate maven site. This site will have reports  publishing findbugs, checkstyle, PMD, CPD, Emma, and plenty others.

Requirements: MAVEN 2.2.1
JDK 1.6 and over (May work with 1.5)

If there are plenty of class files then you will need to set MAVEN_OPTS=-Xmx512m -Xms512m based on memory requirements.



<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mujahed</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Name Of the Project</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
</properties>

<organization>
<name>My Company</name>
</organization>

<developers>
<developer>
<name>Mujahed Syed</name>
<email>msyed1983@gmail.com</email>
</developer>
</developers>

<profiles>
<profile>
<id>project_profile</id>
</profile>
</profiles>

<build>
<sourceDirectory>C:\work\aix_workspace\aix\src</sourceDirectory>
<scriptSourceDirectory>C:\work\aix_workspace\aix\BuildScripts\</scriptSourceDirectory>
<testSourceDirectory>C:\work\aix_workspace\aix\BuildScripts\test\</testSourceDirectory>
<outputDirectory>C:\work\aix_workspace\aix\target\classes</outputDirectory>
<testOutputDirectory>C:\work\aix_workspace\aix\target\test-classes</testOutputDirectory>

<resources>
<resource>
<directory>C:\work\aix_workspace\aix\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>C:\work\aix_workspace\aix\test\resources</directory>
</testResource>
</testResources>
<directory>C:\work\aix_workspace\aix\target</directory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>C:\work\jdk1.6.0_07\bin\javac.exe</executable>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<meminitial>1028m</meminitial>
<maxmem>1028m</maxmem>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>${output.dir}</outputDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<version>1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9</version>
<configuration>
<configLocation>C:/lib/checkstyle-5.4/sun_checks.xml</configLocation>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<minmemory>512m</minmemory>
<maxmemory>1g</maxmemory>
<links>
<link>http://commons.apache.org/lang/api</link>
<link>http://docs.oracle.com/javase/6/docs/api/</link>
</links>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>surefire-report-maven-plugin</artifactId>
<version>2.0-beta-1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
</plugin>
<plugin>
<artifactId>maven-clover-plugin</artifactId>
<version>2.4</version>
</plugin>
                        <plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<targetJdk>1.6</targetJdk>
<minimumPriority>3</minimumPriority>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0-beta-2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
<version>1.0.0-beta-1</version>
</plugin>

</plugins>
    </reporting>

<dependencies>
</dependencies>

</project>

Saturday 25 June 2011

ant weblogic classpath problem DeploymentManagerCreationException

if you have spaces in your classpath entry and if you are trying to deploy weblogic through ant deploy task there can be issues like:

[wldeploy] javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException[wldeploy] at weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.(WebLogicDeploymentManagerImpl.java:121)

To solve this, you will have to remove spaces from classpath.

Tuesday 15 March 2011

javax.naming.NoInitialContextException: Need to specify class name in environment

if jndi.properties file is missing then you get this error. check the contents of jar file. Error stack trace is


[java] javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parame
ter, or in an application resource file: java.naming.factory.initial
[java] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
[java] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
[java] at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:392)
[java] at ejb30.client.BankClient.main(Unknown Source)

Sunday 13 March 2011

javax.naming.NoInitialContextException

[java] javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory


This problem can be solved by adding weblogic.jar to the classpath
<?xml version="1.0" encoding="UTF-8"?>
<project name="ch03-lab01" default="usage" basedir=".">
<property environment="env" />
<property file="env.properties" />
<property name="app.name" value="ch03-lab01" />
<property name="config.dir" value="${basedir}/config" />
<property name="src.dir" value="${basedir}/src" />
<property name="build.dir" value="${basedir}/build" />

<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="${weblogic.home}/server/lib/weblogic.jar" />
</classpath>
</taskdef>

<path id="j2ee.classpath">
<pathelement location="${build.dir}" />
<fileset dir="${bea.home}/modules">
<include name="javax.ejb_3.0.1.jar" />
<include name="javax.annotation_1.1.jar" />
<include name="javax.persistence_1.0.0.0_1-0.jar" />
</fileset>
</path>

<target name="usage">
<echo message="build file for ${app.name}, available targets are:" />
<echo message="==================================================" />
<echo message="clean ---------> deletes build directory" />
<echo message="undeply ---------> deletes ear file from server" />
<echo message="all ---------> clean, complile, package and deploy the app" />
</target>

<target name="all">
<antcall target="usage" />
<antcall target="run-client" />
</target>


<target name="clean">
<delete dir="${build.dir}" />
<mkdir dir="${build.dir}" />
<mkdir dir="${build.dir}/client" />
<mkdir dir="${build.dir}/client/META-INF" />
</target>

<target name="compile" depends="clean">
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="j2ee.classpath" includeantruntime="false" />
</target>

<target name="package-ejb" depends="compile">
<jar jarfile="${build.dir}/BankService.jar">
<fileset dir="${build.dir}">
<include name="ejb30/session/**" />
<include name="ejb30/entity/**" />
</fileset>
<metainf dir="${config.dir}">
<include name="persistence.xml" />
</metainf>
</jar>
</target>

<target name="package-client" depends="compile">
<copy todir="${build.dir}/client">
<fileset dir="${config.dir}" includes="jndi.properties" />
</copy>
<jar jarfile="${build.dir}/Client.jar" manifest="${config.dir}/manifest.mf">
<fileset dir="${build.dir}/client" includes="**" />
<fileset dir="${build.dir}">
<include name="ejb30/client/Client.class" />
</fileset>
</jar>
</target>

<target name="package-ear" depends="package-ejb, package-client">
<jar destfile="${build.dir}/BankService.ear"
basedir="${build.dir}"
includes="BankService.jar"/>
</target>


<target name="deploy" depends="package-ear">
<wldeploy user="${admin.username}" password="${admin.password}"
adminurl="t3://${weblogic.hostname}:${weblogic.port}"
debug="true" action="deploy" name="BankService"
source="${build.dir}/BankService.ear" failonerror="${failondeploy}" />
</target>

<target name="undeploy">
<wldeploy user="${admin.username}" password="${admin.password}"
adminurl="t3://${weblogic.hostname}:${weblogic.port}"
debug="true" action="undeploy"
name="BankService" failonerror="${failondeploy}" />
</target>

<target name="run-client" depends="deploy">
<java classname="ejb30.client.Client" fork="yes">
<arg line="3 Belfast Northern"/>
<classpath>
<pathelement location="${build.dir}/Client.jar" />
<pathelement location="${weblogic.home}/server/lib/weblogic.jar" />
</classpath>
</java>
</target>
</project>

Sunday 6 March 2011

The type java.lang.Object cannot be resolved. It is indirectly referenced fromrequired .class files eclipse

Eclipse new Error Discovered

The type java.lang.Object cannot be resolved. It is indirectly referenced fromrequired .class files eclipse


Solution

Add the following code to .classpath file:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

Wednesday 24 November 2010

Specified VM install not found: type Standard VM, name jre6

Ant wont run says "Specified VM install not found: type Standard VM, name jre6"!
Solution : delete the "C:\Users\Mujahed\workspace_helios\.metadata\.plugins\org.eclipse.debug.core\.launches\projectname build.xml.launch file"
and problem is solved"