Spring + ehcache + bigmemory go integration - spring

I am integrating spring3.2 + ehcache + bigmemory go.
Firstly, i do not undertand what is the term "Save the BigMemory Go license-key file to the BigMemory Go home directory." What would be my BigMemory Go home directory in my java web application deployed on glassfish.
Request Help.
Secondly, i get this error:
nested exception is net.sf.ehcache.CacheException: Cannot instantiate enterprise features manager
Following is are my files;
<bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="/WEB-INF/ehcache.xml" />
<property name="shared" value="true" />
</bean>
Code:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" name="myBigMemoryGoConfig">
<diskStore path="C:/bigmemorygo"/>
<cache name="CACHE_GEN" maxBytesLocalHeap="124M" maxBytesLocalOffHeap="1G">
<persistence strategy="localRestartable"/>
</cache>
<cache name="CACHE_CMP" maxBytesLocalHeap="124M" maxBytesLocalOffHeap="1G">
<persistence strategy="localRestartable"/>
</cache>
</ehcache>
Help appreciated.
Thanks,
Godwin

For the BigMemory license, it just needs to be in your application classpath...2 ways to do this:
Copy the license file in your application's "WEB-INF/classes" folder (if using maven to build, that'd be in the /src/main/resources folder...)
Or, if you don't want to copy the license file in your application, add the JVM param "-Dcom.tc.productkey.path=" to your app server startup script (or JAVA_OPTS for example)
For the exception, might be related to the license...Please show us the exception stack if you can.
Hope that helps.

Related

How can I enhance classes for openJPA with gradle

I am stuck setting up a simple test program with
- eclipse
- gradle (Eclipse Buildship plugin)
- openjpa
When I try to run my application I get this error, when I call the entityManager.persist(...) method:
Exception in thread "main" org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance "test.jpa.Person#27c6e487" to PersistenceCapable failed. Ensure that it has been enhanced.
FailedObject: test.jpa.Person#27c6e487
The program is simple, it just has one entity (Person.java).
My persistence.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="ptest"
transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/ptest" />
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionUserName" value="..." />
<property name="openjpa.ConnectionPassword" value="..." />
<property name="openjpa.RuntimeUnenhancedClasses" value="unsupported" />
<property name="openjpa.DynamicEnhancementAgent" value="false" />
<property name="openjpa.Log" value="SQL=ERROR" />
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.ConnectionFactoryProperties"
value="PrettyPrint=true, PrettyPrintLineLength=72, PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=60000" />
</properties>
</persistence-unit>
</persistence>
I have used RuntimeUnenhancedClasses=unsupported and DynamicEnhancementAgent=false, for it was recommended by apache. But I have tried with "supported" and "true" and I still get the same error (for openjpa version 2.1.0 - for higher versions I get a LinageError with "supported/true").
I have tried different versions of jpa, currently using 2.4.2.
I have goodled for gradle scripts to enhance my class, I tried
'at.schmutterer.oss.gradle:gradle-openjpa:0.2.0'
'neva.openjpa'
and some more, but I just cannot enhance the class.
Of course I have goodled for quite some time. I am thankful for any idea I can follow...
Thanks in advance!
Just in case someone else has the same struggle. I have found a solution to this problem:
TomEE ships with JPA and everything that is needed. The eclipse "gradle buildship" plugin can be used to compile code. So the combination of the following components works perfectly fine for me:
apache-tomee-plus-7.0.2
tomcat v8.5 server (pointing to the apache-tommee installation)
Dynamic Web Project (using Dynamic Web Module 3.1)
Java Runtime Environment v1.8
The gradle script reduces simply to this:
apply plugin: 'war'
repositories {
mavenCentral()
}
dependencies {
providedCompile "javax:javaee-api:7.0"
}
I suppose it also works with TomEE 1.7.x and javaee-api:6.0, but I have not tried it.

How to configure Spring facet in IntelliJ IDEA

I'm new to Intellij 14.0 . I was using Netbeans, but my colleagues told me to shift to intellij and so I did.
I need to run the same project that I ran on netbeans in Intellij. The project that I'm working on is made of grails and spring. When I tried to run the project using Intellij this is what I get.
Spring Configuration Check
Unmapped Spring configuration files found.
Please configure/setup Spring facet for modules:
......... (1 file)
And this is the file.
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
<description>Grails application factory bean</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="grailsResourceLoader" ref="grailsResourceLoader" />
</bean>
<bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
<description>A bean that manages Grails plugins</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="application" ref="grailsApplication" />
</bean>
<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
<constructor-arg>
<ref bean="grailsApplication" />
</constructor-arg>
<property name="pluginManager" ref="pluginManager" />
</bean>
<bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean" />
<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
</bean>
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" />
</beans>
Honestly, I dont have any idea how to fix it. Based on my understanding it is looking for some modules but I could not fix it. I even tried this "Add framework support" . But I couldn't find spring in the list.
Could you help me fix this? Thanks
Go to File/Project Structure/Modules, click the green plus icon, select Spring from the dropdown and select your module in the next dialog.
Then click the green plus in the right pane, click plus and select your Spring configuration files and classes and click OK.
Also take a look at IntelliJ Help for Spring Facet.
Just ran into this issue out of the blue today—my build was working last night, and this morning it stopped working—so I figured I'd post my solution using IntelliJIDE CE 2019.1.
Error Messages (to help people find this answer)
package org.springframework.transaction.annotation does not exist
package org.springframework.boot does not exist
Unknown facet type: 'Spring'
Unknown facet type: 'web'
Solution
Step 0:
Update IntelliJ
Menu: IntelliJIDE > Check for Updates (Mac OSX)
Step 1:
Clean out Maven repo and re-download dependencies to ensure that the sources are not corrupt. This will take 5+min.
$ cd [project_directory]
$ mvn dependency:purge-local-repository
Step 2:
Preform a clean install.
$ mvn clean install
Step 3:
Update IntelliJIDE's Repository Indexes:
Open IntelliJ Settings/Preferences
Build, Execution, Deployment > Build Tools > Maven > Repositories
Select repositories one by one (by clicking on the table row) and click the update button. Specifically, do it for https://repo.mave.apache.org/maven2. The download is ±700mb so it will take a while. (10+min)
Related Questions
getting package org.springframework.transaction.annotation does not exist error while packaging app
package org.springframework.boot does not exist
IntelliJ Ultimate 2018 - the manual way:
Menu File -> Project Structure
Right-click on your module and choose "Add..." -> Spring
Optionally click "fix" if spring is not listed as a dependency
Click the + icon at the top to add your spring configuration .xml file(s)
The automatic way:
Click the body of the popup notification
Click the "Create Default" option

Tomcat 7 - Spring 3.2.1 - OpenJPA No persistent class is specified in eager initialization mode

I'm trying to get a simple web app called Debugger running under Tomcat 7 using Spring 3.2.1 and OpenJPA. I use Eclipse as the IDE and run Tomcat external to the IDE. I'm getting a error when the WAR is being deployed. This is the error message:
org.apache.openjpa.persistence.ArgumentException: No persistent class is specified in eager initialization mode.
Here is the persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0">
<persistence-unit name="applicationDB" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<properties>
<property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
<property name="openjpa.InitializeEagerly" value="true"/>
<property name="openjpa.DynamicEnhancementAgent" value="false"/>
</properties>
</persistence-unit>
</persistence>
Is the error caused by not having any classes specified in this file? I'm just trying to get a base application configuration setup so I'm not yet ready to place any classes in the persistence file. Maybe you have to have at least one?
Either list your persistent classes, or remove the openjpa.InitializeEagerly property.

How to locate path of generated wsdl in Spring-ws

I have generated webservice using spring-ws. I have deployed my application in tomcat and deployed without any error. I am not able to find the path for WSDL. Please help me how to form path for wsdl.
My web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>listener><servlet><servlet-name>spring-ws</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class></servlet><servlet-mapping><servlet-name>sprig-ws</servlet-name><url-pattern>/</url-pattern></servlet-mapping> <context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/spring-ws--servlet.xml</param-value></context-param>
spring-ws-servlet.xml
<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<constructor-arg ref="marshaller" />
</bean>
<bean id="marshaller"
class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller">
</bean>
<bean id="loginEndpoint" class="com.cloudexult.endpoint.LoginEndpoint">
</bean>
<sws:dynamic-wsdl id="loginmanager" portTypeName="LoginService" locationUri="/loginService/"
targetNamespace="http://www.example.org/Login/definitions">
<sws:xsd location="/WEB-INF/schema/Login.xsd"/>
</sws:dynamic-wsdl>
Your wsdl should be accessible through:
http://<servername>:<port>/<context-path>/loginService.wsdl
Can you try this and tell us if it doesn't work?
If you are really stuck, enabling log4j to print spring debug logs will help you.
Enable debug logging of spring by following in log4j.properties :
log4j.category.org.springframework=DEBUG
Once that is done, restart your container, look for following in the DEBUG log :
20:51:16,718 DEBUG main http.MessageDispatcherServlet:469 - Published [org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition#61bf8785] as wsdl11Definition.wsdl
Above is just an example, however the last component of the log, will give you the URI of your WSDL.

PropertyPlaceholderConfigurer does not find property file on disk

I am trying to move a working spring WAR to OSGI environment (in glassfish 3.1 and blueprint, spring 3.0.5).
The application loads properties file from disk, like this:
<bean id="myProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="${my_conf}/my.properties"/>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
</bean>
I see in debugger that ${my_conf}/my.properties is translated to the existing path (c:\conf\my.properties)
I use the property jms.url defined in my.properties in the next bean declaration
<amq:broker useJmx="false" persistent="false" brokerName="embeddedbroker">
<amq:transportConnectors>
<amq:transportConnector uri="tcp://${jms.url}"/>
<amq:transportConnector uri="vm://embeddedbroker" />
</amq:transportConnectors>
</amq:broker>
And in deployment I get an exception "Could not resolve placeholder ${jms.url}"
Why it fails? Is there another way to load properties from file on disk?
thank you
Since its an OSGI environment, you will need spring-osgi-core jar added to your application. Take a look at this link to configure property-placeholder for OSGI framework.
It isn't a solution, but an explanation of my problem.
The problem is related to this bug in spring 3 and osgi.
I had to open spring logs to debug level to understand it.

Resources