2 Replies Latest reply: Apr 8, 2013 6:55 AM by 1001650 RSS

    javax.xml.bind.JAXBException: Failed to create JAXBContext: null

    1001650
      Hi,

      we have one java application . we are using jboss and tomcat servers for this applications.
      we did some xml implementations in this.
      When we run it in our local environment , it runs perfectly.


      But , when we run it on clustered jboss , it throws error on server "javax.xml.bind.JAXBException: Failed to create JAXBContext: null"

      Please reply , if u know.

      Thanks ,
      Zealous Systems
        • 1. Re: javax.xml.bind.JAXBException: Failed to create JAXBContext: null
          gimbal2
          No information (other than "it doesn't work") = no answers; its already difficult to figure this out for you and you have access to the environment and thus a whole lot more information, now imagine what someone with NO access to your environment can figure out.

          At least post the entire stacktrace that you get, and post information about what is causing this. For example: are you using JAXB yourself? If so - post the code that trips the exception. Is it some other API that is using JAXB under the hood such as JAX-WS?
          • 2. Re: javax.xml.bind.JAXBException: Failed to create JAXBContext: null
            1001650
            01:29:47,203 ERROR [STDERR] javax.xml.bind.JAXBException: Failed to create JAXBContext: null
            01:29:47,203 ERROR [STDERR] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:123)
            01:29:47,204 ERROR [STDERR] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:66)
            01:29:47,204 ERROR [STDERR] at com.rm.janus.attendance.view.server.xmlgenerator.DailyRegisterXMLGenerator.createDailyRegisterWidgetXmlFile(DailyRegist
            enerator.java:63)
            01:29:47,207 ERROR [STDERR] at com.rm.janus.attendance.view.server.businessrules.AttStudentViewBaseBRHelper.generateAttXMLFile(AttStudentViewBaseBRHel
            va:4023)
            01:29:47,208 ERROR [STDERR] at com.rm.janus.attendance.view.server.businessrules.AttStudentViewBaseBRHelper.refreshDailyRegister(AttStudentViewBaseBRH
            java:3252)
            01:29:47,208 ERROR [STDERR] at com.rm.janus.attendance.view.server.businessrules.AttStudentViewBaseBRHelper.initializeDailyRegister(AttStudentViewBase
            er.java:3146)
            01:29:47,208 ERROR [STDERR] at com.rm.janus.attendance.general.server.ejb.service.AttendanceSessionBean.initializeDailyRegister(AttendanceSessionBean.
            724)
            01:29:47,214 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            01:29:47,218 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            01:29:47,218 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            01:29:47,219 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            01:29:47,219 ERROR [STDERR] at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
            01:29:47,220 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
            01:29:47,221 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
            01:29:47,221 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
            01:29:47,222 ERROR [STDERR] at org.jboss.ws.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:64)
            01:29:47,222 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
            01:29:47,222 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
            01:29:47,223 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
            01:29:47,223 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
            01:29:47,223 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
            01:29:47,223 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
            01:29:47,224 ERROR [STDERR] at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:278)
            01:29:47,224 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
            01:29:47,225 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
            01:29:47,226 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:954)
            01:29:47,226 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
            01:29:47,226 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            01:29:47,227 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            01:29:47,227 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
            01:29:47,227 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
            01:29:47,227 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
            01:29:47,228 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
            01:29:47,228 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
            01:29:47,228 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvokerHA.invoke(JRMPInvokerHA.java:177)
            01:29:47,229 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
            01:29:47,229 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            01:29:47,229 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            01:29:47,230 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
            01:29:47,230 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:153)
            01:29:47,230 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
            01:29:47,231 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
            01:29:47,231 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
            01:29:47,231 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
            01:29:47,232 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
            01:29:47,232 ERROR [STDERR] Caused by: javax.xml.bind.JAXBException: Cannot load resource: com/rm/janus/attendance/dayview/server/xmltransferobject/jaxb.p
            ies
            01:29:47,233 ERROR [STDERR] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:97)
            01:29:47,234 ERROR [STDERR] ... 44 more
            01:29:47,236 INFO [AttXMLGenerator] Inside createDailyRegisterWidgetXmlFile()
            01:29:47,236 ERROR [STDERR] javax.xml.bind.JAXBException: Failed to create JAXBContext: null
            01:29:47,237 ERROR [STDERR] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:123)
            01:29:47,238 ERROR [STDERR] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:66)
            01:29:47,238 ERROR [STDERR] at com.rm.janus.attendance.view.server.xmlgenerator.DailyRegisterXMLGenerator.createDailyRegisterWidgetXmlFile(DailyRegist
            enerator.java:63)
            01:29:47,239 ERROR [STDERR] at com.rm.janus.attendance.view.server.businessrules.AttStudentViewBaseBRHelper.generateAttXMLFile(AttStudentViewBaseBRHel
            va:4023)
            01:29:47,239 ERROR [STDERR] at com.rm.janus.attendance.view.server.businessrules.AttStudentViewBaseBRHelper.initializeDailyRegister(AttStudentViewBase
            er.java:3149)
            01:29:47,240 ERROR [STDERR] at com.rm.janus.attendance.general.server.ejb.service.AttendanceSessionBean.initializeDailyRegister(AttendanceSessionBean.
            724)
            01:29:47,240 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            01:29:47,241 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            01:29:47,241 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            01:29:47,241 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            01:29:47,242 ERROR [STDERR] at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
            01:29:47,242 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
            01:29:47,242 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
            01:29:47,243 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
            01:29:47,243 ERROR [STDERR] at org.jboss.ws.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:64)
            01:29:47,244 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
            01:29:47,244 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
            01:29:47,244 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
            01:29:47,245 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
            01:29:47,245 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
            01:29:47,245 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
            01:29:47,246 ERROR [STDERR] at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:278)
            01:29:47,246 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
            01:29:47,247 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
            01:29:47,247 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:954)
            01:29:47,247 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
            01:29:47,248 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            01:29:47,248 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            01:29:47,248 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
            01:29:47,249 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
            01:29:47,249 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
            01:29:47,249 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
            01:29:47,250 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
            01:29:47,250 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvokerHA.invoke(JRMPInvokerHA.java:177)
            01:29:47,251 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
            01:29:47,251 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            01:29:47,251 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            01:29:47,252 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
            01:29:47,252 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:153)
            01:29:47,252 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
            01:29:47,253 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
            01:29:47,253 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
            01:29:47,253 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
            01:29:47,254 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
            01:29:47,254 ERROR [STDERR] Caused by: javax.xml.bind.JAXBException: Cannot load resource: com/rm/janus/attendance/dayview/server/xmltransferobject/jaxb.p
            ies
            01:29:47,257 ERROR [STDERR] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:97)
            01:29:47,257 ERROR [STDERR] ... 43 more


            code is something like this:::

            MessageElement objMessageElement = null;
            // Getting the JAXB instance.

            JAXBContext jc = JAXBContext.newInstance(
            "com.rm.janus.census.school.server.xmltransferobject.nt");
            // Creating the ObjectFactory
            ObjectFactory objFactory = new ObjectFactory();
            // Creating the Root Element - 'Message'
            objMessageElement = objFactory.createMessageElement();

            // Getting the data for Message tag from the passed WTO
            MessageTO objMessageTO = objCensusReturnWTO.getObMessageTO();
            if (objMessageTO == null) {
            return;
            }

            String strReportName = objMessageTO.getName();
            objMessageElement.setName(strReportName);
            // Getting the data for Header Tag from Message TO
            HeaderTO objHeaderTO = objMessageTO.getObHeaderTO();
            // Getting the data for Pupils Tag from Message TO
            PupilsTO objPupilsTO = objMessageTO.getObPupilsTO();
            // Getting the data for School Tag from Message TO
            SchoolTO objSchoolTO = objMessageTO.getObSchoolTO();

            // Creating the Header Structure
            if (objHeaderTO != null) {
            HeaderStructure obHeaderStruct = createHeaderStructure(objFactory, objHeaderTO);
            if(obHeaderStruct != null){
            objMessageElement.setHeader(obHeaderStruct);
            }
            objHeaderTO = null;
            }
            // Creating the School Structure
            if (objSchoolTO != null) {
            objMessageElement.setSchool(createSchoolStructure(objFactory, objSchoolTO));
            objSchoolTO=null;
            }
            // Creating the Pupils Structure
            if (objPupilsTO != null) {
            objMessageElement.setPupils(createPupilsStructure(objFactory, objPupilsTO));
            objPupilsTO=null;
            }

            // Creating the XML file
            try {
            Marshaller m = jc.createMarshaller();
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            // Marshalling the XML
            m.marshal(objMessageElement, fileToSave);
            m=null;
            } catch (JAXBException ex) {
            ex.printStackTrace();
            throw new JanusException("SCH_CEN_XML_001","Creation of XML failed");
            } catch (Exception ex) { //@TODO - remove the general exception block
            ex.printStackTrace();
            throw new JanusException("SCH_CEN_XML_001","Creation of XML failed");
            } finally {
            jc = null;
            objCensusReturnWTO = null;
            objFactory = null;
            objHeaderTO = null;
            objMessageElement = null;
            objPupilsTO = null;
            objSchoolTO = null;
            objMessageTO = null;
            Runtime.getRuntime().gc();