Spring 3 application instantiating a class provided by Tomcat - spring

I have a Spring 3 application that is loading a library. The library consists of JAX-WS generated Java bindings. When the library is included in the WAR file and deployed to Tomcat the application runs great.
However when we moved the library into Tomcat (CATALINA_HOME/lib) Spring is no long able to instantiate classes in the library due to what looks like a classloader issue:
Caused by: java.lang.IllegalArgumentException: interface com.sun.xml.ws.developer.WSBindingProvider is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353) ~[na:1.6.0_24]
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581) ~[na:1.6.0_24]
at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:604) ~[jaxws-rt-2.2.1.jar:2.2.1]
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:344) ~[jaxws-rt-2.2.1.jar:2.2.1]
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:326) ~[jaxws-rt-2.2.1.jar:2.2.1]
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:308) ~[jaxws-rt-2.2.1.jar:2.2.1]
at javax.xml.ws.Service.getPort(Service.java:92) ~[na:1.6.0_24]
at org.ghc.webservices.element.services.stubs.Express.getExpressSoap12(Express.java:94) ~[element-soap-libs-dev-1.16.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_24]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_24]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_24]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_24]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:145) ~[spring-beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
Unfortunately we need to keep this library external to the application.
I am stumped on how to correct this issue and would appreciate any suggestions.
-Thanks!

are you sure the directory that you placed the library in, is available in the classpath? we normally place our external libraries in common\lib like this.
%CATALINA_HOME%\common\lib\<yourjar>.jar
And if that didn't work then try explicitly appending the your jar and set in classpath in catalina.bat file.
set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\common\lib\<yourjar>.jar

Related

Spring Data Neo4j - Cross store persistence

I am new to SDN, I am trying to do a cross store persistence with hibernate. The tutorial given in website has examples for the same, I have checked the github ones too. I have two questions
I am unable to do xml configuration as mentioned in the docs or examples. <neo4j:config/> doesn't support entityManagerFactory. My assumption is it creates the default Neo4jConfiguration which doesn't have a setter for entityManagerFactory. The workaround i have found is to define a CrossStoreNeo4jConfiguration bean.
#Bean
public CrossStoreNeo4jConfiguration crossStoreNeo4jConfiguration(){
CrossStoreNeo4jConfiguration configuration = new CrossStoreNeo4jConfiguration();
configuration.setEntityManagerFactory(entityManagerFactory);
configuration.setGraphDatabaseService(graphDatabaseService);
return configuration;
}
How to do this inside<neo4j:config/>
What happens when you refer a Neo4jTemplate to your repository using neo4j-template-ref when you define repositories using neo4j:repositories? what is the purpose?
UDPATE
The reason it was unable to create CrossStoreNeo4jConfiguration with <neo4j:config/> was , i was missing the dependency spring-data-neo4j-cross-store`. But now i get exception on application start up.
Caused by: java.lang.IllegalStateException: Singleton 'nodeEntityStateFactory' isn't currently in creation
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.afterSingletonCreation(DefaultSingletonBeanRegistry.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:239)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:292)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955.nodeEntityStateFactory(<generated>)
at org.springframework.data.neo4j.config.Neo4jConfiguration.mappingContext(Neo4jConfiguration.java:199)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955.CGLIB$mappingContext$11(<generated>)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955$$FastClassByCGLIB$$3134c8a8.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955.mappingContext(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149)
Thanks in advance.
This should work:
<neo4j:config entityManagerFactory="entityManagerFactory"/>
No need to create your custom implementation.
The template passed to the repository config is the one used by its infrastructure. In most cases there is no need to configure something different.

Use classmexer in Eclipse RCP application?

I tried to use classmexer in an Eclipse RCP application but I got only an IllegalStateException:
java.lang.IllegalStateException: Agent not initted
at com.javamex.classmexer.Agent.getInstrumentation(Agent.java:33)
at com.javamex.classmexer.MemoryUtil.deepMemoryUsageOf(MemoryUtil.java:104)
at com.javamex.classmexer.MemoryUtil.deepMemoryUsageOf(MemoryUtil.java:80)
at classmexertester.ViewPart.createPartControl(ViewPart.java:22)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:229)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:534)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:643)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:570)
at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:568)
at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:272)
at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:981)
at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2714)
at org.eclipse.ui.internal.WorkbenchWindow$28.run(WorkbenchWindow.java:3030)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:3011)
at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:799)
at org.eclipse.ui.internal.Workbench$23.runWithException(Workbench.java:1229)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1600)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4683)
at org.eclipse.ui.internal.StartupThreading.runWithoutExceptions(StartupThreading.java:94)
at org.eclipse.ui.internal.Workbench.init(Workbench.java:1595)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2628)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at classmexertester.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
in the runtime configuration I put:
-javaagent:C:/Users/kd/workspace/ClassmexerTester/classmexer.jar
can it be that I have to add something in the plugin.xml?
in the runtime configuration I put:
-javaagent:C:/Users/kd/workspace/ClassmexerTester/classmexer.jar
That doesn't sound right. You need to pass -javaagent:C:/Users/kd/workspace/ClassmexerTester/classmexer.jar as a JVM argument. You specify these in the JM Arguments pane on your Product configuration's Launching tab.
You will also need the classmexer.jar in the list of included jars on the classpath pane of your plugin.xml's Runtime tab.
I looked at this a bit more, and ended up in the same situation. I don't think there is a simple solution, as the problem stems from the OSGi framwework's use of separate classloaders for loading bundles. See How can I use java.lang.instrument in an Eclipse RCP application?
The issue is the instance of the classmexer agent that is initialised by the -javaagent VM arg is not the same instance as the one we get in our plugin due to the different classloaders in play. The only way I can see of solving this issue is by modifiying the Agent class, either to use the System.properties based mechanism of object sharing given in the example above, or by implementing the Starting Agents After VM Startup mechanism and attaching the agent programatically in your plugin. Both approaches require changing the classmexer Agent class, so aren't immediately viable as the source doesn't seem to be public.
You can however make use of the excelent Application Profiling tools available in the Eclipse Test & Performance Tools Platform
The following step did the job for me. In Eclipse Java IDE, Go to Run Configuration->Arguments tab and enter "-javaagent:classmexer.jar" under VM arguments and Apply the changes. Make sure classmexer.jar is included in the Eclipse Build path as well.

Class Loading Issue with HornetMQ and JBoss 7.0.2

I am working on a JBoss 7.0.2 instance. Our app is a war and messages are dropped into the queue. This works fine. But when we read it via a listener, the system throws an exception. It is looking for a class which is present in the WEB-INF/classes.
I understand that the module classloader (if I am right it is HornetMQ) is not able to see this application class and throwing up. I dont want my application class to be part of the server lib. That class living within the war is the best place.
The exception is :
javax.jms.JMSException: com.yyy.TransportMessage from [Module "org.hornetq:main" from local module loader #238b8914
(roots: /Users/xxx/jboss/multi/jboss-as-7.0.2.Final/modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
at org.hornetq.utils.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:71)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at org.hornetq.jms.client.HornetQObjectMessage.getObject(HornetQObjectMessage.java:158)
at com.xxx.MessageReceiver.handleObjectMessage(NSMessageReceiver.java:72)
at com.xxx.jms.JMSListener.onMessage(JMSListener.java:1540)
at org.hornetq.jms.client.JMSMessageListenerWrapper.onMessage(JMSMessageListenerWrapper.java:91)
What should I do to make this work?
Regards.
ashok

JSF1.1 Webapp on WebSphere AS 7 IntrospectionException

Got an exception during migration Web application from WAS 6.1 to WAS 7. This application developed using JSF1.1 (MyFaces) + Facelets + Spring (for backing beans). On some pages I'm getting the following exception:
Caused by: javax.faces.FacesException: Could not retrieve value of component with path : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/recovery_accs.xhtml][Class: javax.faces.component.html.HtmlForm,Id: sequestration][Class: javax.faces.component.html.HtmlDataTable,Id: _id37][Class: javax.faces.component.UIColumn,Id: _id50][Class: javax.faces.component.html.HtmlOutputText,Id: _id52]}
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getValue(RendererUtils.java:271)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:226)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:69)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:57)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:799)
... 46 more
Caused by: javax.faces.el.PropertyNotFoundException: /pages/sub/idocAccsRecoverySub.xhtml #34,55 value="#{varbean.idocAcc.vzOrder}": Bean: com.test.project.bean.idoc.accs.IdocAccBean, property: idocAcc
at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
at javax.faces.component.UIOutput.getValue(UIOutput.java:118)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getValue(RendererUtils.java:267)
... 50 more
Caused by: java.beans.IntrospectionException: Parameter type in setter method does not corresponds to predefined.
at java.beans.PropertyDescriptor.setWriteMethod(Unknown Source)
at java.beans.PropertyDescriptor.<init>(Unknown Source)
at java.beans.StandardBeanInfo.introspectProperties(Unknown Source)
at java.beans.StandardBeanInfo.<init>(Unknown Source)
at java.beans.Introspector.getBeanInfoImpl(Unknown Source)
at java.beans.Introspector.getBeanInfoImpl(Unknown Source)
at java.beans.Introspector.getBeanInfoImplAndInit(Unknown Source)
at java.beans.Introspector.getBeanInfo(Unknown Source)
at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:474)
at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:438)
at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:85)
at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
... 52 more
Tried to use different version of facelet library and different EL implementations. Even tried to recompile project using IBM's JDK. Still no success. On Apache Tomcat it works without problem.
In a stacktrace above - IdocAccBean is a regular java bean which extends an abstract class IdocAccCore. If I use other backing beans which extend that class I get the same exception. All other beans not derived from IdocAccCore work correctly. There is nothing special in IdocAccCore class and it's pretty big so I don't think it's necessary to give full source code.
Any suggestions what can be wrong with that IdocAccCore class?
The problem solved by updating IBMs version of JRE. Actually, I was thinking that I'm using the latest version of IBMs JRE. For sure I downloaded one from IBM's siteIBM Development Package for Eclipse. The problem is that this package contains pretty old version of IBM's java 1.6. Fresh version of IBM's java I found in fixpacks for Websphere AS.
You can find detailed list of fixed bugs in IBM's java 1.6 here

Exception starting filter springSecurityFilterChain [duplicate]

This question already has answers here:
ClassNotFoundException when using User Libraries in Eclipse build path
(2 answers)
Closed 2 years ago.
I am getting this when I start the tomcat. I have placed the spring2.5.6.jar in my classpath.
SEVERE: Exception starting filter springSecurityFilterChain
java.lang.ClassNotFoundException: org.springframework.web.filter.DelegatingFilterProxy
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:207)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:78)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3666)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4258)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
What can I do?
As far as I can recall, in Spring 2.5.x this class was either in the full spring.jar, or in the spring-web.jar.
Check whether you have the class inside your spring2.5.6.jar, and if not add spring-web2.5.6.jar to your classpath.
i have placed the spring2.5.6.jar in my classpath
This phrase is very ambiguous. The "classpath" is merely an abstract term which identifies the collection of all local disk file system paths wherein Java has to scan for classes and JAR files during compiletime or runtime. Your current and previous questions and your comments on this question doesn't give me the impression that you properly understand what exactly the classpath is.
In this particular case, you need to ensure that the JAR file is placed in one of those paths which are (by default) covered by the runtime classpath. The webapp's /WEB-INF/lib folder is one of them. You just have to drop a copy of the JAR in that folder. Absolutely nothing more needs to be done. Even not fiddling with Build Path properties in an IDE, which would possibly make things worse. Undo it if necessary. Just dropping the JAR in /WEB-INF/lib folder of the IDE project is sufficient, really.

Resources