Liberty class loading issues or problem with hibernate (migrating tomcat app on liberty)? - jpa

i have to deploy a multi-module application in ear on Liberty Server 20 in my Eclipse. This application use hibernate as provider jpa2 and Derby client + driver derby-10.12.1.1.jar(as shared fileset). Persistence.xml is configured with non jta.
This is server.xml:
<enterpriseApplication id="rubrica-ear" location="rubrica-ear.ear" name="rubrica-ear"/>
<dataSource jndiName="jdbc/TestappDS" type="javax.sql.ConnectionPoolDataSource">
<properties.derby.client createDatabase="false" databaseName=".rubrica"></properties.derby.client>
<jdbcDriver>
<library>
<fileset dir="C:\programmiMio\java-eclipse\drivers" id="shared"></fileset>
</library>
</jdbcDriver>
</dataSource>
My .rubrica db location is in /usr/home.
Because I dont want to start a server derby on console but automatically, i do taht in a #WebListener class:
#WebListener
public class ReqListener implements ServletContextListener {
static final Logger log = LoggerFactory.getLogger(ReqListener.class);
PrintWriter pw = new PrintWriter(System.out);
private NetworkServerControl derbyserver;
#Override
public void contextInitialized(ServletContextEvent arg0) {
try {
String userHomeDir = System.getProperty("user.home", ".");
String systemDir = userHomeDir + "/.rubrica";
// Set the db system directory and startup Server Derby for incoming connections.
System.setProperty("derby.system.home", systemDir);//il db viene salvato qui
derbyserver = new NetworkServerControl(InetAddress.getByName("localhost"), 1527);
derbyserver.start(pw);
log.info("Apache derby settings ok");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error(e.getMessage());
}
}
#Override
public void contextDestroyed(ServletContextEvent arg0) {
if (derbyserver!=null){
...
}
}
When i deploy i get this error
[ERROR] An error occurred in the org.hibernate.ejb.HibernatePersistence persistence provider when attempting to create the entity manager factory of the testapp persistence unit container. The following error occurred: java.lang.NullPointerException
at org.hibernate.engine.jdbc.spi.TypeInfo.extractTypeInfo(TypeInfo.java:128)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:163)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:67)
at com.ibm.ws.jpa.management.JPAPUnitInfo.createEMFactory(JPAPUnitInfo.java:919)
at [internal classes]
When I debug on Liberty i see that Hibernate classes running before the #WebListener code (this is not the same thing in Tomcat), how can i resolve this issue? Something about class loading settings?
I try derby Embedded instead, but problem still araise again, in server.xml:
<properties.derby.embedded createDatabase="create" databaseName="C:/Users/myuser/.rubrica" shutdownDatabase="false"/>
<jdbcDriver>
<library>
<fileset dir="C:\programmiMio\java-eclipse\drivers" id="shared-libs"/>
</library>
</jdbcDriver>
Thanks
Roberto

Related

When deploying a new feature config files are not loaded before bundles are started

I'm evaluating jboss fuse (using version 6.2.1.redhat-084), and i've run into the following issue:
I have a number of features in my project
Each feature has a configuration file
The feature repository file looks like this:
.
<?xml version="1.0" encoding="UTF-8"?>
<features name="myservice-features" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="myservice-common" version="${project.version}">
<configfile finalname="etc/com.myorg.myservice_common.cfg" override="true">mvn:com.myorg/myservice-common/${project.version}/cfg/${build.environment}</configfile>
<bundle start-level="100" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax-cache-api/1.0.0_1</bundle>
<bundle start-level="100" dependency="true">mvn:org.apache.camel/camel-velocity/${camel.version}</bundle>
<bundle start-level="110">mvn:com.myorg/myservice-common/${project.version}</bundle>
</feature>
<feature name="myservice-impl" version="${project.version}">
<feature>myservice-common</feature>
<configfile finalname="etc/com.myorg.myservice.cfg" override="true">mvn:com.myorg/myservice-impl/${project.version}/cfg/${build.environment}</configfile>
<bundle start-level="200">mvn:com.hazelcast/hazelcast/${hazelcast.version}</bundle>
<bundle start-level="200">mvn:com.hazelcast/hazelcast-client/${hazelcast.version}</bundle>
<bundle start-level="220">mvn:com.myorg/myservice-impl/${project.version}</bundle>
</feature>
</features>
The service uses blueprint property placeholder with the corresponding PID to initialize the properties in the camel context
The issue is that when deploying the features in a profile, the configuration files are picked up by org.apache.felix.fileinstall only after the bundles are attempted to be resolved, and I run into the following exception:
.
2016-12-15 10:07:38,384 | ERROR | oyer-49-thread-1 | BlueprintContainerImpl | 23 - org.apache.aries.blueprint.core - 1.4.4 | Unable to start blueprint container for bundle otc-trade-service-impl/1.0.0.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize bean .camelBlueprint.factory.myservice-impl-context
at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)[23:org.apache.aries.blueprint.core:1.4.4]
...
Caused by: java.lang.IllegalArgumentException: Property placeholder key: xxxxx not found
at org.apache.camel.blueprint.BlueprintPropertiesParser.parseProperty(BlueprintPropertiesParser.java:164)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doGetPropertyValue(DefaultPropertiesParser.java:306)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:246)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:154)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:113)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:97)[198:org.apache.camel.camel-core:2.15.1.redhat-621084]
at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:62)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:129)
at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1956)
at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:734)
at org.apache.camel.model.RouteDefinitionHelper.initRouteInputs(RouteDefinitionHelper.java:379)
... 47 more
This looks similar to issue https://issues.jboss.org/browse/ENTESB-593; however, looks like the 'fix' to that issue involved only having the configuration files copied into the ${karaf.base}/etc folder, but not actually triggering and synchronizing on karaf configuration manager before starting the bundles
I'm a bit stuck with this issue. Obviously I could just set 'start="false"' for my bundles and manually start all the camel context bundles after profile deployment, but I'd like to know if there is a more optimal solution.
I've come up up with the following hacky workaround so far:
Add a dependency for org.osgi:org.osgi.compendium:5.0.0 and org.osgi:org.osgi.core:5.0.0
Create the following BundleActivator class:
.
package com.myorg.common;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Dictionary;
public class ConfigurationActivator implements BundleActivator {
public static final String BUNDLE_CONFIGURATION_WATCH = "bundle.configuration.watch";
public static final String BUNDLE_SYMBOLIC_NAME = "bundle.symbolic.name";
private static final Logger LOG = LoggerFactory.getLogger(ConfigurationActivator.class);
private ServiceRegistration<org.osgi.service.cm.ConfigurationListener> listenerReg;
public void start(BundleContext context) throws Exception {
LOG.debug("Bundle " + context.getBundle().getSymbolicName() + " starting");
listenerReg = context.registerService(org.osgi.service.cm.ConfigurationListener.class,
new ConfigurationListener(context), null);
}
public void stop(BundleContext context) throws Exception {
LOG.debug("Bundle " + context.getBundle().getSymbolicName() + " stopping");
if (listenerReg != null) {
listenerReg.unregister();
}
}
public class ConfigurationListener implements org.osgi.service.cm.ConfigurationListener {
private BundleContext bundleContext;
public ConfigurationListener(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
public void configurationEvent(ConfigurationEvent configurationEvent) {
try {
if (configurationEvent.getType() == ConfigurationEvent.CM_UPDATED) {
LOG.debug("Configuration update event: " + configurationEvent.getPid());
Bundle bundle = bundleContext.getBundle();
LOG.trace("Bundle " + bundle.getSymbolicName() + " state: " + bundle.getState());
try {
Configuration configuration = bundleContext.getService(configurationEvent.getReference()).getConfiguration(configurationEvent.getPid());
if (configuration != null) {
Dictionary<String, Object> properties = configuration.getProperties();
if (properties != null) {
if (Boolean.TRUE.toString().equals(properties.get(BUNDLE_CONFIGURATION_WATCH))
&& bundle.getSymbolicName().equals(properties.get(BUNDLE_SYMBOLIC_NAME))) {
LOG.info("Updating bundle " + bundle.getSymbolicName() + " due to configuration change");
bundle.update();
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} catch (IllegalStateException se) {
LOG.warn("Bundle context has been invalidated");
}
}
}
}
Add this bundle activator to the bundle manifest
Add the following properties to your configuration file:
bundle.configuration.watch=true
bundle.symbolic.name=<bundle-name>
Deploy the feature. If the configuration has changed after the bundle has already attempted to start, the bundle will be updated
This still feels inelegant to me due to two reasons:
Additional configuration properties
The original issue will still cause confusing error messages in the logs during deployment
Can anyone suggest a better answer?

Cannot find datasource in Java Adapter in IBM MobileFirst

I have created a DataSource in MobileFirst server.xml:
<dataSource jndiName="jdbc/QAIWDB2">
<jdbcDriver libraryRef="DB2Lib"/>
<properties databaseName="QAIWPRD" password="pass" portNumber="99999" serverName="xyz.com" user="user"/>
</dataSource>
When I am trying to access it from a Java Adpater I am getting an error while deploying the adapter
Adapter deployment failed: An object could not be obtained for name
jdbc/QAIWDB2.
The code in Java Adapter is
static DataSource ds = null;
static Context ctx = null;
public static void init() throws NamingException {
ctx = new InitialContext();
ds = (DataSource)ctx.lookup("jdbc/QAIWDB2");
}
Try the DB2 JNDI definition proposal mentioned in this answer: https://stackoverflow.com/a/17851124/1530814.
Of course, change the values to yours...
<dataSource jndiName="jdbc/db2" type="javax.sql.DataSource">
<jdbcDriver>
<library>
<fileset dir="/usr/lib/java/ibm-db2-universal-driver" includes="db2jcc4.jar, db2jcc_license_cisuz.jar, db2jcc_license_cu.jar"/>
</library>
</jdbcDriver>
<properties databaseName="DB2T" portNumber="21020" serverName="db2t.lvm.de password=" ... " user=" ... "/>
</dataSource>

UserTransaction used by remote clients in WildFly

Is it possible to lookup and use UserTransaction from a remote-client as
in AS 4?
I followed this document and connected from outside the server: Remote EJB invocations via JNDI - EJB client API or remote-naming project - WildFly 8 - Project Documentation Editor.
Here is the code that I used in AS 4, which failed in WildFly
Eg:
public void beginTransaction() {
try {
ut = (UserTransaction) getCtx().lookup("UserTransaction");
ut.begin();
} catch (Exception ex) {
throw new RuntimeException("Failed to begin UserTransactiion", ex);
}
}
Then I got this error:
Caused by: javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.jboss.exported.UserTransaction
Thanks!
It's now deprecated. Better use:
UserTransaction ut = RemoteTransactionContext.getInstance().getUserTransaction();

Spring Rest MultiModule Project has ClassCastException in requestMappingHandlerMapping()

I am facing following issue. I have a multi module project for which I now want to design a Rest-Module for using Spring-Hateoas.
The underlaying modules works as expected. The modules are organized like follows:
app
rest
business
backend
All modules are build by spring-boot in current version 1.1.9.RELEASE.
When I start the Integration-Test as well runable Application class I get the stacktrace you find below. That stacktrace just come when I integrate the business module in application class of rest module.
====
TESTCLASS
#RunWith(SpringJUnit4ClassRunner.class)
#SpringApplicationConfiguration(classes = ApplicationRest.class)
#WebAppConfiguration
#ActiveProfiles("localhost")
public class ApplicationRestTest {
#Test
public void contextLoads() {
}
}
===
CONFIGURATION CLASS OF REST MODULE =>
RUNNING THAT CLASS ONLY WORKS WHEN COMMENTING #IMPORT!!!
#Configuration
#ComponentScan
#EnableAutoConfiguration
#Import(ApplicationBusiness.class) // WORKS WHEN COMMENTING THAT LINE!!!
#PropertySource({ "classpath:/config/application-localhost.properties" })
public class ApplicationRest {
public static void main(final String[] args) {
SpringApplication.run(ApplicationRest.class, args);
}
}
===
CONFIGURATION OF BUSINESS MODULE =>
RUNNING THAT CLASS WORKS!!!
#Configuration
#ComponentScan
#Import(Application.class)
#PropertySource({ "classpath:/config/application-localhost.properties" })
public class ApplicationBusiness {
public static void main(final String[] args) {
SpringApplication.run(ApplicationBusiness.class, args);
}
}
===
CONFIGURATION OF BACKEND MODULE =>
RUNNING THAT CLASS WORKS
#Configuration
#ComponentScan
#EnableAutoConfiguration
#EnableJpaRepositories
#ImportResource("classpath*:META-INF/spring/applicationContext-*.xml")
public class Application {
public static void main(final String[] args) {
final ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
final ContractService service = context.getBean(ContractService.class);
service.countAllContracts();
context.close();
}
}
====
STACKTRACE
CONSOLE OUTPUT OF MODULES BACKEND AND BUSINESS ARE OKAY
....
CONSOLE OUTPUT REST MODULE STARTS HERE ...
2014-11-15 13:39:21.125 INFO 7988 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-11-15 13:39:21.346 WARN 7988 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
2014-11-15 13:20:13.722 ERROR 3472 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener#29ae2517] to prepare test instance [at.compax.bbsng.app.rest.ApplicationRestTest#7a78d2aa]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:103)
at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:98)
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:161)
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:101)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:331)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:213)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:290)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:292)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerMapping()] threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy130 cannot be cast to org.springframework.format.support.FormattingConversionService
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:990)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.test.SpringApplicationContextLoader.loadContext(SpringApplicationContextLoader.java:107)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:69)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:95)
... 25 common frames omitted
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerMapping()] threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy130 cannot be cast to org.springframework.format.support.FormattingConversionService
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
... 41 common frames omitted
Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy130 cannot be cast to org.springframework.format.support.FormattingConversionService
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9d0e5a2e.mvcConversionService(<generated>)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.getInterceptors(WebMvcConfigurationSupport.java:230)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerMapping(WebMvcConfigurationSupport.java:197)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9d0e5a2e.CGLIB$requestMappingHandlerMapping$17(<generated>)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9d0e5a2e$$FastClassBySpringCGLIB$$c90faea7.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$9d0e5a2e.requestMappingHandlerMapping(<generated>)
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 org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
... 42 common frames omitted
============
That Issues happens when I add the following dependency to the classpath:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
When removing it, then it does not complain.
===============
Starting in Debug-Mode prints out following classpath dependencies, maybe that helps:
2014-11-15 16:18:48.758 INFO 8896 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/Development/Projekte/bbsng/trunk/app/rest/target/classes/, file:/C:/Development/Projekte/bbsng/trunk/app/business/target/classes/, file:/C:/Development/Projekte/bbsng/trunk/app/backend/target/classes/, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.1.9.RELEASE/spring-boot-starter-data-jpa-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.1.9.RELEASE/spring-boot-starter-aop-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/aspectj/aspectjrt/1.8.4/aspectjrt-1.8.4.jar, file:/C:/Users/hegnerM/.m2/repository/org/aspectj/aspectjweaver/1.8.4/aspectjweaver-1.8.4.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.1.9.RELEASE/spring-boot-starter-jdbc-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-jdbc/4.0.8.RELEASE/spring-jdbc-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/tomcat/tomcat-jdbc/7.0.56/tomcat-jdbc-7.0.56.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/tomcat/tomcat-juli/7.0.56/tomcat-juli-7.0.56.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-tx/4.0.8.RELEASE/spring-tx-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-orm/4.0.8.RELEASE/spring-orm-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/data/spring-data-jpa/1.6.4.RELEASE/spring-data-jpa-1.6.4.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/data/spring-data-commons/1.8.4.RELEASE/spring-data-commons-1.8.4.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-aspects/4.0.8.RELEASE/spring-aspects-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/hegnerM/.m2/repository/org/postgresql/postgresql/9.3-1102-jdbc41/postgresql-9.3-1102-jdbc41.jar, file:/C:/Users/hegnerM/.m2/repository/org/hsqldb/hsqldb/2.3.2/hsqldb-2.3.2.jar, file:/C:/Users/hegnerM/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar, file:/C:/Users/hegnerM/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar, file:/C:/Users/hegnerM/.m2/repository/commons-pool/commons-pool/1.6/commons-pool-1.6.jar, file:/C:/Development/Projekte/bbsng/trunk/app/domain/target/classes/, file:/C:/Users/hegnerM/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.6.Final/hibernate-entitymanager-4.3.6.Final.jar, file:/C:/Users/hegnerM/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar, file:/C:/Users/hegnerM/.m2/repository/org/hibernate/hibernate-core/4.3.6.Final/hibernate-core-4.3.6.Final.jar, file:/C:/Users/hegnerM/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/hegnerM/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar, file:/C:/Users/hegnerM/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar, file:/C:/Users/hegnerM/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar, file:/C:/Users/hegnerM/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar, file:/C:/Users/hegnerM/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/C:/Users/hegnerM/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar, file:/C:/Users/hegnerM/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar, file:/C:/Users/hegnerM/.m2/repository/com/mysema/querydsl/querydsl-jpa/3.4.3/querydsl-jpa-3.4.3.jar, file:/C:/Users/hegnerM/.m2/repository/com/mysema/querydsl/querydsl-core/3.4.3/querydsl-core-3.4.3.jar, file:/C:/Users/hegnerM/.m2/repository/com/google/guava/guava/14.0/guava-14.0.jar, file:/C:/Users/hegnerM/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar, file:/C:/Users/hegnerM/.m2/repository/com/mysema/commons/mysema-commons-lang/0.2.4/mysema-commons-lang-0.2.4.jar, file:/C:/Users/hegnerM/.m2/repository/com/infradna/tool/bridge-method-annotation/1.13/bridge-method-annotation-1.13.jar, file:/C:/Development/Projekte/bbsng/trunk/app/log/target/classes/, file:/C:/Users/hegnerM/.m2/repository/org/aspectj/aspectjtools/1.8.4/aspectjtools-1.8.4.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter/1.1.9.RELEASE/spring-boot-starter-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot/1.1.9.RELEASE/spring-boot-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.1.9.RELEASE/spring-boot-autoconfigure-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.1.9.RELEASE/spring-boot-starter-logging-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.7/jcl-over-slf4j-1.7.7.jar, file:/C:/Users/hegnerM/.m2/repository/org/slf4j/jul-to-slf4j/1.7.7/jul-to-slf4j-1.7.7.jar, file:/C:/Users/hegnerM/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.7/log4j-over-slf4j-1.7.7.jar, file:/C:/Users/hegnerM/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar, file:/C:/Users/hegnerM/.m2/repository/ch/qos/logback/logback-core/1.1.2/logback-core-1.1.2.jar, file:/C:/Users/hegnerM/.m2/repository/org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar, file:/C:/Users/hegnerM/.m2/repository/org/projectlombok/lombok/1.14.8/lombok-1.14.8.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/commons/commons-collections4/4.0/commons-collections4-4.0.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar, file:/C:/Users/hegnerM/.m2/repository/joda-time/joda-time/2.3/joda-time-2.3.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/1.1.9.RELEASE/spring-boot-starter-actuator-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-actuator/1.1.9.RELEASE/spring-boot-actuator-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-core/4.0.8.RELEASE/spring-core-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.1.9.RELEASE/spring-boot-starter-web-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.1.9.RELEASE/spring-boot-starter-tomcat-1.1.9.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/7.0.56/tomcat-embed-core-7.0.56.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/7.0.56/tomcat-embed-el-7.0.56.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/7.0.56/tomcat-embed-logging-juli-7.0.56.jar, file:/C:/Users/hegnerM/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/7.0.56/tomcat-embed-websocket-7.0.56.jar, file:/C:/Users/hegnerM/.m2/repository/org/hibernate/hibernate-validator/5.0.3.Final/hibernate-validator-5.0.3.Final.jar, file:/C:/Users/hegnerM/.m2/repository/org/jboss/logging/jboss-logging/3.1.1.GA/jboss-logging-3.1.1.GA.jar, file:/C:/Users/hegnerM/.m2/repository/com/fasterxml/classmate/1.0.0/classmate-1.0.0.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-web/4.0.8.RELEASE/spring-web-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-webmvc/4.0.8.RELEASE/spring-webmvc-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-expression/4.0.8.RELEASE/spring-expression-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/hateoas/spring-hateoas/0.16.0.RELEASE/spring-hateoas-0.16.0.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-aop/4.0.8.RELEASE/spring-aop-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-beans/4.0.8.RELEASE/spring-beans-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/spring-context/4.0.8.RELEASE/spring-context-4.0.8.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar, file:/C:/Users/hegnerM/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar, file:/C:/Users/hegnerM/.m2/repository/org/springframework/plugin/spring-plugin-core/1.1.0.RELEASE/spring-plugin-core-1.1.0.RELEASE.jar, file:/C:/Users/hegnerM/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.3.4/jackson-databind-2.3.4.jar, file:/C:/Users/hegnerM/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.3.4/jackson-annotations-2.3.4.jar, file:/C:/Users/hegnerM/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.3.4/jackson-core-2.3.4.jar, file:/C:/Users/hegnerM/.m2/repository/com/jayway/jsonpath/json-path/0.9.1/json-path-0.9.1.jar, file:/C:/Users/hegnerM/.m2/repository/net/minidev/json-smart/1.2/json-smart-1.2.jar]
Okay I got the problem, but I really don't know why this is a problem or is it a spring bug.
I am using a module for Business-Method Logging, what I have centralized as aspect. This works with the modules backend and business, it just start that exception behavior when I use spring-mvc with spring-boot.
As you seen above my module backend has annotation #ImportResource("classpath*:META-INF/spring/applicationContext-*.xml"), so that spring can find the xml-config file what includes following (mentioned I use that xml-file for years to log service logger without any problems):
<bean id="serviceLogger" class="at.compax.bbsng.app.log.service.ServiceLogger" />
<aop:aspectj-autoproxy>
<aop:include name="serviceLogger" />
</aop:aspectj-autoproxy>
<!-- Trace all service methods -->
<bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInterceptor">
<property name="useDynamicLogger" value="true" />
<property name="hideProxyClassNames" value="true" />
</bean>
<!-- Time-Logger -->
<bean id="performanceMonitorInterceptor"
class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor">
<property name="useDynamicLogger" value="true" />
</bean>
<aop:config>
<aop:pointcut id="daoPointcut" expression="execution(* *..*Repository+.*(..))" />
<aop:advisor advice-ref="debugInterceptor" pointcut-ref="daoPointcut" />
</aop:config>
<aop:config>
<aop:pointcut id="servicePointcut" expression="execution(* *..*Service+.*(..))" />
<aop:advisor advice-ref="performanceMonitorInterceptor"
pointcut-ref="servicePointcut" />
</aop:config>
I don't know why spring-boot-mvc has problem with that and why. Does it have problem with annotation for importing xml-files or does it have problems with aspects. But I guess I will find out and I will report.
If someone knows what is the problem, please don't hesiate to post.
=======
As mentioned spring-web-starter seems to have problem when using aspect. But thats really stupid, it always worked when doing multi-module-project without spring-boot. If nobody knows answer on it, I guess it is a spring bug and I will create jira ticket. Ideas are welcome....
I regenerated serialVersionUID after changed of Class properties, and that is works for me.

How to connect JBoss 7.1.1 remoting -jmx via java code?

I have a JBoss 7.1.1 server, for which I want to write jmx client. As far I understood, jboss 7.1.1 is not using typical rmi based jmx and they have given a layer of remoting-jmx over native management. I am using following code:
JMXServiceURL address = new JMXServiceURL("service:jmx:remoting-jmx://localhost:9999");
Map env = JMXConnectorConfig.getEnvironment(paramtbl);
JMXConnector connector = JMXConnectorFactory.connect(address, env);
But it is giving following exception:
java.net.MalformedURLException: Unsupported protocol: remoting-jmx
I googled it and the following thread seems relevant:
https://community.jboss.org/thread/204653?tstart=0
It asks to add jboss's libraries to my classpath. I tried that also but still getting same exception.
I got the same exception when trying to get a JmxServiceUrl.
Make sure that in your standalone.xml you have the following:
<subsystem xmlns="urn:jboss:domain:jmx:1.1">
<show-model value="true"/>
<remoting-connector use-management-endpoint="true" />
</subsystem>
And you should include in project classpath the jar named: jboss-client.jar, it can be found in JBOSS_DIRECTORY/bin/client. In fact, the JMX client must include that jar in its classpath.
This tip fixed the problem for me..Hope it will be helpful for you
Tried to do the same from Arquillian test on JBoss AS7 and finally had to use:
import org.jboss.remotingjmx.RemotingConnectorProvider;
RemotingConnectorProvider s = new RemotingConnectorProvider();
JMXConnector connector = s.newJMXConnector(url, credentials);
connector.connect();
Could not have "module name="org.jboss.remoting-jmx" services="import"" working
Also works with
environment.put("jmx.remote.protocol.provider.pkgs", "org.jboss.remotingjmx");
JMXConnector connector = JMXConnectorFactory.connect(url, environment);
connector.connect();
I used this code to connect to JBoss in a remote server
ModelControllerClient client = null;
try {
client = createClient(InetAddress.getByName("172.16.73.12"), 9999,
"admin", "pass", "ManagementRealm");
}
catch (UnknownHostException e) {
e.printStackTrace();
}
Where createClient is a method I wrote -
private ModelControllerClient createClient(final InetAddress host,
final int port, final String username, final String password,
final String securityRealmName) {
final CallbackHandler callbackHandler = new CallbackHandler() {
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (Callback current : callbacks) {
if (current instanceof NameCallback) {
NameCallback ncb = (NameCallback) current;
ncb.setName(username);
} else if (current instanceof PasswordCallback) {
PasswordCallback pcb = (PasswordCallback) current;
pcb.setPassword(password.toCharArray());
} else if (current instanceof RealmCallback) {
RealmCallback rcb = (RealmCallback) current;
rcb.setText(rcb.getDefaultText());
} else {
throw new UnsupportedCallbackException(current);
}
}
}
};
return ModelControllerClient.Factory
.create(host, port, callbackHandler);
}
For more information on how to read the data obtained from Server or for the complete project using Java/Google visualizer API (to show the statistics in Graph after every 10 secs) , Please refer to this tutorial -
http://javacodingtutorial.blogspot.com/2014/05/reading-jboss-memory-usage-using-java.html
Add the following to your jboss-deployment-structure
<dependencies>
<module name="org.jboss.remoting3.remoting-jmx" services="import"/>
</dependencies>
Activate JMX remoting subsystem by adding following entry in standalone.xml
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<!-- Activate JMX remoting -->
<global-modules>
<module name="org.jboss.remoting-jmx" slot="main"/>
</global-modules>
...
</subsystem>
It seems like "jboss-client.jar" is not available at run-time for JMX connection, So make sure that you have added "jboss-client.jar" in the class path.
And also you are using deprecated protocol "remoting-jmx" instead of "remote".
i.e, "service:jmx:remote://localhost:9999"
Hope it helps.