I have a Spring configuration file spring-idol.xml with the following namespace declaration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
....
</beans>
I want to add the namespace declaration for AOP
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
...
</beans>
Is there a way to do it using Spring IDE? Right now, the only way I can think of is by making a new spring configuration file with the aop namespace declaration and then copy and pasting the declaration from there to the configuration file where my beans are.
Open with -> Spring Config Editor provides you with a tabbed view. One of the tabs is the namespaces tab, where you can add additional namespaces. There you can choose versioned or non-versioned schema files for aop, context, util, batch etc
btw. if you want to add non-spring namespaces (e.g. for apache cxf) use Open with -> XML Editor and do edit namespaces on the root element
Related
I have an issue similar to this problem with items missing from the integration graph. In my case I am using Spring Tool Suite (STS) (Version: 3.9.4, Build Id: 201804120850, Platform: Eclipse Oxygen.1a (4.7.1a) with Spring Integration 4.3.15.
I am using a file splitter. It is working correctly, but does not appear on the integration graph.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xmlns:int-xml="http://www.springframework.org/schema/integration/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="
http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-4.3.xsd
http://www.springframework.org/schema/tool classpath:org/springframework/beans/factory/xml/spring-tool-4.3.xsd
http://www.springframework.org/schema/context classpath:org/springframework/context/config/spring-context-4.3.xsd
http://www.springframework.org/schema/integration classpath:org/springframework/integration/config/spring-integration-4.3.xsd
http://www.springframework.org/schema/integration/stream classpath:org/springframework/integration/stream/config/spring-integration-stream-4.3.xsd
http://www.springframework.org/schema/integration/file classpath:org/springframework/integration/file/config/spring-integration-file-4.3.xsd
http://www.springframework.org/schema/integration/xml classpath:org/springframework/integration/xml/config/spring-integration-xml-4.3.xsd
http://www.springframework.org/schema/integration/mail classpath:org/springframework/integration/mail/config/spring-integration-mail-4.3.xsd">
<int-file:splitter id="15bfileSplitter"
input-channel="PVDR15bChannel"
output-channel="PVDR15bLineChannel" />
This is a bug. Feel free to raise it here: https://github.com/spring-projects/spring-ide/issues
I am getting following error in my springconf.xml file
Multiple annotations found at this line:
- Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-4.0.xsd). For
more information, right click on the message in the Problems View and select "Show Details..."
- Referenced file contains errors (http://www.springframework.org/schema/context/spring-context-4.0.xsd).
For more information, right click on the message in the Problems View and select "Show Details..."
- Referenced file contains errors (http://www.springframework.org/schema/tool/spring-tool-4.0.xsd). For
more information, right click on the message in the Problems View and select "Show Details..."
My SpringConf.xml file looks like this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<mongo:mongo host="com.rg.test" port="10075" />
<mongo:db-factory dbname="young-sierra" />
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>
If I remove
<mongo:mongo host="com.rg.test" port="10075" />
<mongo:db-factory dbname="young-sierra" />
It works fine.
My all jar files in lib folder have following details. I am not sure if I am using correct version of mongo jars. Please help me if any body have idea
commons-logging-1.1.1.jar
jstl-1.2.jar
mongo-java-driver-3.0.2.jar
spring-aop-4.0.0.RELEASE.jar
spring-aspects-4.0.0.RELEASE.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE.jar
spring-data-commons-core-1.0.0.RELEASE(1).jar
spring-data-mongodb-1.0.0.RELEASE.jar
spring-expression-4.0.0.RELEASE.jar
spring-framework-bom-4.0.0.RELEASE.jar
spring-web-4.0.0.RELEASE.jar
spring-webmvc-4.0.0.RELEASE.jar
Check the version of spring that the mongodb xsi:schemaLocation is referring to.
**config file 1 schema defination**
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
If the other configuration xmls specify a different spring version then you will have to update this one. Make sure that all the beans use the same schema spring version across your project. For example one bean cant have the following
**config file 2 Schema defination**
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
living alongside with the defination 1. They both need to have the same schema properties. Hope this is clear.
I created an OSGI config JCR node in XML within my Adobe CQ project under /apps/myproject/config/org.apache.sling.commons.log.LogManager.factory.config-MYPROJECT.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root
xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.level="Trace"
org.apache.sling.commons.log.file="logs/myproject.log"
org.apache.sling.commons.log.file.number="5"
org.apache.sling.commons.log.file.size="5MB"
org.apache.sling.commons.log.pattern="\{0,date,HH:mm:ss.SSS} *{4}* {3} {5}"
org.apache.sling.commons.log.names="[com.mycompany.myproject]" />
Problem is that when it gets imported into the JCR, it is showing up as an nt:file instead of what it should be according to its jcr:primaryType so that it look like this in CRXDE
when it should look like this
So my XML markup starts EXACTLY as follows:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root
xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
...
What I had done originally was to create a new xml file and put in my config. There are 2 other ways I know to create nodes
By doing it in CRXDE and then using vault to export
By doing it in Eclipse using the AEM developer tools (Eclipse plugin for Apache Sling)
In the case of a vault export, the XML starts like this:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" ...
and in the case of the plugin, it starts like this
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root
xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
...
but wait, you can't see it here, the plugin actually adds a friggin blank space right after jcr:root.
So whatever XML parser is acting on these XML files to create nodes in the JRC, it behaves oddly if there is no space right after the root node name. I'm on Windows, using Maven 3.2.3, using version 0.0.20 of content-package-maven-plugin, and AEM 5.6.1.
Please check your filter definition of the content-package-maven-plugin. If your filter root is set to
<filter>
<root>
/apps/myproject/config/org.apache.sling.commons.log.LogManager.factory.config-MYPROJECT.xml
</root>
</filter>
instead of
<filter>
<root>
/apps/myproject/config/org.apache.sling.commons.log.LogManager.factory.config-MYPROJECT
</root>
</filter>
then it will likely just put the file into your repository instead of creating the configuration node.
The latter one without .xml file extension is correct.
You need to add jcr:mixinTypes="[]" type as a property to your logger. So Your configuration will be like :
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:mixinTypes="[]"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.level="Trace"
org.apache.sling.commons.log.file="logs/myproject.log"
org.apache.sling.commons.log.file.number="5"
org.apache.sling.commons.log.file.size="5MB"
org.apache.sling.commons.log.pattern="\{0,date,HH:mm:ss.SSS} *{4}* {3} {5}"
org.apache.sling.commons.log.names="[com.mycompany.myproject]" />
Hope this will help.
I am in the process of converting an already exisiting Java Web application into a RESTful web application using Spring MVC and Groovy.
One of the main features I wanted to achieve was HOT DEPLOYMENT.
I chose groovy because I did not want to make changes to the already implemented Business logic(handlers) and also if I had to ever make changes to the groovy code after deployment, I could easily do that without restarting the server(ie. at runtime).
This can be done because Spring supports Dynamic reloading of groovy scripts(beans). It reloads classes of dynamic languages if they are changed.
I am using Spring annotations to map request URL's to controller methods and the application is deployed in tomcat 6.0.35.
This is the web.xml file
//web.xml
<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<!-- Spring Dispatcher -->
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<!-- Loads application context files in addition to ${contextConfigLocation} -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Set session timeout to 30 minutes -->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
This groovy file is the controller to which the DispatcherServlet maps the request.
// UserController.groovy
#Controller
class UserController
{
// This is the method to which the HTTP request is submitted to based on the mapping of the
// action field of the form ie. /service/user/login/auth.json
#RequestMapping(value="/user/login/auth.{extension:[a-zA-Z]+}", method=RequestMethod.POST)
#ResponseBody
public String authenticate(
#PathVariable String extension,
#RequestParam(value="username", required=true) String username,
#RequestParam(value="password", required=true) String password)
{
// UserResource makes the backend calls, authenticates a user and returns the result.
def user = new UserResource()
def result = user.login(name:username, userPassword:password)
// Output the result of the query. Method makeView makes a JSON response of the result
// and sends to the client(browser)
def builder = makeView(extension)
{
it.login(action:result.action, message:result.message)
}
}
}
The Spring configuration file is as follows where I have used the "lang:groovy" tag which supports dynamic languages. I have also mentioned the refresh time to be 5 seconds, so that any changes made to those groovy files at runtime can be seen every 1 second and the classes are reloaded.
//applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">
<context:annotation-config/>
<context:component-scan base-package="app.controller,app.resource" />
<lang:groovy id="user" script-source="classpath:controller/UserController.groovy" refresh-check-delay="1000"></lang:groovy>
<!-- To enable #RequestMapping process on type level and method level -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<!-- Resolves view names to template resources within the directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".html"/>
</bean>
</beans>
I have configured my Buildpath and groovy compiler accordingly, so that all the groovy scripts directly get copied to the target folder instead of getting compiled to class files.
THE MAIN PROBLEM
When I deploy this project in a tomcat server, it loads all the Spring beans required including the ScriptProcessor. Now, when I go to my browser, load the form, and try to submit the authentication form, I get the following error in Tomcat log:
15:20:09 WARN - No mapping found for HTTP request with URI [/service/user/login/auth.json] in DispatcherServlet with name 'rest'
I have also made changes in $TOMCAT_DIR/conf/context.xml to antilock resources and JARS
<Context antiResourceLocking="true" antiJARLocking="true" reloadable="true" privileged="true">
.
.
.</Context>
However, if I configure my project to compile those groovy scripts into bytecode classes, comment out the "lang:groovy" tag in applicationContext.xml, and then restart the server, the groovy scripts get compiled into class files and the request is serviced perfectly. Authentication takes place.
Also, if I configure the dynamic beans in my applicationContet.xml using the following two lines instead of the tag, my beans DO get created dynamically at runtime and the URLs do get mapped to the respective controller methods because of the annotations.
<bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor" />
<bean id ="User" class="org.springframework.scripting.groovy.GroovyScriptFactory">
<constructor-arg value="classpath:controller/UserController.groovy" />
</bean>
But I do not know how to create the bean refreshing functionality with this style. So I guess there is an issue with the way the tag processes the groovy scripts.
I would really appreciate some help on this. I have searched all over the internet and read an infinite number of tutorials, and followed the exact procedure mentioned there. But I cant find out whats going wrong.
Please help me solve this problem.
Thank you.
Try creating the controller with Java/Groovy that is compiled and let it get injected the Groovy 'script' as a dependency to do the actual work. I seem to remember doing this before and it might be the annotations or the way Spring loads controllers that makes the 'script' not work for you properly.
I have a bit of a problem.
I have created a workflow with the Activiti plugin in Eclipse.
I have a model, context file and the bpmn20.xml file.
Everything is deployed in shared/alfresco/extension but:
If I deploy the workflow deleting the entire following tag in the bpmn20.xml file
<bpmndi:BPMNDiagram id="BPMNDiagram_activitiCustomWorkflow">
(so basically without the workflow diagram), everything works fine but I can't see the workflow diagram in the Workflow details page in Alfresco Share .
If I leave that tag (so what Eclipse created in the beginning with the Activiti project),
Alfresco is not starting. (Connection rejected in browser)
Log is not telling me nothing, and Tomcat cannot be stopped normally (I have to delete the catalina.pid and the tomcat temp folder manually).
My bpmn20.xml file header is:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://activiti.org/bpmn20">
Am I missing something? Or maybe Eclipse doesn't create the correct bpmn file?
Ah, Alfresco 4.0.d and Ubuntu server 10.04 LTS x64
I am using Activiti engine, and the jBPM engine is turned off.
Thanks in advance.
You might need to turn up the logging in webapps/alfresco/WEB-INF/classes/log4j.properties.
log4j.logger.org.alfresco.repo.workflow=debug
I've also got that set in webapps/share/WEB-INF/classes/log4j.properties
my Eclipse (activity designer) generates header like this
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Onlio">
<process id="OnlioWFAdhocMultiNonEsc" name="WF name/description" isExecutable="true">
But I've had also a problem with that, so I'm using this (and this works for me :) ), so you can try it ..
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://alfresco.org">
<process id="WFID" name="WF name/description" isExecutable="true">
(there's different in targetNameSpace only)
So, good luck :)
Btw for deploy you will need a context file or workflow console :) (there should be also way how to deploy through data dictionary- I'm not sure how :) )
OT btw2 - for logging I'm setting these 2 params:
(in ..\tomcat\webapps\alfresco\WEB-INF\classes\log4j.properties)
log4j.logger.org.alfresco.repo.jscript=debug
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug