0

ClassNotFoundException with "use"

asked 2009-01-16 20:57:00 +0800

james gravatar image james
255 2

updated 2009-01-16 22:55:37 +0800

I am sorry if this question seems a bit rediculous, but I'm still pretty new to ZK, and java in general.
I am consistently been unsuccessful with "use"ing or "apply"ing classes. I tried this little tutorial, as an example...
How to load tab contents on demand http://www.zkoss.org/smalltalks/netbeans2/netbeans2.dsp
And I get this as an exception "org.zkoss.zk.ui.UiException: java.lang.ClassNotFoundException: com.MyTabbox"
Likewise, this is the root cause "java.lang.ClassNotFoundException: com.MyTabbox"

When I try to use or apply a class the normal error is the 'ClassNotFoundException:' for what ever the name of the class is
Can anyone help me understand why I'm not able to use or apply classes?
I use tomcat 6, if that makes much of difference.
Thank you for any and all of your help

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2009-01-17 02:25:40 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

updated 2009-01-17 02:25:48 +0800

can you provide you project config and test code ?
i think you didn't have right classpath or compile the source correctly .

link publish delete flag offensive edit

answered 2009-01-19 17:08:07 +0800

james gravatar image james
255 2

Here is the code...

index.zul

<zk>
    <window id="root">    
        <tabbox use="com.MyTabbox" id="tabbox" width="100%" >  
            <tabs>  
                <tab label="Preload"/>  
                <tab label="OnDemand 1"/>  
                <tab label="OnDemand 2"/>  
            </tabs>  
            <tabpanels>  
                <tabpanel>  
                    This panel is pre-loaded.  
                </tabpanel>  
                <tabpanel id="second"> 
                    <include id="secondContent" src=""/>
                </tabpanel>  
                <tabpanel id="third"> 
                    <include id="thirdContent" src=""/>
                </tabpanel>
            </tabpanels> 
        </tabbox> 
    </window>
</zk>

MyTabbox.java
package com;

import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Path;
import org.zkoss.zul.Include;
import org.zkoss.zul.Tabpanel;

public class MyTabbox extends org.zkoss.zul.Tabbox {
    
private int i=0;
    
    public void onSelect() {
        
        i++;
        
        Tabpanel item = getSelectedPanel();
        
        Desktop desktop = this.getDesktop();
        
        desktop.setAttribute("time",i);
        
        if(item != null && item.getId().equals("second")) {
            Include inc = (Include)Path.getComponent("/root/secondContent");
            inc.setSrc("secondTab.zul");
        }
        if(item != null && item.getId().equals("third")) {
            Include inc = (Include)Path.getComponent("/root/thirdContent");
            inc.invalidate();
            inc.setSrc("thirdTab.zul");
        }
    }
    
}

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>testing with the load on demand</display-name>
	<listener>
		<description>
		Used to cleanup when a session is destroyed</description>
		<display-name>
		ZK Session Cleaner</display-name>
		<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
	</listener>
	<servlet>
		<description>
		The servlet loads the DSP pages.</description>
		<servlet-name>dspLoader</servlet-name>
		<servlet-class>
		org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
	</servlet>
	<servlet>
		<description>
		ZK loader for ZUML pages</description>
		<servlet-name>zkLoader</servlet-name>
		<servlet-class>
		org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
		<init-param>
			<param-name>update-uri</param-name>
			<param-value>/zkau</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet>
		<description>
		The asynchronous update engine for ZK</description>
		<servlet-name>auEngine</servlet-name>
		<servlet-class>
		org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>dspLoader</servlet-name>
		<url-pattern>*.dsp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.zul</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.zhtml</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>auEngine</servlet-name>
		<url-pattern>/zkau/*</url-pattern>
	</servlet-mapping>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
		<welcome-file>index.zul</welcome-file>
	</welcome-file-list>
</web-app>

link publish delete flag offensive edit

answered 2009-01-19 17:22:53 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

Hi James,

can you check, that there's a file called MyTabbox.class in tomcat/webapps/YourApplication/WEB-INF/classes/com? If not, you'll have to change your deployment to make it work.

Cheers, Maik

link publish delete flag offensive edit

answered 2009-01-19 20:08:14 +0800

james gravatar image james
255 2

there was not.
I've tried a couple of different deployment options, non of which created that file. I created one... not sure what all was supposed to be in it, but i put the same code as MyTabbox.java.
I got this error...
java.lang.ClassFormatError: Incompatible magic value 1885430635 in class file com/MyTabbox

link publish delete flag offensive edit

answered 2009-01-20 01:10:52 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

if you use eclipse
you should use Dynamic Web Project
or you have to copy the class to your classpath
(Default is WEB-INF/classes/ )

link publish delete flag offensive edit

answered 2009-01-20 16:58:36 +0800

james gravatar image james
255 2

Hey... You know, I have been using the "Dynamic Web Project" and it hasn't worked. When I did it again, just to be sure and do as you said, I noticed this little option "Dynamic Web Module version" it defaults to 2.4 I changed it to 2.5 and it works now. I had previously just kept it as the default.
Thanks everyone for your time and help.
It works now

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-01-16 20:57:00 +0800

Seen: 663 times

Last updated: Jan 20 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More