Izpack can not find class of custom action defined for InstallPanel - izpack

I use 5.0.0-rc4 as izpack version and izpack-installer artifact exists as a dependency in my pom.xml.
<dependency>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-installer</artifactId>
<version>${izpack.version}</version>
</dependency>
I have defined a custom action DeletePreviousInstallationAction for InstallPanel.
InstallPanel definition is included in install.xml as below.
<panels>
<panel classname="TargetPanel"/>
<panel classname="UserInputPanel" id="panelUserInput"/>
<panel classname="InstallPanel">
<actions>
<action stage="preconstruct" classname="com.x.y.z.w.DeletePreviousInstallationAction" />
</actions>
</panel>
<panel classname="ProcessPanel"/>
<panel classname="SimpleFinishPanel"/>
</panels>
DeletePreviousInstallationAction code:
package com.x.y.z.w;
import com.izforge.izpack.api.data.InstallData;
import com.izforge.izpack.api.data.PanelActionConfiguration;
import com.izforge.izpack.api.handler.AbstractUIHandler;
import com.izforge.izpack.data.PanelAction;
public class DeletePreviousInstallationAction implements PanelAction {
#Override
public void executeAction(InstallData id, AbstractUIHandler auih) {
System.out.println("Intall path: " + id.getInstallPath());
}
#Override
public void initialize(PanelActionConfiguration pac) {
}
}
When I try to build setup project, I get Failure: Class 'com.x.y.z.w.DeletePreviousInstallationAction' not found. Why does this happen?

You are most likely missing it during compilation, it has to be added in "jar" section to install xml of izpack e.g.:
<jar src="#{jmx4ant:jmx4ant:jar}" stage="both" />

Related

Custom module issue

I tried creating one new module. For that i created indexController, config.xml, block, layout and other required files, even though i am unable to view the message that i wrote in my block file. Whenever the url is fired (http://mydomain.com/foobar/) the output "it is from foo bar" should be displayed, but at the moment it is not working.
My indexController.php code :
class Foo_Bar_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
Code related to block :
class Foo_Bar_Block_News extends Mage_Core_Block_Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function fetchRow()
{
echo "it is from foo bar";
}
}
code related to config.xml :
<?xml version="1.0"?>
<config>
<modules>
<Foo_Bar>
<version>1.0.0</version>
</Foo_Bar>
</modules>
<frontend>
<routers>
<foobar>
<use>standard</use>
<args>
<module>Foo_Bar</module>
<frontName>foobar</frontName>
</args>
</foobar>
</routers>
<layout>
<updates>
<bar>
<file>foobar.xml</file>
</bar>
</updates>
</layout>
<!--<events>
<catalog_product_load_after>
<observers>
<foo_bar>
<type>model</type>
<class>foo_bar/observer</class>
<method>catalogProductLoadAfter</method>
</foo_bar>
</observers>
</catalog_product_load_after>
</events>-->
</frontend>
<global>
<blocks>
<foobar>
<class>Foo_Bar_Block</class>
</foobar>
</blocks>
</global>
</config>
code related to layout.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<default>
<reference name="content">
</reference>
</default>
<foobar_index_index>
<reference name="content">
<block type="foobar/news" name="news_test" template="bar/check.phtml"/>
</reference>
</foobar_index_index>
</layout>
Code related to template file
<?php
echo $this->fetchRow()
?>
Any help realted to this will be appreciated.
The solution to this issue in my case is to Disable the compilation from admin. Everything else is fine. The desired output is obtained after disabling the compilation from admin.
To disable compilation login to admin side of your magento project and then go to system>>Tools>>Compilation and then click on disable button to disable the compilation.

How to use the extension point of other plugin? (Intellij Idea)

For example, plugin Intellij Idea TestNG has extension point:
<extensionPoints >
<extensionPoint qualifiedName="com.theoryinpractice.testng.listener" interface="org.testng.IDEATestNGListener"/>
</extensionPoints>
I want to use this extension point as follows:
<extensions defaultExtensionNs="TestNG-J">
<com.theoryinpractice.testng.listener implementation="org.example.MyTestNGListener" />
</extensions>
public class MyTestNGListener implements org.testng.IDEATestNGListener {
...
}
But it did not work. What am I doing wrong?
(If there are errors, I'm sorry, did the translation from Google Translate)
defaultExtensionNs must have FQN prefix of EP, not plugin ID:
<extensions defaultExtensionNs="com.theoryinpractice.testng">
<listener implementation="YourListenerFQN"/>
</extensions>
(http://devnet.jetbrains.com/message/5504720#5504720)

JUnit Rule not being executed when test fails

Following is my test file :
package test;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
public class TestWatcherTest
{
#Rule
public TestWatcher testWatcher = new TestWatcher()
{
protected void failed(Throwable e, Description description)
{
System.out.println("in failed()");
}
};
#Test
public void shouldFail()
{
Assert.assertTrue("Test failed", false);
}
}
Output is :
<failure message="Test failed" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Test failed at test.TestWatcherTest.shouldFail(TestWatcherTest.java:24)
</failure>
It seems failed() is not being executed. I read many posts but nothing seems to work for me. What am I doing wrong?
The issue was with ant configuration. From http://testautomationusingjunit.blogspot.com/2013/08/applying-rules-to-junit-tests-running.html, the target needs to be edited to contain JUnitCore in the classpath.
<target name="junit" depends="build">
<java classname="org.junit.runner.JUnitCore">
<classpath>
<path location="selenium_server/selenium-server-standalone-xxx.xx.jar"/>
</classpath>
</java>
<junit fork="no" haltonfailure="no" printsummary="true" failureProperty="test.failed" dir=".">
<test name="src.SampleTest" todir="./report" />
</junit>
</target>

Spring data repository #Autowiring is null when using #Transactional annotation on service bean

I am studying spring framework and trying to use it in my project. But I have came across the following problem with spring data repository and #Transactional annotation used in my service. The problem is that there are no exceptions on the spring start up. Later on when I try to access spring data repository I get NullPointerException. Maybe you have some thoughts that could help me.
I am using spring data repository define as following:
package net.question.data.repository;
import net.question.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepository extends JpaRepository<User, Long> {
}
Then I have a service defined which contains autowired repository:
package net.question.data.service;
import net.question.data.repository.UserRepository;
import net.question.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
#Service
#Transactional
public class UserService {
#Autowired
public UserRepository userRepository;
public void doStuff(User usr) {
// login will be here
}
}
here is the test to show my problem:
package net.question.spring;
import static org.junit.Assert.assertNotNull;
import net.question.data.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration("/app-context.xml")
public class InjectionTestSuite {
#Autowired
UserService userService;
#Test
public void testRepositoryInjection() {
assertNotNull(userService);
assertNotNull(userService.userRepository);
}
}
The test fails on the follwowing line:
assertNotNull(userService.userRepository);
If I remove the #Transactional annotation on the service then the test passes.
here is my app-context.xml file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd ">
<jpa:repositories base-package="net.question.data.repository" />
<!-- For discovering entity services -->
<context:component-scan base-package="net.question.data.service" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="hibernate_mysql" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven />
</beans>
Maybe you have some ideas, how to find the error?

How to limit Visibility of a popup menu only to a certain Project Type?

I am using menuContributions+popup to show a context menu in my plugin.xml. I need to limit it's visibility only to
certain type of Project(e.g. Dynamic Web Project) (Menu should appear on right click of only parent project folder) and
a particular folder(e.g Web Content) and it's sub folders inside the Project Folder structure.
I was able to achieve the 1) condition to some extent by using
<menuContribution locationURI="popup:common.new.menu?after=additions">
<command
label="Web Wiz"
commandId="commandId"
icon="icons/sample.gif">
<visibleWhen>
<with variable="selection">
<iterate ifEmpty="false"
operator="or">
<instanceof
value="org.eclipse.core.resources.IProject"/>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
but it appears for all kinds of projects...I need to limit it to only a Dynamic Web Project, so what should I add to meet this requirement in plugin.xml?
Add a propertyTester that will test your project type.
Use that tester in the visibleWhen
You can read about property-tester at the eclipse help, or at the extension help itself :)
EDIT - Check this one out as well - http://wiki.eclipse.org/Command_Core_Expressions#Property_Testers (especially the ResourcePropertyTester, which can provide you a built-in implementation that you can use)
For the second condition:
<test forcePluginActivation="true"
property="testWizard.propertyTester.checkFolder"
value="org.eclipse.wst.jsdt.core.jsNature"
</test>
is the reference to the property tester , which can be defined as
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="testwizard.wizards.MyPropTester"
id="MyPropTesterFolder"
namespace="testWizard.propertyTester"
properties="checkFolder"
type="org.eclipse.core.resources.IFolder">
</propertyTester>
then the kind of folder and it's subfolders can be tested as below in
package testwizard.wizards;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
public class MyPropTester extends PropertyTester{
#Override
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
IFolder folder=(IFolder)receiver;
String folderPath=folder.getProjectRelativePath().toString();
String arr[]=folderPath.split("/");
try {
if(folder.getProject().hasNature(expectedValue.toString()))
{
if(arr[0].equals("XYZ"))
{
return true;
}
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
}
<menuContribution locationURI="popup:common.new.menu?after=additions">
<command
label="Web Wiz"
commandId="commandId"
icon="icons/sample.gif">
<visibleWhen>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
<test
property="org.eclipse.core.resources.projectNature"
value="your-project-nature" />
</iterate>
</with>
</visibleWhen>
</command>
<menuContribution>