BeanIO ClassNotFoundException when loading typeHandler from jar file

727 views
Skip to first unread message

smg26

unread,
Sep 11, 2013, 10:29:29 AM9/11/13
to bea...@googlegroups.com

Hi All,

Posted this issue on StackOverflow but no luck so hoping I'll get some responses here.

We are using BeanIO to read an XML file and I am able to load the mapping file fine and everything runs great when we test it in Eclipse. However once everything is packaged in a jar file and we try to run it we get class not found exceptions. The ClassNotFoundExceptions occurs on the custom type handlers we have defined. The ClassNotFoundException is as shown below

Caused by: java.lang.ClassNotFoundException: com.findata.typehandlers.LanguageTypeHandler

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

at org.beanio.internal.util.BeanUtil.createBean(BeanUtil.java:83) ... 20 more

The kicker is that the application runs fine in Eclipse since it can find LanguageTypeHandler.class in the class path. This is our first BeanIO project so I'm not sure if we have it configured correctly. In the mapping file we simply specify that class LanguageTypeHandler as below. It seems to be configured correctly since again everything works in Eclipse but not as a stand alone jar.

BeanIO's BeanUtil class is what initiates the classloader as once can see in line 80 ( We are using BeanIO Release 2.1.0.M1)

    Class<?> clazz = null;
    try {
        // load the class
        clazz = classLoader.loadClass(className);
    }
    catch (ClassNotFoundException e) {
        throw new BeanIOConfigurationException(
            "Class not found '" + className + "'", e);
    }

Any help would greatly be appreciated.


Kevin

unread,
Sep 11, 2013, 11:04:31 PM9/11/13
to bea...@googlegroups.com
Hello,

What environment are you running BeanIO in- standalone, a servlet container, OSGi, etc?

Thanks,
Kevin

smg26

unread,
Sep 13, 2013, 8:21:52 AM9/13/13
to bea...@googlegroups.com
It work fine in Eclipse.  However for production we are simply deploying it in a standalone environment and we start the application from a jar file so no servers etc.

Kevin

unread,
Sep 13, 2013, 5:10:14 PM9/13/13
to bea...@googlegroups.com
Its unlikely to be a BeanIO issue then.  You should make sure all your classes and their dependencies can be found on the classpath.

Although unlikely the issue in this case, you can pass a classloader when creating a stream factory using StreamFactory.newInstance(classloader).  So you could try using Class.forName on your type handler and use the classloader that instantiates that class to pass to StreamFactory.  But I suspect the issue is elsewhere.

Thanks,
Kevin

Kaviyarasan Banniappan

unread,
Jun 9, 2016, 4:53:27 AM6/9/16
to beanio-users
Hi Kevin,

Bean IO is running fine in Eclipse standalone project .When we run in Webshphere application server , we are getting the below error.

Invalid Mapping file:

Failed to read the schema file mapping.xsd

let me know what could be the issue. and how to resolve it.

Kavi
Reply all
Reply to author
Forward
0 new messages