Setting StrutsSpringObjectFactory as my current ObjectFactory - struts2

I am working on a project that uses openSymphony 2.1.2 and struts 2.3.8.
However on that code base I am trying to apply a piece code that was written for older versions of openSymphony and struts.
Here is that piece of code:
http://www.lischke-online.de/index.php/java/action-unit-testing-with-struts-2-0-part-2
(As a side note, I need that code in order to be able to simulate running the struts actions from my inherited project, in a system that is based on a different framework.)
I have a problem with the following paragraph:
final StrutsSpringObjectFactory ssf = new StrutsSpringObjectFactory("auto", "true", servletContext);
ObjectFactory.setObjectFactory(ssf);
On the second line, I'm getting the error: The method setObjectFactory(StrutsSpringObjectFactory) is undefined for the type ObjectFactory
However, when I look at the javadoc of ObjectFactory, I do not see an alternative method that would let me set a specific ObjectFactory (e.g. StrutsSpringObjectFactory), as the ObjectFactory that will be used when executing the Actions.
So how do I set such a specific ObjectFactory with the new API?
Updated code:
static {
sessionMap = new HashMap<String, Object>();
// Create fake back end here.
// ...
// ===== Struts setup:
// Create and use a file system resource loader otherwise Tiles will not find
// our configuration file. The default resource loader is able to find struts.xml
// if it is in the classpath, but not tiles.xml.
final FileSystemResourceLoader loader = new FileSystemResourceLoader();
final String[] config = new String[] { "WEB-INF/classes/struts.xml" };
servletContext = new MockServletContext(loader);
final XmlWebApplicationContext appContext = new XmlWebApplicationContext();
// Link the servlet context and the Spring context.
appContext.setServletContext(servletContext);
appContext.setConfigLocations(config);
appContext.refresh();
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
appContext);
servletContext.addInitParameter(BasicTilesContainer.DEFINITIONS_CONFIG, "WEB-INF/tiles.xml");
// Creating the tiles listener statically (not via class loader).
final StrutsTilesListener tilesListener = new StrutsTilesListener();
final ServletContextEvent event = new ServletContextEvent(servletContext);
tilesListener.contextInitialized(event);
// Use spring as the object factory for Struts
//this code not working anymore with struts 2.3.2:
//final StrutsSpringObjectFactory ssf = new StrutsSpringObjectFactory("auto", "true", servletContext);
//ObjectFactory.setObjectFactory(ssf);
//my change: (original note working with newer version of struts)
//StrutsSpringObjectFactory.setObjectFactory(ssf);
//(*) original location.
// Dispatcher is the guy that actually handles all requests. Pass in
// an empty. Map as the parameters but if you want to change stuff like
// what config files to read, you need to specify them here
// (see Dispatcher's source code)
dispatcher = new Dispatcher(servletContext, new HashMap<String, String>());
dispatcher.init();
Dispatcher.setInstance(dispatcher);
//(*) moved to here:
//http://stackoverflow.com/questions/15821643/setting-strutsspringobjectfactory-as-my-current-objectfactory?noredirect=1#comment22519072_15821643
final StrutsSpringObjectFactory ssf = new StrutsSpringObjectFactory("auto", "true", "false", servletContext, "false", dispatcher.getContainer());
}
Stack trace that I get on that code, when calling the test from within a webapp (a deployed war):
08:50:28,471 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-1) #{accountLookupBean.lookupAccounts()}: java.lang.ExceptionInInitial
izerError: javax.faces.FacesException: #{accountLookupBean.lookupAccounts()}: java.lang.ExceptionInInitializerError
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at javax.faces.component.UIData.broadcast(UIData.java:1093) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at javax.faces.component.UIData.broadcast(UIData.java:1093) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at javax.faces.component.UIData.broadcast(UIData.java:1093) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]
Caused by: javax.faces.el.EvaluationException: java.lang.ExceptionInInitializerError
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.
0.Final]
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
... 23 more
Caused by: java.lang.ExceptionInInitializerError
at com.myapp.services.AccountLookupServiceImpl.getRows(AccountLookupServiceImpl.java:38) [classes:]
at com.myapp.beans.AccountLookupBean.lookupAccounts(AccountLookupBean.java:39) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_29]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_29]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_29]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_29]
at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.10.Final.jar:]
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.10.Final.jar:]
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0
.Final]
... 24 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/classes/struts.xml];
nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/classes/struts.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341) [spring-beans-3.2.1.RELEASE.jar:3.2.1.REL
EASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [spring-beans-3.2.1.RELEASE.jar:3.2.1.REL
EASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) [spring-beans-3.2.1.RELEASE
.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) [spring-beans-3.2.1.RELEASE
.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) [spring-beans-3.2.1.RELEASE
.jar:3.2.1.RELEASE]
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) [spring-web-3.2.1.RELEASE.jar:3.2.1.R
ELEASE]
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) [spring-web-3.2.1.RELEASE.jar:3.2.1.RE
LEASE]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) [spring-context-
3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) [spring-context-3.2.1.RELEASE.jar:
3.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at com.myapp.softgems.ActionBaseTestCase.<clinit>(ActionBaseTestCase.java:70) [classes:]
... 34 more
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/classes/struts.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:140) [spring-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328) [spring-beans-3.2.1.RELEASE.jar:3.2.1.REL
EASE]
... 44 more
UPDATE 2:
The reason I want to be able to test an Action, is not simply to be able to right-click on it from the project explorer and than right-click "run as Junit". I actually want to run the test as part of my web application.
This is what I mean: I am trying to call the following code from one of my service classes:
DataTest test = new DataTest("testDataAction");
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.run(test);
Because, in DataTest I try to execute() DataAction. That Action calls some messy db logic and eventually return some data. I need that data for my service. Instead of trying to figure out what the Action does exactly, I wan to simply execute() it and get the data. The way I'm trying to do it is by running a test that will execute() the Action.
My struts.xml is not directly in the project that I am building. Here is my situation: let's call my new project, project A; and the legacy struts project that I depend on, project B.
Project A is being built by other framework (JSF & Spring).
Project B uses struts for the UI. But its Actions were written in such a messy way, that a lot of the DB access logic was written directly within the actions. So if I want to use the logic from project B, and not rewrite it, a temporary solution (which I am trying to accomplish) would be to execute an Action from project B with the corresponding request data.
The way to do it, is by running a test on an Action from B, within a service class from A.
Since project B was packed as a war file, my way to reuse it with Maven in project A, is to define it as an overlay in project A.
The classes and other resources from the classpath of project B are packed into a jar. Then in project A I have a dependency on that jar.
So struts.xml lives in the jar that contains the classes and xml's of project B. In compile time, project A can only see struts.xml within the jar of project A.
Only when I pack project A, war B is unpacked, its content (including struts.xml) is copied into the target folder of project A, and then A + B are packed together as war. (in the final war, struts.xml will be both in the jar B, and in WEB-INF/classes witin the final war.
So in practical terms, if I try to run the test by right-clicking the test and them "run as junit", it should not find struts.xml in some WEB-INF/classes on my classpath - first there's no such thing in my workspace, only in created war. Second I only try to run the test from within a war (as I've shown above). in that time, there is WEB-INF/classes/struts.xml, why could it not be found?

Just create new instance of StrutsSpringObjectFactory but do it after creation of Dispatcher.
final StrutsSpringObjectFactory ssf = new StrutsSpringObjectFactory("auto",
"true", "false", servletContext, "false", dispatcher.getContainer());
BUT take a look at struts2-junit-plugin for testing Struts2 actions. It has StrutsSpringJUnit4TestCase with convenient methods, so you do not need to do all that stuff by yourself.

You need to include the Struts2-Spring-plugin(*.jar)
http://struts.apache.org/release/2.3.x/docs/spring-plugin.html
The Spring Plugin works by overriding the Struts ObjectFactory to
enhance the creation of core framework objects. When an object is to
be created, it uses the class attribute in the Struts configuration to
correspond to the id attribute in the Spring configuration. If not
found, the class will try to be created as usual, then be autowired by
Spring. In the case of Actions, Spring 2's bean scope feature can be
used to scope an Action instance to the session, application, or a
custom scope, providing advanced customization above the default
per-request scoping.

Related

Thymeleaf and Micronaut Views error when using Layout dialect

We are running Micronaut with Thymeleaf views and the Layout dialect (we add it manually by overriding Micronaut's ThymeleafFactory). Below are the dependencies (Micronaut version is 3.2.7):
implementation 'io.micronaut.views:micronaut-views-core:3.1.2'
implementation 'io.micronaut.views:micronaut-views-thymeleaf:3.1.2'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.0.0'
The problematic code is this:
<html layout:decorate="~{/layout-top}">
This seems to work fine when running with ./gradlew run, but crashes when running from a fat (shadow) jar using java -jar .... This would point to classpath issues, but we couldn't figure out what would those be.
Below the error message when running the shadow jar:
Caused by: groovy.lang.MissingMethodException: No signature of method: io.micronaut.views.thymeleaf.WebEngineContext.getOrCreate() is applicable for argument types: (String, nz.net.ultraq.thymeleaf.layoutdialect.context.extensions.IContextExtensions$_getPrefixForDialect_closure1) values: [DialectPrefix::org.thymeleaf.standard.StandardDialect, nz.net.ultraq.thymeleaf.layoutdialect.context.extensions.IContextExtensions$_getPrefixForDialect_closure1#26b0c4d0]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
at nz.net.ultraq.thymeleaf.layoutdialect.context.extensions.IContextExtensions.getPrefixForDialect(IContextExtensions.groovy:54)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)
at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:54)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:247)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
at nz.net.ultraq.thymeleaf.layoutdialect.models.extensions.IProcessableElementTagExtensions.equalsIgnoreXmlnsAndWith(IProcessableElementTagExtensions.groovy:60)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)
at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:54)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:247)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
at nz.net.ultraq.thymeleaf.layoutdialect.decorators.DecorateProcessor.doProcess(DecorateProcessor.groovy:103)
at org.thymeleaf.processor.element.AbstractAttributeModelProcessor.doProcess(AbstractAttributeModelProcessor.java:77)
We debugged this and isolated the failing code in nz.net.ultraq.thymeleaf.layoutdialect.context.extensions.IContextExtensions:
static String getPrefixForDialect(IContext self, Class<IProcessorDialect> dialectClass) {
return self.getOrCreate(DIALECT_PREFIX_PREFIX + dialectClass.name) { ->
def dialectConfiguration = self.configuration.dialectConfigurations.find { dialectConfig ->
return dialectClass.isInstance(dialectConfig.dialect)
}
return dialectConfiguration?.prefixSpecified ?
dialectConfiguration?.prefix :
dialectConfiguration?.dialect?.prefix
}
}
It seems that the IContext argument is not what's supposed to be, but we couldn't really find the root cause for this. Nor why this is behaving differently with the two different methods of running the same code.
Upon further investigation, we discovered that this is related to this bug in the shadow jar plugin: https://github.com/johnrengelman/shadow/issues/490
The library thymeleaf-layout-dialect is using a nz.net.ultraq.extensions:groovy-extensions:1.1.0
which, in turn, registers some Groovy extensions through META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
The shadow jar plugin doesn't handle these correctly (it only handles META-INF/groovy/... paths).
As per ticket comments here https://github.com/johnrengelman/shadow/issues/490 , there is a workaround, but it's deeply unpleasant.

javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory

I'm trying to get a connection to jira's default database (HSQL) using the following java code:
InitialContext initalContext = new InitialContext();
Context context = (Context) initalContext.lookup("java:comp/env");
dataSource = (DataSource) context.lookup("jdbc/JiraDS");
I have added catalina.jar, naming-factory.jar, naming-java.jar and tomcat-juli.jar as per the answer given in stack overflow.
However, I'm still getting an error:
javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at in.componence.jira.plugin.util.JiraDataSourceUtil.getConnectionToJiraDB(JiraDataSourceUtil.java:40)
Please help me out.
The Classloader does not see org.apache.naming.java.javaURLContextFactory. Which jar-file contains the binary of the class? It has to be on the classpath. May be there are multiple classloaders present abd the moaning one is not the one in your focus?

Unable to import neo4j database with blueprints

i'm trying to open a neo4j database by using blueprints implementation, but i got the following exceptions:
Neo4jGraph graph = new Neo4jGraph("/Users/pipe/Dev/neo4j-community-2.1.0-M01/data/graph.db");
this cause
Caused by: javax.faces.el.EvaluationException: java.lang.RuntimeException: Bad value '-192M' for setting 'neostore.propertystore.db.strings.mapped_memory': value does not match expression:\d+[kmgKMG]?
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)
... 32 more
Caused by: java.lang.RuntimeException: Bad value '-192M' for setting 'neostore.propertystore.db.strings.mapped_memory': value does not match expression:\d+[kmgKMG]?
at com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph.<init>(Neo4jGraph.java:165)
at com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph.<init>(Neo4jGraph.java:135)
at org.pipe.java.web.netnografica.persistenza.graphdb.DAONodo.toGraphml(DAONodo.java:204)
at org.pipe.java.web.netnografica.controllo.ControlloGenerale.esportaGraphml(ControlloGenerale.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 33 more
Caused by: java.lang.IllegalArgumentException: Bad value '-192M' for setting 'neostore.propertystore.db.strings.mapped_memory': value does not match expression:\d+[kmgKMG]?
at org.neo4j.helpers.Settings$DefaultSetting.apply(Settings.java:782)
at org.neo4j.helpers.Settings$DefaultSetting.apply(Settings.java:702)
at org.neo4j.graphdb.factory.GraphDatabaseSetting$SettingWrapper.apply(GraphDatabaseSetting.java:215)
at org.neo4j.graphdb.factory.GraphDatabaseSetting$SettingWrapper.apply(GraphDatabaseSetting.java:189)
at org.neo4j.kernel.configuration.ConfigurationValidator.validate(ConfigurationValidator.java:50)
at org.neo4j.kernel.configuration.Config.applyChanges(Config.java:121)
at org.neo4j.kernel.InternalAbstractGraphDatabase.create(InternalAbstractGraphDatabase.java:339)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:253)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:81)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:63)
at com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph.<init>(Neo4jGraph.java:155)
... 44 more
there seems to be a need to provide a properties file. Is correct?
*Edited to answer to Michael Hunger:
Well .. I changed the version of blueprints, now is 2.5.0-SNAPSHOT, but nothing changed. So i provided the configs using the map ask asked by the constructor
Map<String, String> configurazione = new HashMap<String, String>();
configurazione.put("neostore.propertystore.db.strings.mapped_memory", "250M");
configurazione.put("neostore.propertystore.db.arrays.mapped_memory", "100M");
configurazione.put("neostore.relationshipstore.db.mapped_memory", "3845M");
configurazione.put("neostore.nodestore.db.mapped_memory", "350M");
configurazione.put("neostore.propertystore.db.mapped_memory", "350M");
configurazione.put("neostore.nodestore.db.mapped_memory", "769M");
Neo4j2Graph grafo = new Neo4j2Graph("/Users/pipe/Dev/neo4j-community-2.1.0-M01/data/graph.db", configurazione);
Now the exception is changed, and i really don't know what is wrong.. I linked in paste bin to report the complete stack.
http://pastebin.com/XpipSysp
at last a NoSuchMethodError is thrown. What am I missing?
Thanks a lot.
Which blueprints version are you using?
Blueprints 2.5-SNAPSHOT is compatible with Neo4j 2.0.0.
Please note there is a separate module for Neo4j 2.0 called blueprints-neo4j2
And the classes are called Neo4j2Graph Neo4j2Vertex etc.
You should also be able to provide config to the Neo4j2Graph.

Grails UrlMappingsTests

I am trying to create a UrlMappingsTest and am getting the following error:
java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:123)
at org.springframework.web.context.request.RequestContextHolder$currentRequestAttributes.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
at grails.test.GrailsUrlMappingsTestCase.setUp(GrailsUrlMappingsTestCase.groovy:82)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
My TestCase (located in test/integration) looks as follows:
class UrlMappingsTests extends grails.test.GrailsUrlMappingsTestCase {
void testSomething() {
}
}
The test is failing in the setup. I'm using grails 1.2.1. Has anyone seen this error before?
I believe this is the error you get when you run a GrailsUrlMappingTestCase as a unit test. I know you said that it is in the test/integration folder, but is there any way you have the same class in the unit test folder as well. Or that you copied it from one folder to the other and your project didn't get cleaned properly?

How can I check the validity of a wsdl because i got IllegalAnnotationsException?

I have generated a java package with the wsdl2java CXF command.
Now i want to deploy the wsdl to the tomcat server but I got these errors in logs when i start the server
I use opebEjb.
It looks like the wsdl is not valid.
How can i check this?
Log:
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:268)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:202)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:397)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1412)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1373)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
... 30 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:274)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:371)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:525)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:422)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:190)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:164)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:100)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:117)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:168)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:339)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:252)
... 39 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 48 counts of IllegalAnnotationExceptions
There's no ObjectFactory with an #XmlElementDecl for the element {urn:hl7-org:v3}assignedDevice.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement com.santeos.dmp.iheprofiles.hl7.MFMIMT700701UV01AuthorOrPerformer.assignedDevice
at com.santeos.dmp.iheprofiles.hl7.MFMIMT700701UV01AuthorOrPerformer
at protected java.util.List com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MFMIMT700701UV01ControlActProcess.authorOrPerformer
at com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MFMIMT700701UV01ControlActProcess
at protected com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MFMIMT700701UV01ControlActProcess com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MCCIMT000100UV01Message.controlActProcess
at com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MCCIMT000100UV01Message
There's no ObjectFactory with an #XmlElementDecl for the element {urn:hl7-org:v3}assignedPerson.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement com.santeos.dmp.iheprofiles.hl7.MFMIMT700701UV01AuthorOrPerformer.assignedPerson
at com.santeos.dmp.iheprofiles.hl7.MFMIMT700701UV01AuthorOrPerformer
at protected java.util.List com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MFMIMT700701UV01ControlActProcess.authorOrPerformer
at com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MFMIMT700701UV01ControlActProcess
at protected com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MFMIMT700701UV01ControlActProcess com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MCCIMT000100UV01Message.controlActProcess
at com.santeos.dmp.iheprofiles.hl7.PRPAIN201304UV02MCCIMT000100UV01Message
As Julien told in a comment above, this issue can be resolved by changing the package name for each wsdl if you are using more than one wsdl. In my case, I had two wsdl's, one downloaded in my work-space along with all the required xsd's and second used using a URL. Both of them pointing to same server. The reason for downloading the first wsdl was two name collision in object factory. Yes, the external bindings didn't worked, simply because the wsdl was total mess.
So, when I was trying to generate sources using wsdltojava, it was failing with "There's no ObjectFactory with an #XmlElementDecl...". I followed Julien's comments and the issue got resolved. I am not sure if this is the best and cleaner solution, but it worked.
What flags are you passing to wsdl2java?
Can you check the generated code for ObjectFactory classes? Check those to see if any methods are annotated with #XmlElementDecl.

Resources