Only in Eclipse: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? - eclipse

Actually I'm introducing myself into JSF. For that reason I copied the project from this location:
http://www.concretepage.com/spring-4/spring-4-jsf-2-integration-example-using-autowired-annotation
Setup:
OpenSUSE 13.2
JDK-1.8.0_77
Gradle 3.0
Spring 4
JSF-2
Apache Tomcat 8.0.33
Eclipse MARS 2 (4.5.2)
Building this project with "gradle build" and deploy it manually to Tomcat and access an URL works just fine. So this project seems to be OK.
So I try the same procedure inside eclipse with a configurated server. But as soon as I access the same URL, I'm getting an IllegalStateException (No WebApplicationContext found: no ContextLoaderListener registered?).
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
org.springframework.web.jsf.el.SpringBeanFacesELResolver.getWebApplicationContext(SpringBeanFacesELResolver.java:90)
org.springframework.web.jsf.el.SpringBeanFacesELResolver.getBeanFactory(SpringBeanFacesELResolver.java:78)
org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:49)
com.sun.faces.el.DemuxCompositeELResolver._getValue(Unknown Source)
com.sun.faces.el.DemuxCompositeELResolver.getValue(Unknown Source)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:94)
org.apache.el.parser.AstValue.getValue(AstValue.java:137)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
com.sun.faces.facelets.el.TagValueExpression.getValue(Unknown Source)
javax.faces.component.ComponentStateHelper.eval(Unknown Source)
javax.faces.component.ComponentStateHelper.eval(Unknown Source)
javax.faces.component.UIOutput.getValue(Unknown Source)
javax.faces.component.UIInput.getValue(Unknown Source)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(Unknown Source)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(Unknown Source)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(Unknown Source)
javax.faces.component.UIComponentBase.encodeEnd(Unknown Source)
javax.faces.component.UIComponent.encodeAll(Unknown Source)
javax.faces.render.Renderer.encodeChildren(Unknown Source)
javax.faces.component.UIComponentBase.encodeChildren(Unknown Source)
javax.faces.component.UIComponent.encodeAll(Unknown Source)
javax.faces.component.UIComponent.encodeAll(Unknown Source)
javax.faces.component.UIComponent.encodeAll(Unknown Source)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(Unknown Source)
com.sun.faces.application.view.MultiViewHandler.renderView(Unknown Source)
com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
javax.faces.webapp.FacesServlet.service(Unknown Source)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
I think this exception is already seen pretty often. I've tried serveral confirmed solutions, but all of them mess up the simplicity of the project. Also the manual deployment is working, so I don't think there is something wrong with the project itself. (e.g. adding a context-listener,...)
I'm pretty sure, there is something wrong with the configuration of the server or the project inside eclipse.
I compared several settings against the standalone-tomcat:
Usage of the same JRE
configuration of project's libs and deployment-assembly
eclipse launch-configuration by ps -Af
Also neither warnings nor errors are printed into the console-log.
I added a breakpoint to WebAppInitializer.onStartup. This breakpoint was not visited.
Do you have other suggestions what to check or even a solution for this?
-- Solution --
Could it be that simple?
Next day I started the enviroment again.
I added an index.jsp (I didn't configure the web.xml) started the tomcat inside eclipse. It worked.
Afterwards I removed the index.jsp restarted my complete enviroment, redeployed and it is still working.
I think the solution is a simple restart (simple eclipse-caching-problem).
I don't get the point, why adding a file should influence the bootstrap.
Thanks in advice
Mike

It seems to be a simple eclipse-chaching-problem. Here is the reason why (additionally I added this information to the question)
Next day I started the enviroment again. I added an index.jsp (I didn't configure the web.xml) started the tomcat inside eclipse. It worked. Afterwards I removed the index.jsp restarted my complete enviroment, redeployed and it is still working.
I think the solution is a simple restart.

Related

Error to connect database in Eclipse JDBC ODBC,

I'm looking for resolve problem with eclipse, im trying to connect to MySQL via ODBC im using java 1.7, and the same code in NetBeans, and Eclipse,
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Gtable","root","");
In NetBeans it works fine but in Eclipse returns
Exception in thread "main" java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at testdb2.testd.main(testd.java:11)
How can i fix it ?
I added it to build path
it did not help
Im using this now,
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("sun.jdbc.odbc.JdbcOdbcDriver found");
} catch (ClassNotFoundException cnfe) {
System.out.println("Error: sun.jdbc.odbc.JdbcOdbcDriver not found");
}
And it returns jdbcodbc not found, where can i get that ?
The issue with the Eclipse project was that it was actually running under Java 8, so the JDBC-ODBC Bridge was not available. Changing the run configuration to use a Java 7 JRE solved the problem.
If you want to do this correctly, add a folder called lib to your current project.
Download the jar for the driver and drag this jar from your file explorer in your lib folder in eclipse.
After this, right click your project folder -> java build path, look for the libraries tab and click add jars.
Browse to your jar in the lib folder and click OK. After this click ok again.
This should work :)
Try this:
Class.forName("com.mysql.jdbc.Driver");
If this doesn't work, you probably gave the wrong path.
Try searching in your referenced libraries in the package explorer view.
Just expand the jar and look for driver.class.
If this is to much work, your could try searching with shift + ctrl + r.
adjust your filter to your needs.
You need to search for the path of driver.class
I also suggest you not to use root and give it a strong password
You should open project property (alt+Enter), open menu "Deploy Assembly", and set libraries folder, where you have jdbc driver.
Something like this:

JavaFX native bundle exe is throwing "JavaFx launcher Exception" where as Executable Jar file is perfectly running

For long time I was facing an issue while running the application jar -
I am obfuscating the JAR using Proguard and that JAR file also contains some resource files like images, .version file, etc along with publicCerts.store file.
So to include resource file into final JAR I had specified all the resource files as
-adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF,images/*.jar,*.version,publicCerts.store
but while running my application JAR I was getting execption -
Exception in Application start method
java.lang.reflect.InvocationTargetException
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 com.javafx.main.Main.a(Main.java:642)
at com.javafx.main.Main.main(Main.java:805)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
pl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.AssertionError: java.security.KeyStoreException: Uninitiali
zed keystore
at de.schlichtherle.license.LicenseNotary.getPublicKey(Unknown Source)
at de.schlichtherle.license.LicenseNotary.verify(Unknown Source)
at de.schlichtherle.license.LicenseManager.verify(Unknown Source)
at de.schlichtherle.license.LicenseManager.verify(Unknown Source)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29
)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
... 1 more
Caused by: java.security.KeyStoreException: Uninitialized keystore
at java.security.KeyStore.isKeyEntry(Unknown Source)
... 17 more
I thought the obfuscation corrupting the publicCerts.store so use another obfuscation option for publicCerts.store
-adaptresourcefilenames publicCerts.store
-adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF,images/*.jar,.version
and it works. When I used to double click on by application jar it is showing my application window but now the native bundle executable (exe) is showing me this dialog in the same case at the same condition.
Edited -
I have debugged the issue and found that it's throwing exception -
java.lang.AssertionError: java.security.NoSuchAlgorithmException: PBEWithMD5AndDES SecretKeyFactory not available java.security.NoSuchAlgorithmException: PBEWithMD5AndDES SecretKeyFactory not available
I wonder the native bundle executable (exe) is made up from the same executable but the exe is not working. Here is ANT step to deploy the application and create the native bundle exe.
<target name="CreatingExe" depends="SignedJar">
<fx:deploy width="800" height="600" nativeBundles="all" outdir="${dist}" outfile="${app.name}">
<fx:info title="${app.title}"/>
<fx:application name="${app.title}" mainClass="${main.class}"/>
<fx:resources>
<fx:fileset dir="${distBI}" includes="*.jar"/>
<fx:fileset dir="${WorkingFolder}/temp"/>
</fx:resources>
</fx:deploy>
</target>
FYI : I am running my build on Windows 8 O.S., 64 bit machine. I am deploying my JavaFX application in following steps-
Compiling JavaFX Code.
Creating JAR.
Obfuscating code.
Signing Jar
Creating Executable.
Signing Executable.
Build was successful.
How to exclude publicCerts.store from obfuscation? Why the final exe is not working even the application jar is working? Do I need to specify any thing else in fx:deploy task?
When building a JavaFx native bundle the ext folder under <JDK.HOME> doesn't get included. What this folder contain is mostly the security stuff.
<!--Copy the ext library to the runtime lib-->
<copydir src="${java.home}/lib/ext"
dest="${dist.jar.dir}/bundles/{YOUR.PACKAGE.NAME}/runtime/jre/lib/ext"
includes="**/*"
/>

Eclipse Juno Loading descriptor error

I just updated my Eclipse from Galileo to Juno. I created a new workspace and imported a Java Spring MVC based project. When I open it, it begins 'Loading descriptor' and then an error message pops up: An internal error occurred during: "Loading descriptor for mta_pfm.". If I open it using Galileo, there is no error. I tried to disable the validation of XML file in Juno, but it does not work. I have no idea how to fix it now. Please help. Thanks
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '
Container
' is not legal. (platform:/resource/mta_pfm/WebContent/WEB-INF/web.xml, 138, 14)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.getResource(ProjectResourceSetImpl.java:1064)
at org.eclipse.jst.jee.model.internal.JEE5ModelProvider.getModelResource(JEE5ModelProvider.java:169)
at org.eclipse.jst.jee.model.internal.Web25ModelProvider.getModelObject(Web25ModelProvider.java:44)
at org.eclipse.jst.jee.model.internal.JEE5ModelProvider.getModelObject(JEE5ModelProvider.java:215)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.loadProviders(AbstractMergedModelProvider.java:261)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.access$2(AbstractMergedModelProvider.java:255)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider$LoadModelsWorkspaceRunnable.run(AbstractMergedModelProvider.java:278)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.loadModel(AbstractMergedModelProvider.java:249)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.getMergedModel(AbstractMergedModelProvider.java:219)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.getModelObject(AbstractMergedModelProvider.java:139)
at org.eclipse.jst.jee.ui.internal.navigator.Web25ContentProvider.getNewContentProviderInstance(Web25ContentProvider.java:69)
at org.eclipse.jst.jee.ui.internal.navigator.LoadingJeeDDJob.run(LoadingJeeDDJob.java:50)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '
Container
' is not legal. (platform:/resource/mta_pfm/WebContent/WEB-INF/web.xml, 138, 14)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2657)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2642)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endElement(XMLHandler.java:1564)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:240)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1505)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1284)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.demandLoad(ProjectResourceSetImpl.java:811)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 14 more
Caused by: java.lang.IllegalArgumentException: The value '
Container
' is not a valid enumerator of 'ResAuthType'
at org.eclipse.jst.javaee.core.internal.impl.JavaeeFactoryImpl.createResAuthTypeFromString(JavaeeFactoryImpl.java:741)
at org.eclipse.jst.javaee.core.internal.impl.JavaeeFactoryImpl.createFromString(JavaeeFactoryImpl.java:135)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1615)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1156)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2652)
... 35 more
Some of your projects file may be incompatible with Juno (Juno in it's first release is not very stable, I recommend downloading the official update patches or even better - moving to Kepler which feels more solid).
Anyway, Eclipse can take some runtime arguments as described here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html
Edit your Juno eclipse.exe shortcut and run "'...\eclipse.exe' -clean" to refresh your project files.
Remember to remove the argument once it's fixed as you have no need to clean the project files every time you start eclipse.
Try to start eclipse in clean mode from the command line
eclipse -clean

Nimbus JDK 6u27 applet crashes when running in JRE 7u4

We have a web application that extends the Nimbus LaF library with custom painters for various controls. The applet is built against JDK 6u27, and runs as expected against JRE 6.x, however we have run into issues when running it against JRE 7u4.
We extend AbstractRegionPainter for our custom Painter classes and attempt to instantiate a PaintContext, which causes a "class not found" exception to be thrown.
We realise that Nimbus has been moved into javax.swing in Java 7, and that com.sun.java.swing.plaf.nimbus.AbstractRegionPainter (which we import) now extends javax.swing.plaf.nimbus.AbstractRegionPainter, however it does not appear that Oracle have provided similar redirection for the PaintContext inner class. The applet displays the following in the debug log:
Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: com/sun/java/swing/plaf/nimbus/AbstractRegionPainter$PaintContext
...
Caused by: java.lang.ClassNotFoundException: com.sun.java.swing.plaf.nimbus.AbstractRegionPainter$PaintContext
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Since any classes that extend AbstractRegionPainter must provide a PaintContext, this seems like a backwards compatibility bug in JRE7u4, but if anyone has any ideas about how we can fix/workaround this issue it would be greatly appreciated.

Jar cannot be opened on different Computer ("Can not find main class")

Today I programmed myself a Little game, which I compiled into a jar through Eclipse - I made sure its a executable jar, or runnable jar or however you want to call it.
I've sent the jar to a friend of mine, but oddly he's not able to open it.
He's always receiving the "Can not find main class" error, which shouldn't pop up since it works perfectly for me. I've already googled but was not able to find a answer.
If you're interested, you can take a look here, if it works for you:
http://www.file-upload.net/download-3939961/WidzDeluxe.jar.html
Now the question I have is kind of obvious I guess, is the error only for him or do you all have the same problem? What's the cause of it?
If people wish, I also upload the code.
You have compiled class files bundled inside this jar with a different (higher) version of Java. Presumably it was Java 1.7 and the friend of yours is trying to open it with Java 1.6.
Here is the stacktrace I received trying to open your executable jar with Java 1.6.0_21:
Exception in thread "main" java.lang.UnsupportedClassVersionError: NewJFrame : Unsupported major.min
or version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: NewJFrame. Program will exit.
One possible solution that came to my ming would be to set the compliance level to let's say 6.0 in Java Compiler settings in Eclipse. That should to the trick.
I had this same problem, found I was compiling the program for Java 1.7. I ended up updating Java on all my computers that I was running it on and it worked great.