I want to rotate an ImageView programmatically in my Activity. Currently I couldn't find any solutions for Xamarin which works and translated solutions from Android didn't work either. Does anybody know how to rotate an ImageView?
This code for example just gives me a NullPoinerException and I don't know why:
[Trace] error opening trace file: No such file or directory (2)
[Mono] Image addref mscorlib[0xb7c3b4b8] -> mscorlib.dll[0xb7c771b0]: 1
[Mono] AOT module 'mscorlib.dll.so' not found: Cannot load library: load_library[1093]: Library '/data/data/ImageViewRotation.ImageViewRotation/lib/mscorlib.dll.so' not found
[Mono] GC_MAJOR: (mature allocation failure) pause 1.41ms, total 1.34ms, bridge 0.02ms major 112K/32K los 0K/0K
[Mono] Assembly mscorlib[0xb7c3b4b8] added to domain RootDomain, ref_count=1
[Mono] Assembly Loader probing location: '/data/data/ImageViewRotation.ImageViewRotation/files/.__override__/ImageViewRotation.dll'.
[Mono] Image addref ImageViewRotation[0xb7c6aac0] -> /data/data/ImageViewRotation.ImageViewRotation/files/.__override__/ImageViewRotation.dll[0xb7c6a4a0]: 2
[Mono] Assembly ImageViewRotation[0xb7c6aac0] added to domain RootDomain, ref_count=1
[Mono] AOT module '/data/data/ImageViewRotation.ImageViewRotation/files/.__override__/ImageViewRotation.dll.so' not found: Cannot load library: load_library[1093]: Library '/data/data/ImageViewRotation.ImageViewRotation/lib//data/data/ImageViewRotation.ImageViewRotation/files/.__override__/ImageViewRotation.dll.so' not found
[Mono] Assembly Loader loaded assembly from location: '/data/data/ImageViewRotation.ImageViewRotation/files/.__override__/ImageViewRotation.dll'.
[Mono] Config attempting to parse: '/data/data/ImageViewRotation.ImageViewRotation/files/.__override__/ImageViewRotation.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/ImageViewRotation/ImageViewRotation.config'.
[monodroid-gc] GREF GC Threshold: 46800
[Mono] Image addref Mono.Android[0xb7c506d8] -> Mono.Android.dll[0xb7c6c678]: 1
[Mono] Assembly Mono.Android[0xb7c506d8] added to domain RootDomain, ref_count=1
[Mono] AOT module 'Mono.Android.dll.so' not found: Cannot load library: load_library[1093]: Library '/data/data/ImageViewRotation.ImageViewRotation/lib/Mono.Android.dll.so' not found
[Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
[Mono] Unloading image mscorlib.dll [0xb7c85a78].
[Mono] Assembly Ref addref Mono.Android[0xb7c506d8] -> mscorlib[0xb7c3b4b8]: 2
[MonoDroid] Xamarin/Android Trial Mode Active
[dalvikvm-heap] Grow heap (frag case) to 10.964MB for 441772-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 12.649MB for 1767052-byte allocation
[] HostConnection::get() New Host Connection established 0xb7c9c840, tid 2126
[Mono] The request to load the assembly System.Core v2.0.5.0 was remapped to v3.5.0.0
[Mono] Image addref System.Core[0xb7cc0320] -> System.Core.dll[0xb7cbf7c8]: 1
[Mono] Assembly System.Core[0xb7cc0320] added to domain RootDomain, ref_count=1
[Mono] AOT module 'System.Core.dll.so' not found: Cannot load library: load_library[1093]: Library '/data/data/ImageViewRotation.ImageViewRotation/lib/System.Core.dll.so' not found
[Mono] Assembly Ref addref Mono.Android[0xb7c506d8] -> System.Core[0xb7cc0320]: 2
[Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
[Mono] Unloading image mscorlib.dll [0xb7cc2168].
[Mono] Assembly Ref addref System.Core[0xb7cc0320] -> mscorlib[0xb7c3b4b8]: 3
[Mono] Assembly Ref addref ImageViewRotation[0xb7c6aac0] -> Mono.Android[0xb7c506d8]: 2
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Probing '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Found as '_monodroid_gc_wait_for_bridge_processing'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_get_identity_hash_code'.
[Mono] Probing '_monodroid_get_identity_hash_code'.
[Mono] Found as '_monodroid_get_identity_hash_code'.
[Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
[Mono] Unloading image mscorlib.dll [0xb7d9b5f0].
[Mono] Assembly Ref addref ImageViewRotation[0xb7c6aac0] -> mscorlib[0xb7c3b4b8]: 4
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_inc'.
[Mono] Probing '_monodroid_gref_inc'.
[Mono] Found as '_monodroid_gref_inc'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_new'.
[Mono] Probing '_monodroid_gref_log_new'.
[Mono] Found as '_monodroid_gref_log_new'.
[MonoDroid] UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
[MonoDroid] at ImageViewRotation.MainActivity.OnCreate (Android.OS.Bundle) <0x000c2>
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00048>
[MonoDroid] at (wrapper dynamic-method) object.f34fad60-56f9-4f99-879a-ff280dbcc703 (intptr,intptr,intptr) <0x0001f>
[mono]
[mono] Unhandled Exception:
[mono] System.NullReferenceException: Object reference not set to an instance of an object
[mono] at ImageViewRotation.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
[mono] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
[mono] at (wrapper dynamic-method) object:f34fad60-56f9-4f99-879a-ff280dbcc703 (intptr,intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
[mono-rt] at ImageViewRotation.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
[mono-rt] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
[mono-rt] at (wrapper dynamic-method) object:f34fad60-56f9-4f99-879a-ff280dbcc703 (intptr,intptr,intptr)
MainActivity.cs
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Graphics;
namespace ImageViewRotation
{
[Activity (Label = "ImageViewRotation", MainLauncher = true)]
public class MainActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
ImageView image = FindViewById<ImageView> (Resource.Id.imageView1);
Matrix mat = new Matrix();
Bitmap bMap = BitmapFactory.DecodeResource(Resources, Resource.Id.imageView1);
mat.PostRotate(45);
Bitmap bMapRotate = Bitmap.CreateBitmap(bMap, 0, 0, bMap.Width, bMap.Height, mat, true);
image.SetImageBitmap(bMapRotate);
}
}
}
Main.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:src="#drawable/Icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
</LinearLayout>
The line
Bitmap bMap = BitmapFactory.DecodeResource(Resources, Resource.Id.imageView1);
Is where your app will fail. Why? The Resource Id you are passing in is not for an actual image, but for the ImageView instance. DecodeResource is used for decoding images and not views.
Instead you should do something like:
var drawable = image.Drawable;
using (var bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Config.ARGB_8888))
using(var canvas = new Canvas(bitmap))
{
drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
drawable.Draw(canvas);
var mat = new Matrix();
mat.PostRotate(45);
using(var bMapRotate = Bitmap.CreateBitmap(bitmap, 0, 0, bitmap.Width, bitmap.Height, mat, true))
image.SetImageBitmap(bMapRotate);
}
Related
Im new to JNA. Im trying to access a method inside a DLL. I get the following error
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'GetACSStatus': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:179)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:347)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:327)
at com.sun.jna.Library$Handler.invoke(Library.java:203)
at com.sun.proxy.$Proxy0.GetACSStatus(Unknown Source)
at TestJNA.main(TestJNA.java:17)
Here is the code:
public class TestJNA {
public interface simpleDLLTest extends Library {
simpleDLLTest INSTANCE = (simpleDLLTest) Native.loadLibrary("IMV1", simpleDLLTest.class);
public NativeLong GetACSStatus();
}
public static void main(String[] args) {
simpleDLLTest sdll = simpleDLLTest.INSTANCE;
NativeLong result1 = sdll.GetACSStatus(); // calling function
System.out.println("GetACSStatus(): " + result1);
}
}
Please help.
You need to compile your code with extern "C" so that the symbols are exported without C++ name mangling.
Alternatively you can use the name from the symbol table as the function lookup name (you would need to use a FunctionMapperto get the special symbols).
I'm creating a COM component in F#. The component is expected to be used from scripting.
The component code:
namespace WebUIPlugin
open System
open System.Windows
open System.Runtime.InteropServices
[<Guid("BAEF0C5B-EFA5-4868-8342-7A1E6F8F7AF4")>]
type IPlugin =
[<DispId(1)>]
abstract OpenFormFromFile : path:string -> unit
[<Guid("8D71E2DB-D718-4595-B856-58D14EEAEBB2");
ClassInterface(ClassInterfaceType.None);
ComVisible(true)>]
type Plugin = class
new () = {}
interface IPlugin with
member this.OpenFormFromFile(path) =
let showWindow =
let window = Window()
window.Show
UI.spawn showWindow |> ignore
end
end
I'm registering it with regasm /codebase Plugin.dll and it works well from scripting cscript test.js.
test.js is following:
var obj = new ActiveXObject("WebUIPlugin.Plugin");
obj.OpenFormFromFile("");
It even stops on breakpoint in OpenFormFromFile. So good so far.
Unfortunately, I cannot make it work from F#/C#:
let objectType = Type.GetTypeFromProgID("WebUIPlugin.Plugin")
let handler = Activator.CreateInstance(objectType)
objectType.InvokeMember("OpenFormFromFile", BindingFlags.InvokeMethod, null, handler, [|""|]) |> ignore
var objectType = Type.GetTypeFromProgID("WebUIPlugin.Plugin");
dynamic handler = Activator.CreateInstance(objectType);
objectType.InvokeMember("OpenFormFromFile", BindingFlags.InvokeMethod, null, handler, new object[]{""});
The code throws exception:
An unhandled exception of type System.MissingMethodException occurred in mscorlib.dll
Additional information: Attempted to access a missing member.
Everything (component, test C# and F# projects, regasm, cscript) is either in x64 or x86 consistently. With the same result - WSH script works, .NET assembly does not.
I'm building an iOS App where I need to use the camera and save images from it into the App folder.
When I try to convert the image from the camera to a JPEG or PNG, I'm getting: "Cannot cast from source type to destination type."
Here is the code I'm using:
public class ImagePickerDelegate : UIImagePickerControllerDelegate
{
public ImagePickerDelegate()
{
}
public override void FinishedPickingImage(UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
{
var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string jpgFilename = System.IO.Path.Combine(documentsDirectory, string.Format("{0}.jpg", Guid.NewGuid()));
using (NSData imageData = image.AsJPEG(0.2f))
{
NSError err;
if (!imageData.Save(jpgFilename, false, out err))
{
Console.WriteLine("Saving of file failed: " + err.Description);
}
}
}
}
The error occurs when I call:
using (NSData imageData = image.AsJPEG(0.2f))
Any ideas?
Here is the Stacktrace:
System.InvalidCastException: Cannot cast from source type to destination type.
at MonoTouch.UIKit.UIImage.AsJPEG () [0x00006] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIImage.cs:53
at App.ImagePickerDelegate.FinishedPickingImage (MonoTouch.UIKit.UIImagePickerController picker, MonoTouch.UIKit.UIImage image, MonoTouch.Foundation.NSDictionary editingInfo) [0x00024] in /Users/giusepecasagrande/Dropbox/SoftwareDev/AppName/AppName/AppName/ImagePickerDelegate.cs:37
at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38
at BeBabby.Application.Main (System.String[] args) [0x00008] in /Users/giusepecasagrande/Dropbox/SoftwareDev/AppName/AppName/AppName/Main.cs:16
And here is a sample project that I created:
https://github.com/GiusepeCasagrande/XamarinSimpleCameraSample/tree/master
If you input this part of code in the Picker delegate, you can see the problem.
Did you tried overriding the method FinidPickingMedia instead of Finishpickingimage ?
I'm answering this thread, since the problem seems to be solved somehow. And the sample project is now working.
Pasting the comment I made earlier:
Seems to me that the same code that was crashing, I pasted here, then copied back to project and now its working.
Magic? :)
I'm now sure what happened, but what I know is: the project is now running and working flawless. Thanks you all for your efforts and help.
Say a facelets has e.g 10 outputtexts bound with value expressions to 10 different fields in the bean. If exception occurs when calling the first getter, should the following 9 still be called?
Because this is the behavior I am seeing when testing this. It causes grave problems with a legacy module that has been boosted up to use JSF 2.
I am using Mojarra 2.1.16 and tried with Mojarra 2.1.6. Tried with both weld and JSF2 beans. Container is Tomcat 7.
Can this behavior be altered somehow? I can't imagine this being desired behavior.
The code I used to reproduce it below:
EDIT: This is not the production code, this simply shows the unexpected behavior.
Relevant facelet code:
<h:inputText value="#{testController.a}"></h:inputText>
<h:inputText value="#{testController.b}"></h:inputText>
<h:inputText value="#{testController.c}"></h:inputText>
<h:inputText value="#{testController.d}"></h:inputText>
<h:inputText value="#{testController.e}"></h:inputText>
<h:inputText value="#{testController.f}"></h:inputText>
<h:inputText value="#{testController.g}"></h:inputText>
<h:inputText value="#{testController.h}"></h:inputText>
Relevant bean code
private String a, b, c ,d, e, f, g, h;
public String getA() throws Exception {
throw new Exception();
}
public void setA(String a) {
this.a = a;
}
public String getB() {
System.out.println("b was called");
return b;
}
public void setB(String b) {
this.b = b;
}
public String getC() {
System.out.println("c was called");
return c;
}
public void setC(String c) {
this.c = c;
}
public String getD() {
System.out.println("d was called");
return d;
}
public void setD(String d) {
this.d = d;
}
public String getE() {
System.out.println("e was called");
return e;
}
public void setE(String e) {
this.e = e;
}
public String getF() {
System.out.println("f was called");
return f;
}
public void setF(String f) {
this.f = f;
}
public String getG() {
System.out.println("g was called");
return g;
}
public void setG(String g) {
this.g = g;
}
public String getH() {
System.out.println("h was called");
return h;
}
public void setH(String h) {
this.h = h;
}
JSF 2.1.6 with a managed bean:
2013-jan-09 13:54:41 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jre6\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\CollabNet\Subversion Client;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;C:\Program Files (x86)\TortoiseSVN\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\cvsnt;C:\Program Files (x86)\cvsnt1;C:\Program Files\SlikSvn\bin\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Groovy\Groovy-1.8.6\bin;c:\projects\maven\bin;;.
2013-jan-09 13:54:41 org.apache.tomcat.util.digester.SetPropertiesRule begin
VARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:demo' did not find a matching property.
2013-jan-09 13:54:41 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8090"]
2013-jan-09 13:54:41 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8010"]
2013-jan-09 13:54:41 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 706 ms
2013-jan-09 13:54:41 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
2013-jan-09 13:54:41 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.29
2013-jan-09 13:54:47 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context '/demo'
2013-jan-09 13:54:48 com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class javax.validation.constraints.NotNull, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class org.hibernate.validator.constraints.NotEmpty, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class javax.validation.constraints.Size, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class javax.validation.constraints.Pattern, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class javax.validation.constraints.Min, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class javax.validation.constraints.Max, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class javax.validation.constraints.AssertTrue, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.javascript.ClientServiceConfigParser parse
VARNING: Found JavaScript function definition for class javax.validation.constraints.AssertFalse, but that class is not presented
2013-jan-09 13:54:51 org.richfaces.cache.CacheManager getCacheFactory
INFO: Selected fallback cache factory
2013-jan-09 13:54:51 org.richfaces.cache.lru.LRUMapCacheFactory createCache
INFO: Creating LRUMap cache instance using parameters: {facelets.DEVELOPMENT=true, javax.faces.PROJECT_STAGE=Development, org.richfaces.enableControlSkinning=true, javax.faces.DEFAULT_SUFFIX=.xhtml}
2013-jan-09 13:54:51 org.richfaces.cache.lru.LRUMapCacheFactory createCache
INFO: Creating LRUMap cache instance of 512 items capacity
2013-jan-09 13:54:51 org.richfaces.application.InitializationListener onStart
INFO: RichFaces Core Implementation by JBoss by Red Hat, version v.4.2.0.Final
2013-jan-09 13:54:51 com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
INFO: Monitoring jndi:/localhost/demo/WEB-INF/faces-config.xml for modifications
2013-jan-09 13:54:52 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8090"]
2013-jan-09 13:54:52 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8010"]
2013-jan-09 13:54:52 org.apache.catalina.startup.Catalina start
INFO: Server startup in 10510 ms
2013-jan-09 13:55:30 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
ALLVARLIG: Error Rendering View[/rdfieldset/rdfieldset.xhtml]
javax.el.ELException: /rdfieldset/rdfieldset.xhtml #13,42 value="#{testController.a}": Error reading 'a' on type com.wmdata.raindance.webcomp.links.demo.TestController
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.wmdata.raindance.webcomp.fileUpload.FileUploadFilter.doFilter(FileUploadFilter.java:67)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.Exception
at com.wmdata.raindance.webcomp.links.demo.TestController.getA(TestController.java:15)
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 javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
... 39 more
b was called
c was called
d was called
e was called
f was called
g was called
h was called
JSF 2.1.16 with CDI-bean
jan 09, 2013 1:59:52 EM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/start.xhtml]
javax.el.ELException: /start.xhtml #26,49 value="#{testController.a}": Error reading 'a' on type test.testController$Proxy$_$$_WeldClientProxy
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.render(CodiLifecycleWrapper.java:126)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.Exception
at test.testController.getA(testController.java:44)
at test.testController$Proxy$_$$_WeldClientProxy.getA(testController$Proxy$_$$_WeldClientProxy.java)
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 javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
... 39 more
b was called
c was called
d was called
e was called
f was called
g was called
h was called
Using Entity Framework on .Net 4
Here is my code:
using (frfcourEntities frf = new frfcourEntities())
{
EntityKey routehdrId = new EntityKey("frfcourEntities.Routehdrs", "Refno", "xxx");
try{
var routehdr = frf.GetObjectByKey(routehdrId);
frf.DeleteObject(routehdr);
frf.SaveChanges();
}
catch(System.Data.ObjectNotFoundException)
{}
}
The line:
catch(System.Data.ObjectNotFoundException)
will not compile. It reports
The type caught or thrown must be derived from System.Exeception.
But ObjectNotFoundException is what the EF GetObjectByKey method throws.
Add an assembly reference to System.Data. Without it "using System.Data" works but it doesn't resolve DataException.