Search Results

Search found 1594 results on 64 pages for 'initialization'.

Page 6/64 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Why can event handlers can only be bound to HttpApplication events during IHttpModule initialization

    - by Venemo
    This is just another "working in dev server, why not working in IIS" type question. So, I created a nice DAL using NHibernate as described here. When creating an ISession, I hook up an event handler to the HttpApplication.EndRequest to take care of cleaning it up. However, I deployed my site to IIS and it says: Event handlers can only be bound to HttpApplication events during IHttpModule initialization. Since when? What for? Why? How can I bypass it?

    Read the article

  • AS3: Weak Listener References Not Appropriate During Initialization?

    - by TheDarkIn1978
    as i currently understand, if an event listener is added to an object with useWeakReference set to true, then it is eligible for garbage collection and will be removed if and when the garbage collection does a sweep. public function myCustomSpriteClass() //constructor { this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener, false, 0, true); this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener, false, 0, true); } in this case, is it not appropriate to initialize an object with weak references event listeners, incase the garbage collector does activate a sweep removing the objects event listeners since they were added during initialization of the object? in this case, would it only be appropriate to create a type of deallocate() method which removes the event listeners before the object is nullified?

    Read the article

  • Tomcat not showing Spring Context initialization errors when running from Eclipse WTP

    - by SourceRebels
    Hi all, Im working with Eclipse Galileo (WTP), Spring 2.5.6-SEC01 and Apache Tomcat 5.5.28. When I run my application from Eclipse, I'm able to see Tomcat standard output and error from the console view. When there is a Spring initialization error (ex: malformed spring XML) I'm not able to see the error message or the stacktrace at the Console view. Anyone found before a problem like this? how you solve it? Thanks in advance, I'm getting mad :-) Edited: I'm seeing all Tomcat startup messages and my System.out.println and System.err.println messages in Eclipse Console. I also try to pass this two system properties to my Tomcat Server: -Djava.util.logging.manager="org.apache.juli.ClassLoaderLogManager" -Djava.util.logging.config.file="C:\apache-tomcat-5.5.28\conf\logging.properties"

    Read the article

  • Incompatible Types in Initialization

    - by jack
    I have the following code in a subroutine that produces an incompatible types in initialization error on the varVal library in the subroutine evaluateExpression: NSDictionary *varVal; for (int i=0; i<varCount; i++) { [varVal setObject:[(i+1)*2 stringValue] forKey:[i stringValue]]; } double result =[[self brain] evaluateExpression:[[self brain] expression] usingVariableValues:varVal]; My subroutine declaration in the brain.h file is: +(double)evaluateExpression:(id)anExpression usingVariableValues:(NSDictionary *)variables; I'd appreciate any help.

    Read the article

  • LLVM Clang 5.0 explicit in copy-initialization error

    - by kevzettler
    I'm trying to compile an open source project on OSX that has only been tested on Linux. $: g++ -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-da I'm trying to compile with the following command line options g++ -MMD -Wall -std=c++0x -stdlib=libc++ -Wno-sign-compare -Wno-unused-variable -ftemplate-depth=1024 -I /usr/local/Cellar/boost/1.55.0/include/boost/ -g -O3 -c level.cpp -o obj-opt/level.o I am seeing several errors that look like this: ./square.h:39:70: error: chosen constructor is explicit in copy-initialization int strength = 0, double flamability = 0, map<SquareType, int> constructions = {}, bool ticking = false); The project states the following are requirements for the Linux setup. How can I confirm I'm making that? gcc-4.8.2 git libboost 1.5+ with libboost-serialize libsfml-dev 2+ (Ubuntu ppa that contains libsfml 2: ) freeglut-dev libglew-dev

    Read the article

  • inode_operations , warning: initialization from incompatible pointer type

    - by djTeller
    Hi everyone, I'm trying to compile a simple Kernel program that read and write from a proc file. I'm trying to set permission to that file by overriding the permission fp in inode_operations struct (.permission) static int module_permission(struct inode *inode, int op, struct nameidata *foo) { . . . } static struct inode_operations Inode_Ops_4_Our_Proc_File = { .permission = module_permission, /* check for permissions */ }; Our_Proc_File->proc_iops = &Inode_Ops_4_Our_Proc_File; For some reason, when I compile this i get - warning: initialization from incompatible pointer type on the following line: .permission = module_permission, /* check for permissions */ Any idea how to solve this? Thanks!

    Read the article

  • C pointer initialization and dereferencing, what's wrong here?

    - by randombits
    This should be super simple, but I'm not sure why the compiler is complaining here. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int *n = 5; printf ("n: %d", *n); exit(0); } Getting the following complaints: foo.c: In function ‘main’: foo.c:6: warning: initialization makes pointer from integer without a cast I just want to print the value that the pointer n references. I'm dereferencing it in the printf() statement and I get a segmentation fault. Compiling this with gcc -o foo foo.c.

    Read the article

  • Static assembly initialization

    - by ph0enix
    I'm attempting to develop an Interceptor framework (in C#) where I can simply implement some interfaces, and through the use of some static initialization, register all my Interceptors with a common Dispatcher to be invoked at a later time. The problem lies in the fact that my Interceptor implementations are never actually referenced by my application so the static constructors never get called, and as a result, the Interceptors are never registered. If possible, I would like to keep all references to my Interceptor libraries out of my application, as this is my way of (hopefully) enforcing loose coupling across different modules. Hopefully this makes some sense. Let me know if there's anything I can clarify... Does anyone have any ideas, or perhaps a better way to go about implementing my Interceptor pattern? TIA, Jeremy

    Read the article

  • java unload static fields

    - by Alina Danila
    I have a java class that uses complex static fields which need special operations as close() so that they are safely cleaned by GC. For the initialization of static fields I use the static block. But I don't now how to unload the static field safely, so that I can call the close() method before the field is cleaned up by GC. Is there any way to unload a static field, similar to the static initialization block?

    Read the article

  • Seam IllegalStateException: Two components with the same name and precedence

    - by Anand
    Hi, When I run my seam application I get the following error Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.IllegalStateException: Two components with the same name and precedence - component name: wizardController, component classes: package.WizardController, package.WizardController at org.jboss.seam.init.Initialization.addComponentDescriptor(Initialization.java:543) at org.jboss.seam.init.Initialization.installScannedComponentAndRoles(Initialization.java:809) at org.jboss.seam.init.Initialization.scanForComponents(Initialization.java:756) at org.jboss.seam.init.Initialization.init(Initialization.java:629) at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:35) I am not able to resolve this problem.

    Read the article

  • initialize a const array in a class initializer in C++

    - by Nathan Fellman
    I have the following class in C++: class a { const int b[2]; // other stuff follows // and here's the constructor a(void); } The question is, how do I initialize b in the initialization list, given that I can't initialize it inside the body of the function of the constructor, because b is const? This doesn't work: a::a(void) : b([2,3]) { // other initialization stuff } Edit: The case in point is when I can have different values for b for different instances, but the values are known to be constant for the lifetime of the instance.

    Read the article

  • How to delay static initialization within a property

    - by Mystagogue
    I've made a class that is a cross between a singleton (fifth version) and a (dependency injectable) factory. Call this a "Mono-Factory?" It works, and looks like this: public static class Context { public static BaseLogger LogObject = null; public static BaseLogger Log { get { return LogFactory.instance; } } class LogFactory { static LogFactory() { } internal static readonly BaseLogger instance = LogObject ?? new BaseLogger(null, null, null); } } //USAGE EXAMPLE: //Optional initialization, done once when the application launches... Context.LogObject = new ConLogger(); //Example invocation used throughout the rest of code... Context.Log.Write("hello", LogSeverity.Information); The idea is for the mono-factory could be expanded to handle more than one item (e.g. more than a logger). But I would have liked to have made the mono-factory look like this: public static class Context { private static BaseLogger LogObject = null; public static BaseLogger Log { get { return LogFactory.instance; } set { LogObject = value; } } class LogFactory { static LogFactory() { } internal static readonly BaseLogger instance = LogObject ?? new BaseLogger(null, null, null); } } The above does not work, because the moment the Log property is touched (by a setter invocation) it causes the code path related to the getter to be executed...which means the internal LogFactory "instance" data is always set to the BaseLogger (setting the "LogObject" is always too late!). So is there a decoration or other trick I can use that would cause the "get" path of the Log property to be lazy while the set path is being invoked?

    Read the article

  • Efficiency of Java "Double Brace Initialization"?

    - by Jim Ferrans
    In Hidden Features of Java the top answer mentions Double Brace Initialization, with a very enticing syntax: Set<String> flavors = new HashSet<String>() {{ add("vanilla"); add("strawberry"); add("chocolate"); add("butter pecan"); }}; This idiom creates an anonymous inner class with just an instance initializer in it, which "can use any [...] methods in the containing scope". Main question: Is this as inefficient as it sounds? Should its use be limited to one-off initializations? (And of course showing off!) Second question: The new HashSet must be the "this" used in the instance initializer ... can anyone shed light on the mechanism? Third question: Is this idiom too obscure to use in production code? Summary: Very, very nice answers, thanks everyone. On question (3), people felt the syntax should be clear (though I'd recommend an occasional comment, especially if your code will pass on to developers who may not be familiar with it). On question (1), The generated code should run quickly. The extra .class files do cause jar file clutter, and slow program startup slightly (thanks to coobird for measuring that). Thilo pointed out that garbage collection can be affected, and the memory cost for the extra loaded classes may be a factor in some cases. Question (2) turned out to be most interesting to me. If I understand the answers, what's happening in DBI is that the anonymous inner class extends the class of the object being constructed by the new operator, and hence has a "this" value referencing the instance being constructed. Very neat. Overall, DBI strikes me as something of an intellectual curiousity. Coobird and others point out you can achieve the same effect with Arrays.asList, varargs methods, Google Collections, and the proposed Java 7 Collection literals. Newer JVM languages like Scala, JRuby, and Groovy also offer concise notations for list construction, and interoperate well with Java. Given that DBI clutters up the classpath, slows down class loading a bit, and makes the code a tad more obscure, I'd probably shy away from it. However, I plan to spring this on a friend who's just gotten his SCJP and loves good natured jousts about Java semantics! ;-) Thanks everyone!

    Read the article

  • List<element> initialization fires "Process is terminated due to StackOverflowException"

    - by netmajor
    I have structs like below and when I do that initialization: ArrayList nodesMatrix = null; List<vertex> vertexMatrix = null; List<bool> odwiedzone = null; List<element> priorityQueue = null; vertexMatrix = new List<vertex>(nodesNr + 1); nodesMatrix = new ArrayList(nodesNr + 1); odwiedzone = new List<bool>(nodesNr + 1); priorityQueue = new List<element>(); arr.NodesMatrix = nodesMatrix; arr.VertexMatrix = vertexMatrix; arr.Odwiedzone = odwiedzone; arr.PriorityQueue = priorityQueue; //only here i have exception debuger fires Process is terminated due to StackOverflowException :/ Some idea why this collection fires this exception ? private struct arrays { ArrayList nodesMatrix; public ArrayList NodesMatrix { get { return nodesMatrix; } set { nodesMatrix = value; } } List<vertex> vertexMatrix; public List<vertex> VertexMatrix { get { return vertexMatrix; } set { vertexMatrix = value; } } List<bool> odwiedzone; public List<bool> Odwiedzone { get { return odwiedzone; } set { odwiedzone = value; } } public List<element> PriorityQueue { get { return PriorityQueue; } set { PriorityQueue = value; } } } public struct element : IComparable { public double priority { get { return priority; } set { priority = value; } } public int node { get { return node; } set { node = value; } } public element(double _prio, int _node) { priority = _prio; node = _node; } #region IComparable Members public int CompareTo(object obj) { element elem = (element)obj; return priority.CompareTo(elem.priority); } #endregion

    Read the article

  • Function-Local Static Const variable Initialization semantics.

    - by Hassan Syed
    The questions are in bold, for those that cannot be bothered reading a question in depth. This is a followup to this question. It is to do with the initialization semantics of static variables in functions. Static variables should be initialized once, and their internal state might be altered later - as I (currently) do in the linked question. However, the code in question does not require the feature to change the state of the variable later. Let me clarrify my position, since I don't require the string object's internal state to change. The code is for a trait class for meta programming, and as such would would benifit from a const char * const ptr -- thus Ideally a local cost static const variable is needed. My educated guess is that in this case the string in question will be optimally placed in memory by the link-loader, and that the code is more secure and maps to the intended semantics. This leads to the semantics of such a variable "The C++ Programming language Third Edition -- Stroustrup" does not have anything (that I could find) to say about this matter. All that is said is that the variable is initialized once when the flow of control of the thread first reaches the code. This leads me to ponder if the following code would be sensible, and if not what are the intended semantics ?. #include <iostream> const char * const GetString(const char * x_in) { static const char * const x = x_in; return x; } int main() { const char * const temp = GetString("yahoo"); std::cout << temp << std::endl; const char * const temp2 = GetString("yahoo2"); std::cout << temp2 << std::endl; } The following compiles on GCC and prints "yahoo" twice. Which is what I want -- However it might not be standards compliant (which is why I post this question). It might be more elegant to have two functions, "SetString" and "String" where the latter forwards to the first. If it is standards compliant does someone know of a templates implementation in boost (or elsewhere) ?

    Read the article

  • Explicit Type Conversion and Multiple Simple Type Specifiers

    - by James McNellis
    To value initialize an object of type T, one would do something along the lines of one of the following: T x = T(); T x((T())); My question concerns types specified by a combination of simple type specifiers, e.g., unsigned int: unsigned int x = unsigned int(); unsigned int x((unsigned int())); Visual C++ 2008 and Intel C++ Compiler 11.1 accept both of these without warnings; Comeau 4.3.10.1b2 and g++ 3.4.5 (which is, admittedly, not particularly recent) do not. According to the C++ standard (C++03 5.2.3/2, expr.type.conv): The expression T(), where T is a simple-type-specifier (7.1.5.2) for a non-array complete object type or the (possibly cv-qualified) void type, creates an rvalue of the specified type, which is value-initialized 7.1.5.2 says, "the simple type specifiers are," and follows with a list that includes unsigned and int. Therefore, given that in 5.2.3/2, "simple-type-specifier" is singular, and unsigned and int are two type specifiers, are the examples above that use unsigned int invalid? (and, if so, the followup is, is it incorrect for Microsoft and Intel to support said expressions?) This question is more out of curiosity than anything else; for all of the types specified by a combination of multiple simple type specifiers, value initialization is equivalent to zero initialization. (This question was prompted by comments in response to this answer to a question about initialization).

    Read the article

  • Class initialization issues loading java.util.LogManager in Android Dalvik VM

    - by Freddy B. Rose
    I've done changes in an Android native library and installed a new system.img file but am now getting an unrelated Error on startup. I can get past it by swallowing the error but I wanted to know if anyone can explain what the issue is. The Android implementation of Logger.java claims that it is Forcing the LogManager to be initialized since its class init code performs necessary one-time setup. But this forced initialization results in a NoClassDefFoundError. I'm thinking that it has something to do with the class not having been preloaded by Zygote yet but am not that familiar with the whole class loaders and VM business. If anyone has some insight it would be greatly appreciated. Thanks. I/Zygote ( 1253): Preloading classes... D/skia ( 1253): ------ build_power_table 1.4 D/skia ( 1253): ------ build_power_table 0.714286 W/dalvikvm( 1253): Exception Ljava/lang/StackOverflowError; thrown during Ljava/util/logging/LogManager;. W/dalvikvm( 1253): Exception Ljava/lang/NoClassDefFoundError; thrown during Ljava/security/Security;. W/dalvikvm( 1253): Exception Ljava/lang/ExceptionInInitializerError; thrown during Landroid/net/http/HttpsConnection;. E/Zygote ( 1253): Error preloading android.net.http.HttpsConnection. E/Zygote ( 1253): java.lang.ExceptionInInitializerError E/Zygote ( 1253): at java.lang.Class.classForName(Native Method) E/Zygote ( 1253): at java.lang.Class.forName(Class.java:237) E/Zygote ( 1253): at java.lang.Class.forName(Class.java:183) E/Zygote ( 1253): at com.android.internal.os.ZygoteInit.preloadClasses(ZygoteInit.java:295) E/Zygote ( 1253): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) E/Zygote ( 1253): at dalvik.system.NativeStart.main(Native Method) E/Zygote ( 1253): Caused by: java.lang.ExceptionInInitializerError E/Zygote ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:57) E/Zygote ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:56) E/Zygote ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264) E/Zygote ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84) E/Zygote ( 1253): at javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm(KeyManagerFactory.java:55) E/Zygote ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLParameters.(SSLParameters.java:142) E/Zygote ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLContextImpl.engineInit(SSLContextImpl.java:82) E/Zygote ( 1253): at android.net.http.HttpsConnection.initializeEngine(HttpsConnection.java:101) E/Zygote ( 1253): at android.net.http.HttpsConnection.(HttpsConnection.java:65) E/Zygote ( 1253): ... 6 more E/Zygote ( 1253): Caused by: java.lang.NoClassDefFoundError: java.util.logging.LogManager E/Zygote ( 1253): at java.util.logging.Logger.initHandler(Logger.java:419) E/Zygote ( 1253): at java.util.logging.Logger.log(Logger.java:1094) E/Zygote ( 1253): at java.util.logging.Logger.warning(Logger.java:906) E/Zygote ( 1253): at org.apache.harmony.luni.util.MsgHelp.loadBundle(MsgHelp.java:61) E/Zygote ( 1253): at org.apache.harmony.luni.util.Msg.getString(Msg.java:60) E/Zygote ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:316) E/Zygote ( 1253): at java.io.FilterInputStream.read(FilterInputStream.java:138) E/Zygote ( 1253): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:157) E/Zygote ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:243) E/Zygote ( 1253): at java.util.Properties.load(Properties.java:302) E/Zygote ( 1253): at java.security.Security$1.run(Security.java:80) E/Zygote ( 1253): at java.security.Security$1.run(Security.java:67) E/Zygote ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264) E/Zygote ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84) E/Zygote ( 1253): at java.security.Security.(Security.java:66) E/Zygote ( 1253): ... 15 more W/dalvikvm( 1253): threadid=3: thread exiting with uncaught exception (group=0x2aac6170)

    Read the article

  • Class initialization issues loading java.util.logging.LogManager in Android Dalvik VM

    - by Freddy B. Rose
    I've done changes in an Android native library and installed a new system.img file but am now getting an unrelated Error on startup. I can get past it by swallowing the error but I wanted to know if anyone can explain what the issue is. The Android implementation of Logger.java claims that it is Forcing the LogManager to be initialized since its class init code performs necessary one-time setup. But this forced initialization results in a NoClassDefFoundError. I'm thinking that it has something to do with the class not having been preloaded by Zygote yet but am not that familiar with the whole class loaders and VM business. If anyone has some insight it would be greatly appreciated. Thanks. I/Zygote ( 1253): Preloading classes... D/skia ( 1253): ------ build_power_table 1.4 D/skia ( 1253): ------ build_power_table 0.714286 W/dalvikvm( 1253): Exception Ljava/lang/StackOverflowError; thrown during Ljava/util/logging/LogManager;. W/dalvikvm( 1253): Exception Ljava/lang/NoClassDefFoundError; thrown during Ljava/security/Security;. W/dalvikvm( 1253): Exception Ljava/lang/ExceptionInInitializerError; thrown during Landroid/net/http/HttpsConnection;. E/Zygote ( 1253): Error preloading android.net.http.HttpsConnection. E/Zygote ( 1253): java.lang.ExceptionInInitializerError E/Zygote ( 1253): at java.lang.Class.classForName(Native Method) E/Zygote ( 1253): at java.lang.Class.forName(Class.java:237) E/Zygote ( 1253): at java.lang.Class.forName(Class.java:183) E/Zygote ( 1253): at com.android.internal.os.ZygoteInit.preloadClasses(ZygoteInit.java:295) E/Zygote ( 1253): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) E/Zygote ( 1253): at dalvik.system.NativeStart.main(Native Method) E/Zygote ( 1253): Caused by: java.lang.ExceptionInInitializerError E/Zygote ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:57) E/Zygote ( 1253): at javax.net.ssl.KeyManagerFactory$1.run(KeyManagerFactory.java:56) E/Zygote ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264) E/Zygote ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84) E/Zygote ( 1253): at javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm(KeyManagerFactory.java:55) E/Zygote ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLParameters.(SSLParameters.java:142) E/Zygote ( 1253): at org.apache.harmony.xnet.provider.jsse.SSLContextImpl.engineInit(SSLContextImpl.java:82) E/Zygote ( 1253): at android.net.http.HttpsConnection.initializeEngine(HttpsConnection.java:101) E/Zygote ( 1253): at android.net.http.HttpsConnection.(HttpsConnection.java:65) E/Zygote ( 1253): ... 6 more E/Zygote ( 1253): Caused by: java.lang.NoClassDefFoundError: java.util.logging.LogManager E/Zygote ( 1253): at java.util.logging.Logger.initHandler(Logger.java:419) E/Zygote ( 1253): at java.util.logging.Logger.log(Logger.java:1094) E/Zygote ( 1253): at java.util.logging.Logger.warning(Logger.java:906) E/Zygote ( 1253): at org.apache.harmony.luni.util.MsgHelp.loadBundle(MsgHelp.java:61) E/Zygote ( 1253): at org.apache.harmony.luni.util.Msg.getString(Msg.java:60) E/Zygote ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:316) E/Zygote ( 1253): at java.io.FilterInputStream.read(FilterInputStream.java:138) E/Zygote ( 1253): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:157) E/Zygote ( 1253): at java.io.BufferedInputStream.read(BufferedInputStream.java:243) E/Zygote ( 1253): at java.util.Properties.load(Properties.java:302) E/Zygote ( 1253): at java.security.Security$1.run(Security.java:80) E/Zygote ( 1253): at java.security.Security$1.run(Security.java:67) E/Zygote ( 1253): at java.security.AccessController.doPrivilegedImpl(AccessController.java:264) E/Zygote ( 1253): at java.security.AccessController.doPrivileged(AccessController.java:84) E/Zygote ( 1253): at java.security.Security.(Security.java:66) E/Zygote ( 1253): ... 15 more W/dalvikvm( 1253): threadid=3: thread exiting with uncaught exception (group=0x2aac6170)

    Read the article

  • (static initialization order?!) problems with factory pattern

    - by smerlin
    Why does following code raise an exception (in createObjects call to map::at) alternativly the code (and its output) can be viewed here intererestingly the code works as expected if the commented lines are uncommented with both microsoft and gcc compiler (see here), this even works with initMap as ordinary static variable instead of static getter. The only reason for this i can think of is that the order of initialization of the static registerHelper_ object (factory_helper_)and the std::map object (initMap) are wrong, however i cant see how that could happen, because the map object is constructed on first usage and thats in factory_helper_ constructor, so everything should be alright shouldnt it ? I am even more suprised that those doNothing() lines fix the issue, because that call to doNothing() would happen after the critical section (which currently fails) is passed anyway. EDIT: debugging showed, that without the call to factory_helper_.doNothing(), the constructor of factory_helper_ is never called. #include <iostream> #include <string> #include <map> #define FACTORY_CLASS(classtype) \ extern const char classtype##_name_[] = #classtype; \ class classtype : FactoryBase<classtype,classtype##_name_> namespace detail_ { class registerHelperBase { public: registerHelperBase(){} protected: static std::map<std::string, void * (*)(void)>& getInitMap() { static std::map<std::string, void * (*)(void)>* initMap = 0; if(!initMap) initMap= new std::map<std::string, void * (*)(void)>(); return *initMap; } }; template<class TParent, const char* ClassName> class registerHelper_ : registerHelperBase { static registerHelper_ help_; public: //void doNothing(){} registerHelper_(){ getInitMap()[std::string(ClassName)]=&TParent::factory_init_; } }; template<class TParent, const char* ClassName> registerHelper_<TParent,ClassName> registerHelper_<TParent,ClassName>::help_; } class Factory : detail_::registerHelperBase { private: Factory(); public: static void* createObject(const std::string& objclassname) { return getInitMap().at(objclassname)(); } }; template <class TClass, const char* ClassName> class FactoryBase { private: static detail_::registerHelper_<FactoryBase<TClass,ClassName>,ClassName> factory_helper_; static void* factory_init_(){ return new TClass();} public: friend class detail_::registerHelper_<FactoryBase<TClass,ClassName>,ClassName>; FactoryBase(){ //factory_helper_.doNothing(); } virtual ~FactoryBase(){}; }; template <class TClass, const char* ClassName> detail_::registerHelper_<FactoryBase<TClass,ClassName>,ClassName> FactoryBase<TClass,ClassName>::factory_helper_; FACTORY_CLASS(Test) { public: Test(){} }; int main(int argc, char** argv) { try { Test* test = (Test*) Factory::createObject("Test"); } catch(const std::exception& ex) { std::cerr << "caught std::exception: "<< ex.what() << std::endl; } #ifdef _MSC_VER system("pause"); #endif return 0; }

    Read the article

  • hello-1.mod.c:14: warning: missing initializer (near initialization for '__this_module.arch.unw_sec_init')

    - by Sompom
    I am trying to write a module for an sbc1651. Since the device is ARM, this requires a cross-compile. As a start, I am trying to compile the "Hello Kernel" module found here. This compiles fine on my x86 development system, but when I try to cross-compile I get the below error. /home/developer/HelloKernel/hello-1.mod.c:14: warning: missing initializer /home/developer/HelloKernel/hello-1.mod.c:14: warning: (near initialization for '__this_module.arch.unw_sec_init') Since this is in the .mod.c file, which is autogenerated I have no idea what's going on. The mod.c file seems to be generated by the module.h file. As far as I can tell, the relevant parts are the same between my x86 system's module.h and the arm kernel header's module.h. Adding to my confusion, this problem is either not googleable (by me...) or hasn't happened to anyone before. Or I'm just doing something clueless that anyone with any sense wouldn't do. The cross-compiler I'm using was supplied by Freescale (I think). I suppose it could be a problem with the compiler. Would it be worth trying to build the toolchain myself? Obviously, since this is a warning, I could ignore it, but since it's so strange, I am worried about it, and would like to at least know the cause... Thanks very much, Sompom Here are the source files hello-1.mod.c #include <linux/module.h> #include <linux/vermagic.h> #include <linux/compiler.h> MODULE_INFO(vermagic, VERMAGIC_STRING); struct module __this_module __attribute__((section(".gnu.linkonce.this_module"))) = { .name = KBUILD_MODNAME, .init = init_module, #ifdef CONFIG_MODULE_UNLOAD .exit = cleanup_module, #endif .arch = MODULE_ARCH_INIT, }; static const struct modversion_info ____versions[] __used __attribute__((section("__versions"))) = { { 0x3972220f, "module_layout" }, { 0xefd6cf06, "__aeabi_unwind_cpp_pr0" }, { 0xea147363, "printk" }, }; static const char __module_depends[] __used __attribute__((section(".modinfo"))) = "depends="; hello-1.c (modified slightly from the given link) /* hello-1.c - The simplest kernel module. * * Copyright (C) 2001 by Peter Jay Salzman * * 08/02/2006 - Updated by Rodrigo Rubira Branco <[email protected]> */ /* Kernel Programming */ #ifndef MODULE #define MODULE #endif #ifndef LINUX #define LINUX #endif #ifndef __KERNEL__ #define __KERNEL__ #endif #include <linux/module.h> /* Needed by all modules */ #include <linux/kernel.h> /* Needed for KERN_ALERT */ static int hello_init_module(void) { printk(KERN_ALERT "Hello world 1.\n"); /* A non 0 return means init_module failed; module can't be loaded.*/ return 0; } static void hello_cleanup_module(void) { printk(KERN_ALERT "Goodbye world 1.\n"); } module_init(hello_init_module); module_exit(hello_cleanup_module); MODULE_LICENSE("GPL"); Makefile export ARCH:=arm export CCPREFIX:=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-linux- export CROSS_COMPILE:=${CCPREFIX} TARGET := hello-1 WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-sign-compare -Wno-unused -Werror UNUSED_FLAGS := -std=c99 -pedantic EXTRA_CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE} KDIR ?= /home/developer/src/ltib-microsys/ltib/rpm/BUILD/linux-2.6.35.3 ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m := $(TARGET).o else # normal makefile default: clean $(MAKE) -C $(KDIR) M=$$PWD .PHONY: clean clean: -rm built-in.o -rm $(TARGET).ko -rm $(TARGET).ko.unsigned -rm $(TARGET).mod.c -rm $(TARGET).mod.o -rm $(TARGET).o -rm modules.order -rm Module.symvers endif

    Read the article

  • Hibernate Lazy initialization exception problem with Gilead in GWT 2.0 integration

    - by sylsau
    Hello, I use GWT 2.0 as UI layer on my project. On server side, I use Hibernate. For example, this is 2 domains entities that I have : public class User { private Collection<Role> roles; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "users", targetEntity = Role.class) public Collection<Role> getRoles() { return roles; } ... } public class Role { private Collection<User> users; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = User.class) public Collection<User> getUsers() { return users; } ... } On my DAO layer, I use UserDAO that extends HibernateDAOSupport from Spring. UserDAO has getAll method to return all of Users. And on my DAO service, I use UserService that uses userDAO to getAll of Users. So, when I get all of Users from UsersService, Users entities returned are detached from Hibernate session. For that reason, I don't want to use getRoles() method on Users instance that I get from my service. What I want is just to transfer my list of Users thanks to a RPC Service to be able to use others informations of Users in client side with GWT. Thus, my main problem is to be able to convert PersistentBag in Users.roles in simple List to be able to transfer via RPC the Users. To do that, I have seen that Gilead Framework could be a solution. In order to use Gilead, I have changed my domains entities. Now, they extend net.sf.gilead.pojo.gwt.LightEntity and they respect JavaBean specification. On server, I expose my services via RPC thanks to GwtRpcSpring framework (http://code.google.com/p/gwtrpc-spring/). This framework has an advice that makes easier Gilead integration. My applicationContext contains the following configuration for Gilead : <bean id="gileadAdapterAdvisor" class="org.gwtrpcspring.gilead.GileadAdapterAdvice" /> <aop:config> <aop:aspect id="gileadAdapterAspect" ref="gileadAdapterAdvisor"> <aop:pointcut id="gileadPointcut" expression="execution(public * com.google.gwt.user.client.rpc.RemoteService.*(..))" /> <aop:around method="doBasicProfiling" pointcut-ref="gileadPointcut" /> </aop:aspect> </aop:config> <bean id="proxySerializer" class="net.sf.gilead.core.serialization.GwtProxySerialization" /> <bean id="proxyStore" class="net.sf.gilead.core.store.stateless.StatelessProxyStore"> <property name="proxySerializer" ref="proxySerializer" /> </bean> <bean id="persistenceUtil" class="net.sf.gilead.core.hibernate.HibernateUtil"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean class="net.sf.gilead.core.PersistentBeanManager"> <property name="proxyStore" ref="proxyStore" /> <property name="persistenceUtil" ref="persistenceUtil" /> </bean> The code of the the method doBasicProfiling is the following : @Around("within(com.google.gwt.user.client.rpc.RemoteService..*)") public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable { if (log.isDebugEnabled()) { String className = pjp.getSignature().getDeclaringTypeName(); String methodName = className .substring(className.lastIndexOf(".") + 1) + "." + pjp.getSignature().getName(); log.debug("Wrapping call to " + methodName + " for PersistentBeanManager"); } GileadHelper.parseInputParameters(pjp.getArgs(), beanManager, RemoteServiceUtil.getThreadLocalSession()); Object retVal = pjp.proceed(); retVal = GileadHelper.parseReturnValue(retVal, beanManager); return retVal; } With that configuration, when I run my application and I use my RPC Service that gets all of Users, I obtain a lazy initialization exception from Hibernate from Users.roles. I am disappointed because I thought that Gilead would let me to serialize my domain entities even if these entities contained PersistentBag. It's not one of the goals of Gilead ? So, someone would know how to configure Gilead (with GwtRpcSpring or other solution) to be able to transfer domain entities without Lazy exception ? Thanks by advance for your help. Sylvain

    Read the article

  • How do I declare a C# Web User Control but stop it from initializing?

    - by Scott Stafford
    I have a C#/ASP.NET .aspx page that declares two controls that each represents the content of one tab. I want a query string argument (e.g., ?tab=1) to determine which of the two controls is activated. My problem is, they both go through the initialization events and populate their child controls, wasting CPU resources and slowing the response time. Is it possible to deactivate them somehow so they don't go through any initialization? My .aspx page looks like this: <% if (TabId == 0) { %> <my:usercontroltabone id="ctrl1" runat="server" /> <% } else if (TabId == 1) { %> <my:usercontroltabtwo id="ctrl2" runat="server" /> <% } %> And that part works fine. I assumed the that <%'s would have meant the control wouldn't actually be declared and so wouldn't initialize, but that isn't so...

    Read the article

  • Is C++11 Uniform Initialization a replacement for the old style syntax?

    - by Robert Dailey
    I understand that C++11's uniform initialization solves some syntactical ambiguity in the language, but in a lot of Bjarne Stroustrup's presentations (particularly those during the GoingNative 2012 talks), his examples primarily use this syntax now whenever he is constructing objects. Is it recommended now to use uniform initialization in all cases? What should the general approach be for this new feature as far as coding style goes and general usage? What are some reasons to not use it? Note that in my mind I'm thinking primarily of object construction as my use case, but if there are other scenarios to consider please let me know.

    Read the article

  • Set the JAXB context factory initialization class to be used

    - by user1902288
    I have updated our projects (Java EE based running on Websphere 8.5) to use a new release of a company internal framework (and Ejb 3.x deployment descriptors rather than the 2.x ones). Since then my integration Tests fail with the following exception: [java.lang.ClassNotFoundException: com.ibm.xml.xlxp2.jaxb.JAXBContextFactory] I can build the application with the previous framework release and everything works fine. While debugging i noticed that within the ContextFinder (javax.xml.bind) there are two different behaviours: Previous Version (Everything works just fine): None of the different places brings up a factory class so the default factory class gets loaded which is com.sun.xml.internal.bind.v2.ContextFactory (defined as String constant within the class). Upgraded Version (ClassNotFound): There is a resource "META-INF/services/javax.xml.bind.JAXBContext" beeing loaded successfully and the first line read makes the ContextFinder attempt to load "com.ibm.xml.xlxp2.jaxb.JAXBContextFactory" which causes the error. I now have two questions: What sort is that resource? Because inside our EAR there is two WARs and none of those two contains a folder services in its META-INF directory. Where could that value be from otherwise? Because a filediff showed me no new or changed properties files. No need to say i am going to read all about the JAXB configuration possibilities but if you have first insights on what could have gone wrong or help me out with that resource (is it a real file i have to look for?) id appreciate a lot. Many Thanks! EDIT (according to comments Input/Questions): Out of curiosity, does your framework include JAXB JARs? Did the old version of your framework include jaxb.properties? Indeed (i am a bit surprised) the framework has a customized eclipselink-2.4.1-.jar inside the EAR that includes both a JAXB implementation and a jaxb.properties file that shows the following entry in both versions (the one that finds the factory as well as in the one that throws the exception): javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory I think this is has nothing to do with the current issue since the jar stayed exactly the same in both EARs (the one that runs/ the one with the expection) It's also not clear to me why the old version of the framework was ever selecting the com.sun implementation There is a class javax.xml.bind.ContextFinder which is responsible for initializing the JAXBContextFactory. This class searches various placess for the existance of a jaxb.properties file or a "javax.xml.bind.JAXBContext" resource. If ALL of those places dont show up which Context Factory to use there is a deault factory loaded which is hardcoded in the class itself: private static final String PLATFORM_DEFAULT_FACTORY_CLASS = "com.sun.xml.internal.bind.v2.ContextFactory"; Now back to my problem: Building with the previous version of the framework (and EJB 2.x deployment descriptors) everything works fine). While debugging i can see that there is no configuration found and thatfore above mentioned default factory is loaded. Building with the new version of the framework (and EJB 3.x deployment descriptors so i can deploy) ONLY A TESTCASE fails but the rest of the functionality works (like i can send requests to our webservice and they dont trigger any errors). While debugging i can see that there is a configuration found. This resource is named "META-INF/services/javax.xml.bind.JAXBContext". Here are the most important lines of how this resource leads to the attempt to load 'com.ibm.xml.xlxp2.jaxb.JAXBContextFactory' which then throws the ClassNotFoundException. This is simplified source of the mentioned javax.xml.bind.ContextFinder class: URL resourceURL = ClassLoader.getSystemResource("META-INF/services/javax.xml.bind.JAXBContext"); BufferedReader r = new BufferedReader(new InputStreamReader(resourceURL.openStream(), "UTF-8")); String factoryClassName = r.readLine().trim(); The field factoryClassName now has the value 'com.ibm.xml.xlxp2.jaxb.JAXBContextFactory' (The day i understand how to format source code on stackoverflow will be my biggest step ahead.... sorry for the formatting after 20 mins it still looks the same :() Because this has become a super lager question i will also add a bounty :)

    Read the article

  • micro-SD card initialization using SPI interface

    - by Ron
    I'm using a micro-SD card in an embedded design. The card is connected to a microcontroller using the SPI interface. It worked fine for all cards I've used before, but now my new card will not initialize. The card is a Transcend 2GB micro-SD card (TS2GUSD). After sending the initial clock train to switch to SPI mode I do the following: 1) CMD0 (Argument 0, CRC 0x95) - Response 0x01 - OK 2) CMD8 (Argument 0x000001AA, CRC 0x87) - Response 0x01 0x000001AA - Means it's SDC V2+ card, the Voltage range 2.7V~3.6V is supported - OK Then I should send the ACMD41 command, but when sending the CMD55 (argument 0, CRC 0) that must precede CMD41, I get response 0x05 - Illegal Command. I've also tried to send CMD1 (for MMC cards), but it gives a similar Illegal Command response. The code works fine with my Sandisk 2GB micro-SD card. Does anyone have any idea? Thanks, -Ron-

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >