load properties file from class path - properties-file

I created a "AppProp.java" file to write 3 properties(dabase hostname,dbuser name,dbpassword) in "config.properties".I tried load properties file from classpath.but it gives error as following ....
**Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:434)
at java.util.Properties.load0(Properties.java:353)
at java.util.Properties.load(Properties.java:341)
at App.main(App.java:18)**
Now,I want to know why it gives error?

Related

XSSFWorkbook Creation failure

I am creating .xlsx file using poi jars which are poi-3.15.jar, poi-ooxml->3.15.jar, poi-ooxml-schemas-3.15.jar, ooxml-schemas-1.3.jar, xml-apis->2.0.2.jar, xbean-2.2.0, xmlschema-1.4.7.jar and commons-collections4-.4.0.jar.> But still im getting follwoing error.Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.commons.collections4.ListValuedMap
can you please help me to create simple .xlsx file using >XSSFWorkbook class.
ListValuedMap is contained in this jar: commons-collections4. You should also use Xml Beans 2.3.0 or later.

org.apache.ignite.IgniteCheckedException: Failed to read class name from file

I have a 3 node Apache Ignite Cluster, I have created a cache with Integer as Key and a 'Subscriber' POJO as value, when I connect to the cluster from inside a JAVA program and access the cache , I get the above mentioned exception, I have 'peerclassloading' property set to false, and I have deployed 'Subscriber' POJO Binaries in all the nodes, Please find the complete stack trace below. What am I missing here? Why is it looking for some file inside my IGNITE_HOME when I am starting client inside my JAVA program with Ignition.start()?
class org.apache.ignite.IgniteCheckedException: Failed to read class name from file [id=-1219769240, file=/home/benakaraj/Downloads/apache-ignite-fabric-1.5.0.final-bin/work/marshaller/-1219769240.classname]
at org.apache.ignite.internal.MarshallerContextImpl.className(MarshallerContextImpl.java:158)
at org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:174)
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:483)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1443)
at org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:537)
at org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:117)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:280)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:145)
at org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinaryIfNeeded(CacheObjectContext.java:132)
at org.apache.ignite.internal.processors.cache.GridCacheContext.unwrapBinaryIfNeeded(GridCacheContext.java:1748)
at org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture.setResult(GridPartitionedSingleGetFuture.java:598)
at org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture.onResult(GridPartitionedSingleGetFuture.java:454)
at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.processNearSingleGetResponse(GridDhtCacheAdapter.java:153)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.access$1200(GridDhtAtomicCache.java:128)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$11.apply(GridDhtAtomicCache.java:295)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$11.apply(GridDhtAtomicCache.java:293)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:582)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:280)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:204)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$000(GridCacheIoManager.java:80)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:163)
at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:821)
at org.apache.ignite.internal.managers.communication.GridIoManager.access$1600(GridIoManager.java:103)
at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:784)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: /home/benakaraj/Downloads/apache-ignite-fabric-1.5.0.final-bin/work/marshaller/-1219769240.classname (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileReader.<init>(FileReader.java:72)
at org.apache.ignite.internal.MarshallerContextImpl.className(MarshallerContextImpl.java:154)
... 26 more
Looks like the cache tries to deserialize the value after retrieving it from cache, but you don't have a class for it on the node where IgniteCache.get() was called. You can either deploy the class, or use IgniteCache.withKeepBinary() to avoid deserialization: https://apacheignite.readme.io/docs/binary-marshaller#binaryobject-cache-api
The issue turned out to be pretty simple, Ignite looks for the user defined POJOs from the list of classes loaded by default class loader, if it does not find it there , it looks inside marshalled classes, In my case, my value POJO was inside the test resources , hence default class loader was not loading the class, causing ignite to look inside marshalled classes folder(IGNITE_HOME/work/marshaller/) .

apache.commons.configuration Unable to load the configuration from the URL

For a project I'm working on I need to change some property values at run time and save them. Looking for a solution I found the apache commons configuration.
I have looked at some others topics solving my first problems but now, an error that says:
org.apache.commons.configuration.ConfigurationException: Unable to load the configuration from the URL file:/C:/Users/sensor/Documents/NetBeansProjects/HermanWijn/dist/run1776677076/HermanWijn.jar!/Database/DataProptester.properties
Looking at this toppic: Property file not reflecting the modified changes using Apache Commons Configuration
My code should be working but for some reason I get an error.
The JDBCWijnDAO is a class in the same package as the properties file, Of course I want to do more than just load the prop file, but at the moment when creating the new propconfig, gives an error which I need to solve.
code:
URL resource = JDBCWijnDAO.class.getResource("DataProptester.properties");
PropertiesConfiguration config = new PropertiesConfiguration(resource.getPath());
Okay, i think i "know" what the problem is but I don't really know how to fix it, in the trace there is a:
Caused by: java.io.FileNotFoundException: C:\Users\Sensor\Documents\NetBeansProjects\HermanWijn\dist\run1776677076\HermanWijn.jar!\Database\DataProptester.properties (The system cannot find the path specified)
I assume there is something wrong with the total path.
errors:
org.apache.commons.configuration.ConfigurationException: Unable to load the configuration from the URL file:/C:/Users/Sander/Documents/NetBeansProjects/HermanWijn/dist/run1776677076/HermanWijn.jar!/Database/DataProptester.properties
at org.apache.commons.configuration.DefaultFileSystem.getInputStream(DefaultFileSystem.java:86)
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:323)
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:261)
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:238)
at org.apache.commons.configuration.AbstractFileConfiguration.<init>(AbstractFileConfiguration.java:158)
at org.apache.commons.configuration.PropertiesConfiguration.<init>(PropertiesConfiguration.java:253)
at hermanwijn.knophandlers.DataBestandLocatieSelectieHandler.handle(DataBestandLocatieSelectieHandler.java:49)
at hermanwijn.knophandlers.DataBestandLocatieSelectieHandler.handle(DataBestandLocatieSelectieHandler.java:29)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Node.fireEvent(Node.java:6863)
at javafx.scene.control.Button.fire(Button.java:179)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3324)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3164)
at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3119)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1559)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2261)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:228)
at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
at com.sun.glass.ui.View.notifyMouse(View.java:922)
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$2$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.FileNotFoundException: C:\Users\Sander\Documents\NetBeansProjects\HermanWijn\dist\run1776677076\HermanWijn.jar!\Database\DataProptester.properties (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at java.net.URL.openStream(URL.java:1035)
at org.apache.commons.configuration.DefaultFileSystem.getInputStream(DefaultFileSystem.java:82)
Fixed, the problem was the package name was not included, it must be:
URL resource = JDBCWijnDAO.class.getResource("/Database/DataProptester.properties");

exception when finishing a custom "new file wizard" in a RCP project

I am working with a custom "new file wizard". when i press the finish button i am expecting the eclipse to add a new file and show it correctly, but instead an exception occurs and i can't open the created file. But if i use this wizard for a second time, the exception doesn't occur and the file opens correctly. why?
the exception occurs when this line getContainer().run(true, false, op) executes.
and it is a part of the exception:
!ENTRY org.eclipse.e4.ui.workbench 4 0 2012-07-28 16:15:01.239
!MESSAGE Unable to create class 'org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor' from bundle '33'
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.IllegalArgumentException: can't find IDfind.ext
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:857)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:837)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:111)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:318)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:240)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:161)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:141)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:889)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:623)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:725)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:696)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:690)
.
.
.
So the problem is that one of plugins that you have in your app requires a marker named find.ext. The error log shows IDfind.ext because the error message is concatenated without a space.
The happens if you have a custom application. Solution is quite easy:
Locate your WindowActionBarAdvisor that extends ActionBarAdvisor and defines your application initial menus and toolbars like File, Help, etc. etc.
Add this line:
menu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
f.e. to the method
createEditMenu.
or to any other menu entry.

JAVA3D- First program- error [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
problems with java3D lib configuration
I want to make a 3d game using JAVA on Ubuntu, thus I downloaded j3d-1_5_2-linux-i586.zip from http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-client-419417.html#java3d-1.5.1-oth-JPR, extracted it. In Eclipse, I add the 3 jars in ../j3d-1_5_2-linux-i586/lib/ext/ in eclipse, then wrote this code
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.BranchGroup;
public class Hello3d {
public Hello3d() {
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
group.addChild(new ColorCube(0.3));
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main(String[] args) {
new Hello3d();
}
}
got these errors
Description Resource Path Location Type
Access restriction: The constructor SimpleUniverse() is not accessible due to restriction on required library /home/emil/Downloads/j3d-1_5_2-linux-i586/lib/ext/j3dutils.jar Hello3d.java /Checker3D/src line 7 Java Problem
Description Resource Path Location Type
Access restriction: The constructor BranchGroup() is not accessible due to restriction on required library /home/emil/Downloads/j3d-1_5_2-linux-i586/lib/ext/j3dcore.jar Hello3d.java /Checker3D/src line 8 Java Problem
Description Resource Path Location Type
Access restriction: The constructor ColorCube(double) is not accessible due to restriction on required library /home/emil/Downloads/j3d-1_5_2-linux-i586/lib/ext/j3dutils.jar Hello3d.java /Checker3D/src line 9 Java Problem
and more like those
I set the "Forbidden reference (access rules)" under the "Deprecated and restricted API" from "**Error**" to "**Warning**".
on building
I got
Exception in thread "main" java.lang.UnsatisfiedLinkError: no j3dcore-ogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:231)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:200)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:157)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:987)
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:299)
at Hello3d.<init>(Hello3d.java:7)
at Hello3d.main(Hello3d.java:15)
in Run--->Run Configuration ---> JAVA applications--->(x=)arguments--->VM argiments, I added
-Djava.library.path=$LD_LIBRARY_PATH:/home/emil/Downloads/j3d-1_5_2-linux-i586/lib/i386/
I got that error
Exception in thread "main" java.lang.NoClassDefFoundError: Checker
Caused by: java.lang.ClassNotFoundException: Checker
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Checker. Program will exit.
Here is your answer cheers!
Windows -> Preferences -> Java -> Build Path -> User Libraries 1. New: J3DAll, 2. Add JARs.. select all three at ..\jre6\lib\ext\j3dcore.jar, j3dutils.jar, vecmath.jar
Project -> Properties -> Java Build Path -> Libraries Add Library .. -> User Library -> Next select J3DAll Finish
Project -> Properties -> Java Build Path -> Order and Export Top J3DAll