You are here

Strange Exceptions when Compiling Code and Solutions in J2ME Polish (updated often)

During the J2ME development with J2ME Polish, sometimes I met some strange exception when I debugged or compiled the codes. In this post I will write down them all and the according solution(if I have Tongue out), so this post will be updated frequently.

1, Exception description:
BUILD FAILED
E:\My Documents\WorkSpace\testproject\build.xml:23: taskdef class de.enough.polish.ant.PolishTask cannot be found

When I compile my project, I met this exception unmeantly, even this project could be run yesterday or few hours ago. Strange...
This is according task node in build.xml, every thing seems to be ok:
<!-- Definition of the J2ME Polish task: -->
<taskdef name="j2mepolish"
classname="de.enough.polish.ant.PolishTask" classpath="${polish.home}/bin/classes:${polish.home}/lib/enough-j2mepolish-build.jar:${polish.home}/lib/jdom.jar"/>

Solution:
1, This mainly happened when you use CVS of Polish. Please update your polish CVS: enough-polish-build, enough-polish-j2me and enough-polish-runtime, then run the build.xml in each project (1st run j2me, then runtime, and last with build). This exception will disappear.

2,Please check such "<property file="yourusername.properties" />" code in build.xml, and make sure there is one properties file named as yourusername.properties was put together with build.xml. If this properties file is missing, the error will come.

2, Exception description:

[j2mepolish] proguard: Maybe you meant the fully qualified name 'src.Midlet'?
[j2mepolish] proguard: You should check your configuration for typos.

When you compile the project, proguard will show you such message and stop working.
And you project could have such structure, resources and source folders are set to be Source Folder :

-Project
---resources
---source
---src
Midlet.java
build.xml
user.properties


Solution:

Add subfolder in your source folder "src" and the structure should be like this:
-Project
---resources
---source
---src
--easywms
--com
Midlet.java
build.xml
user.properties

compile the project again, proguard will still ask you:
[j2mepolish] proguard: Maybe you meant the fully qualified name 'easywms.com.Midlet'?
[j2mepolish] proguard: You should check your configuration for typos.

But this time, it will go on working.

3, Exception description:

[javac] E:\My Documents\WorkSpace2\mpm\source\src\www\easywms\com\view\FormLogin.java:46: <identifier> expected
[javac] public FormLogin(UIController control, Displayable parent, de.enough.polish.ui.StyleSheet.mainscreenStyle ){

Today When I updated Polish CVS, my project got such exception when i run build.xml, but it worked one minute before. By tracking the code, I found Polish has changed some rules, for one Screen instance, you'd better put the css sytle just befor the "super" method, but not before the class constructure.


Solution:

Old code:
//#style screenStyle
public FormLogin(UIController control, Displayable parent ){
super("title");
...
}

Change to new code:
public FormLogin(UIController control, Displayable parent ){

//#style screenStyle

super("title");
...
}


4, Exception description:
[j2mepolish] java.lang.IllegalArgumentException
[j2mepolish] at java.lang.ProcessImpl.<init>(Unknown Source)
[j2mepolish] at java.lang.ProcessImpl.start(Unknown Source)
[j2mepolish] at java.lang.ProcessBuilder.start(Unknown Source)
[j2mepolish] at java.lang.Runtime.exec(Unknown Source)
[j2mepolish] at de.enough.polish.util.ProcessUtil.exec(ProcessUtil.java:160)
[j2mepolish] at de.enough.polish.util.ProcessUtil.exec(ProcessUtil.java:107)
[j2mepolish] at de.enough.polish.util.ProcessUtil.exec(ProcessUtil.java:86)
[j2mepolish] at de.enough.polish.obfuscate.ProGuardObfuscator.obfuscate(ProGuardObfuscator.java:209)
[j2mepolish] at de.enough.polish.ant.PolishTask.obfuscate(PolishTask.java:2404)
[j2mepolish] at de.enough.polish.ant.PolishTask.execute(PolishTask.java:549)
[j2mepolish] at de.enough.polish.ant.PolishTask.execute(PolishTask.java:388)
[j2mepolish] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[j2mepolish] at org.apache.tools.ant.Task.perform(Task.java:364)
[j2mepolish] at org.apache.tools.ant.Target.execute(Target.java:341)
[j2mepolish] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[j2mepolish] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[j2mepolish] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[j2mepolish] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[j2mepolish] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[j2mepolish] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[j2mepolish] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[j2mepolish] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
[j2mepolish] ProGuard arguments: [java, -jar, E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\lib\proguard.jar, -injars, "'E:\My Documents\WorkSpace2\easytest\build\real\source.jar'", -outjars, "'E:\My Documents\WorkSpace2\easytest\build\real\dest.jar'", -libraryjars, "'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\mmapi.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\mmapi.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\midp-2.0.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\cldc-1.1.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\nokia-ui.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\wmapi.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\mmapi.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\btapi.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\m3g.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\pdaapi.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\sip-1.0.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\m2g.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\locationapi-1.0.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\mmapi.jar'";"'E:\My Documents\WorkSpace2\easytest\..\polishbackup\07\enough-polish-build\import\m2g.jar'";D:\Devices\WTK25\lib\JSR234.jar, -keep, class com.mwaysolutions.bc.BCMidlet, -keep, class MyMidlet, -dontoptimize, -applymapping, "'E:\My Documents\WorkSpace2\easytest\build\real\Nokia\N95\de_DE\input-obfuscation-map.txt'", -printmapping, "'E:\My Documents\WorkSpace2\easytest\build\real\Nokia\N95\de_DE\obfuscation-map.txt'", -allowaccessmodification, -overloadaggressively, -defaultpackage, , -dontusemixedcaseclassnames]

BUILD FAILED
E:\My Documents\WorkSpace2\easytest\build.xml:58: ProGuard is unable to obfuscate: java.lang.IllegalArgumentException



Solution:

The happed mostly with old version of polish under v2.03, because the old polish use Proguard 3.1(-), and this verion of Proguard is not compatible with WTK 2.5+.
Please use WTK 2.2 to preverify your application, just change the WTK path in your polish configuration.

3, Exception description:

BUILD FAILED

E:\My Documents\WorkSpace2\Modict\build.xml:59: The MIDlet [com.easywms.midlet.Midlet] could not be found. Check your <midlet>-setting in the file [build.xml] or adjust the [sourceDir] attribute of the <build>-element.The MIDlet should be in E:\My Documents\WorkSpace2\Modict\source\src\com\easywms\midlet\Midlet.java

Solution:

in build.xml
    <build usePolishGui="yes" workDir="${dir.work}" fullscreen="menu" binaryLibraries="lib/cldc_classes.zip" polishDir="../enough-polish-j2me/source/src">

Change to new code:
    <build usePolishGui="yes" workDir="${dir.work}" fullscreen="menu" binaryLibraries="lib/cldc_classes.zip">

to be continued.....

Comments

E:\java_j2me\framedform\build.xml:99: Invalid CSS code: The style-selector [colorchoicegroup:hover] contains invalid characters, please use only alpha-numeric characters for style-names.

Excuse me ,what's the matter with it. when i use the sample,my polish.css don't pass.what can i do.

[quote=chiv_gavin]E:\java_j2me\framedform\build.xml:99: Invalid CSS code: The style-selector [colorchoicegroup:hover] contains invalid characters, please use only alpha-numeric characters for style-names.

Excuse me ,what's the matter with it. when i use the sample,my polish.css don't pass.what can i do.[/quote]
please check your polish.css, open this file and find the sector for colorChoiceGroup:hover, this is the css code inside(i use polish 2.03), Do you have any non-english letter inside? which country are you from, make sure there is no letter from your language inside. If not, you can try to use the code here to replace yours.

.colorChoiceGroup:hover {
padding: 2;
font-color: focusedFontColor;
layout: expand | center;
background {
type: web20;
color: highlightedBgColor;
circle-anchor: top;
circle-color: #A2A2f9;
padding: 3;
padding-top: 0;
padding-bottom: 8;
}
label-style: .labelFocused;
}

please check the polish home with written in build.xml
may possible it will mismatch with actual