Hibernate Search 5.5 Message Driven Bean for Master/Slave implementation - master-slave

Hibernate documentation doesn't mention what has to be done in the MDB
This example inherits from the abstract JMS controller class available in the Hibernate Search
source code and implements a JavaEE MDB. This implementation is given as an example and
can be adjusted to make use of non Java EE Message Driven Beans. Essentially what you need
to do is to connect the specific JMS Queue with the SearchFactory instance of the EntityManager.
As an advanced alternative, you can implement your own logic by not extending AbstractJMSHibernateSearchController
but rather to use it as an implementation example.
In 5.5 we cant find AbstractJMSHibernateSearchController class. Please help to know what has to be implemented.
Basically i was implementing Master/Slave using Hibernate Search with 4.2
I am getting below exception, trying to upgrade to latest version
org.hibernate.search.store.impl.FSSlaveDirectoryProvider - HSEARCH000021: Unable to synchronize source of C:\hisindex-slave\com.abc.his.warehouse.model.base.Client
java.io.FileNotFoundException: C:\hisindex-slave\com.abc.his.house.model.base.Client\2\_3.fdt (The requested operation cannot be performed on a file with a user-mapped section open)
at java.io.FileOutputStream.open0(Native Method)

Related

Grails java.lang.IllegalStateException: Method on class [] was used outside of a Grails application Grails 2.5.0 (not a test class)

I am trying to upgrade a Grails 1.2.x project to the minimum version which supports JDK 1.8 (=Grails 2.5.0) so that I modify the written code as less as possible.
After I managed to resolve all the dependencies, create the .war file and start it (on a jBoss 7 server) I get the mentioned error in the title when from a Controller class I do a call such as Result.list() (the Result being the domain class).
I do have multiple datasources configured, it seems the jndi names are OK and I can connect to the used DB (I got errors when these were not OK).
I tried to put #Validateable as I red somewhere on the class, but no use.
Any ideas or tips what could I try else? I suspect it is something related to DB, not have no idea how to approach it.

JBoss 6.x throwing java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl

In our application we make WSDL service call(let us say "SomeService"). We use JBoss 6.x and JDK1.8 in our environment(test). Our application also has dependency with CXF for some other services. "SomeService" should be called through standard JAXWS instead of "CXF". By default,c all is being routed through CXF and that's resulting into policy issues. Hence, I followed the solution mentioned below:
JAX-WS = When Apache CXF is installed it "steals" default JDK JAX-WS implementation, how to solve? .
I made the following change in my code:
if (previousDelegate.getClass().getName().contains("cxf")) {
ServiceDelegate serviceDelegate = ((Provider) Class.forName("com.sun.xml.internal.ws.spi.ProviderImpl").newInstance())
.createServiceDelegate(SomeService.WSDL_LOCATION, SomeService.SERVICE_NAME, service.getClass());
delegateField.set(service, serviceDelegate);
}
This change works fine for me in my local environment(I'm using Tomcat 8 +JDK 1.8). I went and deployed the code in test platform (it's JBoss 6.x + JDK 1.8). While testing the functionality, I'm getting the following error:
java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl from [Module "deployment.MyAPP.war:main" from Service Module Loader]
Not sure of the reason for this error. Anybody has clues about it? Do we need to make any additional changes in our JBoss server. Since "com.sun.xml.internal.ws.spi.ProviderImpl" is standard class and that's available in JDK1.8, I don't see any reason why am I getting the above error since our JBoss server is pointing to JDK1.8.
Your help is highly appreciated.
It looks like a classloading issue with your application, or the application server.
The ClassNotFoundException will occur the first time the class is referenced and the classloader tries to load it. The next time the class is referenced, the classloader has cached that is is not found and will throw a NoClassDefFoundError.
Confirm that the ClassNotFoundException is not being caused by the class not being packaged correctly or other classloader settings. Also, ensure the ClassNotFoundException is not occurring the first time the class is referenced.
Check to see if there are any symlinks in the JBoss path.
That will tell us the classes you have deployed to your application, and allow us check if com.sun.xml.internal.ws.spi.ProviderImpl or a related class is deployed to it. That class is shipped with the application server in this directory, and I think this should be the only location it is loaded from.
src/jboss-as/thirdparty/sun-jaxws/lib/jaxws-rt.jar
The only reference I can find to the message "classLoader is not connected to a domain (probably undeployed?) for class "
If you are using a custom JAX-WS implementation and don't want to use JBossWS CXF (the supported JAX-WS library that comes with EAP 6.x), you'll need to first remove JBossWS from your deployment
Once you've done that, you then need to expose the JDK classes that represent the JAX-WS and SAAJ implementation.
Make sure you add modules dependencies for sun.internal.saaj and sun.internal.ws to your deployment.
--
Anup

Injecting a service in Grails PluginDescriptor.groovy file?

I am trying to transform/Convert my Grails application into a Grails plugin. This post has been very helpful for me in doing so:
http://burtbeckwith.com/blog/?p=1973
While copy pasting the files, and following the above link I am stuck with Bootstrap.groovy file. While I have to paste my Bootstrap.groovy's init() code into ".doWithApplicationContext" , which I have done so, I have a problem regarding injection of sevices. Here is my Application's Bootstrap file:
class BootStrap {
//Injecting voice recordign service
def processRecordingVoiceRecognizitonService
//Injecting Service to Connect to AMQ Server to Send Recording
def AMQConnectionManagementService
//Injecting AMQ Publisher to Publish Voice Recognition Results
def messagePublisherService
//Injecting AMQ Consumer to Consume Voice Model Creation Notifications
def messageConsumerService
.
.
.
.
.
.
.
One can see I am injecting Services in my Bootstap.
I have pasted that piece of code at the start of PluginDesciptor.groovy but Intellij Idea is not showing injection sign which means services are not being injected.
Is it actually possible to inject a service in Plugin Descriptor? If not then what is the wok around to initialize and establish necessary connections in the services files?
I have found a related question but couldn't understand. here is the link just in case. inject service into instance of src/groovy class
The equivalent point to BootStrap in the lifecycle of a plugin descriptor is doWithApplicationContext, which receives a reference to the ApplicationContext from which you can fetch whatever services you need. You can't inject services into the descriptor in the normal way because the descriptor is instantiated (and several of its key methods are called) before the ApplicationContext has been set up.
def doWithApplicationContext = { applicationContext ->
applicationContext.messagePublisherService.someMethodName()
Alternatively, a plugin can provide a bootstrap artefact to applications by naming it something like MyPluginBootStrap.groovy - any Groovy class in grails-app/conf whose name ends with BootStrap will be treated as a bootstrap artefact, it's only the plain BootStrap.groovy in the plugin that is excluded from being "contributed" to applications that depend on the plugin.

Getting "unable to resolve class" exception when importing application domain objects into a plugin in grails

I am working with the Grails Authentication plugin and trying to add a domain class from the plugin into my GORM. I am able to use plugin objects in my application when importing them with, "import com.grailsrocks.authentication.AuthenticationUser", but getting "unable to resolve class" exception when trying to access my application objects from the plugin (I am trying to use the domain class "User" and my import command is "import blap.User" - package name is blap). Both import commands work from the shell, and the import statement is not triggering an error in STS.
I am new to grails, so I'm probably doing something very wrong. But, at this point I am running out of ideas, so any help would be greatly appreciated. Thanks!
Vitaly
While I haven't used the Grails Authentication plugin before, I don't think you should be modifying the plugin classes. In general, you should extend the plugin class you want to modify in your application and use your application class instead.
Actually, from reading the docs, it looks like you should use the event handling to modify the plugin behavior.
From the plugin docs:
The default AuthenticationUser domain class is minimal. If you want to change constraints or add fields (you may consider using a separate class instead for extra user data) you just redefine the onNewUserObject event and return your own instance of a domain class or similar wrapper around another authentication database such as LDAP

What does Grails create-service do exactly?

I am developing a Grails application (with Grails 1.3.7). In service layer, I did not use the command 'create-service' to create my service but do it manually.
As the result, my service was not auto initialize in controllers and other services, and it did not handle transaction.
But I do not know where is the differences from create service by command with by manual? Because I do not see any configuration file which figure out this? (I mean in traditional Spring, we always have some configuration files which specify all beans in applications, but in Grails is not).
I want to fix this issue and commit to SVN server my fix, but I do not want to delete the old service and commit the new one which is created by Grails command. So could you please help me:
1. explain what is the differences from create service by command with by manual?
2. how to change the the service created by manual to service created by command without replacing the old one?
Thank you so much!
explain what is the differences from create service by command with by manual?
Assuming you put your service in grails-app/services and followed the naming convention using a postfix of Service The only difference is that you get a nice template that looks like
class SomeService {
boolean transactional = true
def someMethod() {
}
}
and it automatically creates a unit test with the name SomeServiceTests. That is it. BTW transactional defaults to true if you do not include it.
how to change the the service created by manual to service created by command without replacing the old one?
There is nothing to do assuming you followed the conventions. If you did follow the conventions and you are still experience problems please update your question with more details such as how are you trying to use your service and a example of your service.
As long as you put your class in the grails-app/services directory, it should act just like any other service (and work as a spring bean).
If you put it in src/java or src/groovy, it's not considered a service (and not loaded as a service artefact by grails). It could still be a spring bean, but you'd have to manually add it to the resources.groovy file.
Also note that the Grails autowiring of the beans must be exact, so if you have MyService and you want to use it in the controller, make sure you have "def myService" or "MyService myService." If you would prefer different names of your member variables, you can also use the Spring Autowired annotation directly, though I've only tried autowiring grails types (e.g. a grails service) autowired to a bean I declared in resources.xml
If you put services, or any other bean in the resources.xml or resources.groovy files, they will also be autowired intro controllers, other services, etc.
It's best to think of Grails as "rapid Spring", so the autowiring, transactions, etc all are backed by Spring configuration and such.

Resources