How could I turn on validation during unmarshalling? [moxy 2.6.0]
First intresting thing is that I need to put schema which should be already in DynamicContext. But even with setting schema to unmarshaller again it gives me an error.
I've tried to use this one:
final JAXBUnmarshaller unmarshaller = dynamicJAXBContext.createUnmarshaller();
//unmarshaller.setSchema();
final Schema schema = schemas.get(type);
unmarshaller.setSchema(schema);
unmarshaller.setValidating(true);
And it gives an exception. Looks like part which broke this are some elements which are put there from DynamicContext
Exception Description: An error occurred resolving the XML Schema.
Internal Exception: java.lang.NullPointerException
Exception [EclipseLink-25012] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred resolving the XML Schema.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.XMLMarshalException.errorResolvingXMLSchema(XMLMarshalException.java:186)
at org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference.getURL(XMLSchemaClassPathReference.java:48)
at org.eclipse.persistence.oxm.XMLUnmarshaller.initializeSchemas(XMLUnmarshaller.java:211)
at org.eclipse.persistence.oxm.XMLUnmarshaller.setValidationMode(XMLUnmarshaller.java:155)
at org.eclipse.persistence.jaxb.JAXBUnmarshaller.setValidating(JAXBUnmarshaller.java:756)
The problem here is that the schema was not found. You set null instead of Schema instance.
Btw. method
javax.xml.bind.Unmarshaller#setValidating
is deprecated since JAXB 2.0. Using method
javax.xml.bind.Unmarshaller#setSchema
will do the job.
Related
I am trying to write a code to convert csv to bean using opencsv and xml to bean using jaxb.
I tried using lombok.
The getters are not getting resolved even after lombok has generated them.
Exception with JAXB:
019-05-07 13:06:43.571 ERROR 16964 --- [nio-8080-exec-2] c.r.readerimpl.XMLStatementReaderImpl : JAXBException While reading the statement from XML
Exception with opencsv:
Caused by: java.lang.InstantiationException: com.rabobank.readerrows.Record
Caused by: java.lang.NoSuchMethodException: com.***.readerrows.Record.<init>()
Can someone help me?
I am trying to use "JHipster-UML". The first time i ran it on my xmi file it worked fine. I then modified my modal (using GenMyModal), exported and re-ran "JHipster-UML" on the modified xmi file and then restarted. I then get errors when starting up. Am I missing a step?
Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at com.mycompany.myapp.Application.main(Application.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by:
org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:75)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:378)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:155)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 10 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.core.userdetails.UserDetailsService com.mycompany.myapp.config.SecurityConfiguration.userDetailsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mycompany.myapp.repository.UserRepository com.mycompany.myapp.security.UserDetailsService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#503a431e' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#503a431e': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.ValidationFailedException: Validation Failed:
2 change sets check sum
classpath:config/liquibase/changelog/20151003011413_added_entity_Parent.xml::20151003011413::jhipster is now: 7:57b97f063aff9a9eb02142bd4831626b
classpath:config/liquibase/changelog/20151003011413_added_entity_Child.xml::20151003011413::jhipster is now: 7:a7512c06e21d617c6aeaeba25d6a8051
I suppose you're not using H2 database in dev mode, so it means that database changes are persisted and Liquibase finds that the checksums of your changelogs are different from what has been recorded on previous run and it's right. If you want to overcome this, you must drop your schema and re-start app.
Of course, you don't have these problems when using H2 in dev.
Alternatively, you could refer to answers to this question
type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented it
from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 44 in the jsp file:
/jsp/ShoppingCart/AddBook.jsp The method getValue(String) is undefined
for the
type HttpServletRequest
int int_BookID,int_CategoryID,int_Price,int_Quantity;
String str_Title, str_Author, str_Publisher,str_Edition,str_Description;
int_BookID=(int)(10000*Math.random()+1);
int_CategoryID=Integer.parseInt(request.getValue("cat"));
str_Title=request.getParameter("title");
str_Author=request.getParameter("author");
str_Publisher=request.getParameter("pub");
request.getValue("cat") is the problem here.
I suppose the 'cat' is a parameter.
Instead , use request.getParameter("cat")
PS- I recommend you to read the basics of JSP first try the HeadFirst series.
I am getting the following exception when trying to deploy the :mancenter-3.1.3.war in to my Weblogic 12.
The fullstacktrace is :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'managementCenterContext' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'centralManager' while setting bean property 'centralManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'centralManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hazelcast.webmonitor.service.CentralManager]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'centralManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hazelcast.webmonitor.service.CentralManager]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1007)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hazelcast.webmonitor.service.CentralManager]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;
at com.google.common.cache.LocalCache.<clinit>(LocalCache.java:155)
at com.google.common.cache.LocalCache$LocalManualCache.<init>(LocalCache.java:4750)
at com.google.common.cache.LocalCache$LocalManualCache.<init>(LocalCache.java:4745)
at com.google.common.cache.CacheBuilder.build(CacheBuilder.java:757)
at com.hazelcast.webmonitor.service.CentralManager.<init>(CentralManager.java:63)
Truncated. see log file for complete stacktrace
Any help is highly appreciated.
Thanks.
Check your classpath and see what version of guava is being used by your WAR. The error suggests that the version of guava jar being found at runtime does not match the version that was used at compile time.
Sounds very similar to:
Are Guava-11.0.2.jar conflicting with com.google.common_1.0.0.0_0-6.jar?
Weblogic Guava issue when deploying application
I'm getting this exception: Default constructor cannot handle exception type JAXBException thrown by implicit super constructor. Must define an explicit constructor
JAXBContext.newInstance throws a checked exception. You won't be able to directly set this on a field. You will need to move it inside your constructor and surround it with a try/catch block.