jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Brosius" <dbros...@mebigfatguy.com>
Subject Re: NoClassDefFoundError on OCM Test
Date Tue, 03 Mar 2009 03:19:46 GMT
Do you have a cglib.jar on your classpath?

----- Original Message ----- 
From: "Fernando Cabredo" <fcabredoph@yahoo.com>
To: <users@jackrabbit.apache.org>
Sent: Monday, March 02, 2009 8:50 PM
Subject: NoClassDefFoundError on OCM Test


> Hi,
>
> I would like to get some help that is causing my OCM test.
>
> Here is the error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError: 
> net/sf/cglib/proxy/Callback
>    at 
> org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl.<init>(ObjectContentManagerImpl.java:125)
>    at com.daraga.jackrabbit.Main.main(Main.java:97)
> Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback
>    at java.net.URLClassLoader$1.run(Unknown Source)
>    at java.security.AccessController.doPrivileged(Native Method)
>    at java.net.URLClassLoader.findClass(Unknown Source)
>    at java.lang.ClassLoader.loadClass(Unknown Source)
>    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>    at java.lang.ClassLoader.loadClass(Unknown Source)
>    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>    ... 2 more
>
> And my code are as follows:
>
> import java.net.MalformedURLException;
> import java.util.ArrayList;
> import java.util.Date;
> import java.util.List;
>
> import javax.jcr.LoginException;
> import javax.jcr.Repository;
> import javax.jcr.Session;
> import javax.jcr.SimpleCredentials;
> import javax.servlet.ServletException;
>
> import org.apache.jackrabbit.ocm.exception.RepositoryException;
> import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
> import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
> import org.apache.jackrabbit.ocm.mapper.Mapper;
> import 
> org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
> import com.daraga.jackrabbit.model.Article;
> import com.daraga.jackrabbit.model.ArticlePhotos;
> import com.daraga.jackrabbit.model.Author;
> import com.daraga.jackrabbit.model.Category;
> import com.daraga.jackrabbit.model.Photos;
> import com.daraga.jackrabbit.model.Section;
> import org.apache.jackrabbit.rmi.repository.URLRemoteRepository;
>
>
> public class Main {
>    private static Session session;
>
>    public String loginRepository (String repositoryUrl, String username, 
> String password){
>        String str;
>        System.out.println("<------------JackrabbitService---------->");
>        try {
>            SimpleCredentials cred = new SimpleCredentials(username,
>                     password.toCharArray());
>            Repository repository = new URLRemoteRepository(repositoryUrl);
>            try {
>                session = repository.login(cred, null);
>            } catch (LoginException e) {
>                throw new ServletException(e);
>            } catch (RepositoryException e) {
>                throw new ServletException(e);
>            }
>        } catch (Exception e) {
>            e.toString();
>            // TODO: handle exception
>        }
>        try {
>            String user = session.getUserID();
>            str = "[Status]Login Successful[/Status]";
>        }finally{
>            //TODO on Login of user
>        }
>        return str;
>    }
>    public static void main(String[] args) {
>
>        String repositoryUrl = 
> "http://localhost:8080/jackrabbit-webapp-1.5.2/rmi";
>        String username = "admin";
>        String password = "admin";
>        try {
>            SimpleCredentials cred = new SimpleCredentials(username,
>                     password.toCharArray());
>            Repository repository = new URLRemoteRepository(repositoryUrl);
>            try {
>                session = repository.login(cred, null);
>            } catch (LoginException e) {
>                throw new ServletException(e);
>            } catch (RepositoryException e) {
>                throw new ServletException(e);
>            }
>        } catch (Exception e) {
>            e.toString();
>        }
>        String str;
>        try {
>            String user = session.getUserID();
>            System.out.println("str --->"+user);
>            str = "[Status]Login Successful[/Status]";
>        }finally{
>            //TODO on Login of user
>        }
>
>        List<Class> myclasses = new ArrayList<Class>();
>
>        myclasses.add(Article.class);
>
>        myclasses.add(ArticlePhotos.class);
>        myclasses.add(Author.class);
>        myclasses.add(Category.class);
>        myclasses.add(Photos.class);
>        myclasses.add(Section.class);
>
>
>        Mapper mapper = new AnnotationMapperImpl(myclasses);
>        ObjectContentManager ocm = new ObjectContentManagerImpl(session, 
> mapper);
>
>        Article article = new Article();
>        article.setPath("/articles");
>        article.setTitle("Public Announcement");
>        article.setContent("Urgently Needed");
>        article.setAuthorid(100);
>        article.setSectionid(1);
>        article.setDatecreated(new Date());
>        ocm.insert(article);
>        ocm.save();
>
>        System.out.println("Retrieve a press release from the repository");
>        article = (Article) ocm.getObject("/articles");
>        System.out.println("Article title : " + article.getTitle());
>    }
>
> }
>
> Any help will be much appreciated.
>
> Fernando Cabredo
>
>
> 


Mime
View raw message