ClassNotFoundException:wildfly-9.0.2.Final中的javax.xml.datatype.DatatypeFactory

时间:2016-05-20 05:27:45

标签: java ant jboss java-8 wildfly

Enviornment - AS@wildfly-9.0.2.Final, 
BuildingTool@ant,
JDK@jdk1.8.0_66

从我的java代码访问以下类,这导致错误。

javax.xml.datatype.DatatypeFactory

Java claas已配置为模块

jaroneapi'==>module add --name=jaroneapi --resources=~/modules/jaroneapi.jar

package api.jarone.com.pojo;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.datatype.DatatypeFactory;
public class TestJarOneDetails {
 public XMLGregorianCalendar convertDatetoXMLGregorian(String inputDate)
  {
    XMLGregorianCalendar date2 = null;
    try {
          System.out.println("[TestJarOne][convertDatetoXMLGregorian] This class is present in " +
                "jaroneapi.jar which has been configured as a module 'module add --name=jaroneapi --resources=~/modules/jaroneapi.jar' ");
          SimpleDateFormat fmt = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
          Date date = fmt.parse(inputDate);
          GregorianCalendar c = new GregorianCalendar();
          c.setTime(date);
          date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
        } catch (Exception e) {
        e.printStackTrace();
    }
    return date2;
 }  
   }

在访问以上' TestJarOneDetails'时发生以下错误类。

    10:43:13,337 ERROR [org.jboss.as.ejb3.invocation] (default task-1) WFLYEJB0034: EJB Invocation failed on component ClientTestHelperBean for method public abstract java.lang.String client.test.ejb.session.ClientTestHelperLocal.getValueByParamName(int,java.lang.String,java.lang.String) throws java.lang.Exception: javax.ejb.EJBException: WFLYEJB0442: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:184)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
Caused by: java.lang.NoClassDefFoundError: javax/xml/datatype/DatatypeFactory
at api.jarone.com.pojo.TestJarOneDetails.convertDatetoXMLGregorian(TestJarOneDetails.java:21)
at client.test.ejb.session.ClientTestHelperBean.getValueByParamName(ClientTestHelperBean.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Caused by: java.lang.ClassNotFoundException: javax.xml.datatype.DatatypeFactory from [Module "jaroneapi:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /home/cmsim/manish/wildfly-9.0.2.Final/modules,/home/cmsim/manish/wildfly-9.0.2.Final/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
10:43:13,341 ERROR [stderr] (default task-1) javax.ejb.EJBException: WFLYEJB0442: Unexpected Error
10:43:13,341 ERROR [stderr] (default task-1)    at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:184)
10:43:13,341 ERROR [stderr] (default task-1)    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
10:43:13,341 ERROR [stderr] (default task-1)    at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327)
10:43:13,342 ERROR [stderr] (default task-1)    at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
10:43:13,361 ERROR [stderr] (default task-1) Caused by: java.lang.ClassNotFoundException: javax.xml.datatype.DatatypeFactory from [Module "jaroneapi:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /home/cmsim/manish/wildfly-9.0.2.Final/modules,/home/cmsim/manish/wildfly-9.0.2.Final/modules/system/layers/base))]
10:43:13,361 ERROR [stderr] (default task-1)    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
10:43:13,361 ERROR [stderr] (default task-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
10:43:13,361 ERROR [stderr] (default task-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
10:43:13,361 ERROR [stderr] (default task-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)

我想我必须配置模块' jaroneapi'有一些依赖关系,但是依赖关系是什么' javax.xml.datatype.DatatypeFactory'存在于/jdk1.8.0_66/jre/lib/rt.jar。

1 个答案:

答案 0 :(得分:1)

您需要在模块中的javax.api模块上添加依赖项。对于命令,您只需添加--dependencies=javax.api

module add --name=jaroneapi --resources=~/modules/jaroneapi.jar --dependencies=javax.api

或者您可以编辑module.xml并手动添加依赖项。

<module xmlns="urn:jboss:module:1.3" name="jaroneapi">

    <resources>
        <resource-root path="jaroneapi.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>