qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
6,508,519
I want a user to be able to access objects (could be JSON or XML) using a restful syntax rather than having to use query strings. So instead of `http://mywebsite.com/objects/get=obj1&get=obj2&get=someotherobject/` they could do something like `http://mywebsite.com/objects/obj1/obj2/` and the xml/JSON would be returned. They could list the objects in any order just like you can with query strings. In asp.net mvc you map a route like so: ``` routes.MapRoute( "MyRoute", "MyController/MyAction/{param}", new { controller = "MyController", action = "MyAction", param = "" } ); ``` I would want to do something like: ``` routes.MapRoute( "MyRoute", "MyController/MyAction/{params}", new { controller = "MyController", action = "MyAction", params = [] } ); ``` where the `params` array would contain each get.
2011/06/28
[ "https://Stackoverflow.com/questions/6508519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277140/" ]
You need to install [Microsoft SQL Server Compact 4.0](http://www.microsoft.com/download/en/details.aspx?id=17876).
<http://forums.asp.net/t/1679349.aspx/1> CypressBender Re: Unable to retrieve metadata for \* Unable to find the requested .Net Framework Data Provider.... Aug 08, 2011 07:44 PM|LINK I installed Microsoft SQL Server Compact 4.0, and that fixed the problem for me. <http://www.microsoft.com/download/en/details.aspx?id=17876>
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
You can use `selectTextOnFocus` to achieve this. This will ensure that all text inside the `TextInput` is highlighted when the field is tapped into.
I don't know if there's a better way, but I found a workaround. The text has to be focused first. Here's an example ``` import React { Component } from 'react'; import { Button, TextInput, findNodeHandle } from 'react-native'; import TextInputState from 'react-native/lib/TextInputState'; class MyComponent extends Component { render() { return ( <View style={{ flex: 1, }}> <Button title="select text" onPress={() => { TextInputState.focusTextInput(findNodeHandle(this.inputRef)) }} </ <TextInput selectTextOnFocus ref={ref => this.inputRef = ref} /> </View> ); } } ```
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
You can use `selectTextOnFocus` to achieve this. This will ensure that all text inside the `TextInput` is highlighted when the field is tapped into.
`this.inputRef.focus()` sets focus to the `TextInput` component, and then the flag you set in the attributes `selectTextOnFocus` does the rest.
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
You can use `selectTextOnFocus` to achieve this. This will ensure that all text inside the `TextInput` is highlighted when the field is tapped into.
I'm here to share my findings. In a List, you might encounter that `selectTextOnFocus` is broken. In this case you can use this method `selection`. From React-Native I found this: [![enter image description here](https://i.stack.imgur.com/wYR4O.png)](https://i.stack.imgur.com/wYR4O.png) In my case I had trouble with the `selectTextOnFocus` prop in a list. So I had to add a `debounce` function to work with `selection` prop. ``` const [shouldSelect, setShouldSelect] = useState(undefined); const onFocus = () =>{ setShouldSelect({start:0, end:String(text).length}); } const focus = useCallback(_.debounce(onFocus,500),[shouldSelect]); <TextInput selection={shouldSelect} onBlur={()=>setShouldSelect(undefined)} onFocus={()=>focus()}// this is important selectTextOnFocus ref={r=>onRef(r)} keyboardType={'number-pad'} autoCorrect={false} blurOnSubmit={false} returnKeyType={'done'} underlineColorIos={'transparent'} underlineColorAndroid={'white'} allowFontScaling={false} value={String(text)} /> ```
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
Actually you can, by accessing textInput's method by refs. `<TextInput ref={input => this.myInput = input} selectTextOnFocus style={{height: 100, width: 100}} defaultValue='Hey there' />` and where you want to select all text programmatically you can `this.myInput.focus()` works on iOS, not sure about android. --- --- Reference : <http://facebook.github.io/react-native/releases/0.45/docs/textinput.html#selectionstate>
I don't know if there's a better way, but I found a workaround. The text has to be focused first. Here's an example ``` import React { Component } from 'react'; import { Button, TextInput, findNodeHandle } from 'react-native'; import TextInputState from 'react-native/lib/TextInputState'; class MyComponent extends Component { render() { return ( <View style={{ flex: 1, }}> <Button title="select text" onPress={() => { TextInputState.focusTextInput(findNodeHandle(this.inputRef)) }} </ <TextInput selectTextOnFocus ref={ref => this.inputRef = ref} /> </View> ); } } ```
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
Actually you can, by accessing textInput's method by refs. `<TextInput ref={input => this.myInput = input} selectTextOnFocus style={{height: 100, width: 100}} defaultValue='Hey there' />` and where you want to select all text programmatically you can `this.myInput.focus()` works on iOS, not sure about android. --- --- Reference : <http://facebook.github.io/react-native/releases/0.45/docs/textinput.html#selectionstate>
`this.inputRef.focus()` sets focus to the `TextInput` component, and then the flag you set in the attributes `selectTextOnFocus` does the rest.
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
Actually you can, by accessing textInput's method by refs. `<TextInput ref={input => this.myInput = input} selectTextOnFocus style={{height: 100, width: 100}} defaultValue='Hey there' />` and where you want to select all text programmatically you can `this.myInput.focus()` works on iOS, not sure about android. --- --- Reference : <http://facebook.github.io/react-native/releases/0.45/docs/textinput.html#selectionstate>
I'm here to share my findings. In a List, you might encounter that `selectTextOnFocus` is broken. In this case you can use this method `selection`. From React-Native I found this: [![enter image description here](https://i.stack.imgur.com/wYR4O.png)](https://i.stack.imgur.com/wYR4O.png) In my case I had trouble with the `selectTextOnFocus` prop in a list. So I had to add a `debounce` function to work with `selection` prop. ``` const [shouldSelect, setShouldSelect] = useState(undefined); const onFocus = () =>{ setShouldSelect({start:0, end:String(text).length}); } const focus = useCallback(_.debounce(onFocus,500),[shouldSelect]); <TextInput selection={shouldSelect} onBlur={()=>setShouldSelect(undefined)} onFocus={()=>focus()}// this is important selectTextOnFocus ref={r=>onRef(r)} keyboardType={'number-pad'} autoCorrect={false} blurOnSubmit={false} returnKeyType={'done'} underlineColorIos={'transparent'} underlineColorAndroid={'white'} allowFontScaling={false} value={String(text)} /> ```
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
I don't know if there's a better way, but I found a workaround. The text has to be focused first. Here's an example ``` import React { Component } from 'react'; import { Button, TextInput, findNodeHandle } from 'react-native'; import TextInputState from 'react-native/lib/TextInputState'; class MyComponent extends Component { render() { return ( <View style={{ flex: 1, }}> <Button title="select text" onPress={() => { TextInputState.focusTextInput(findNodeHandle(this.inputRef)) }} </ <TextInput selectTextOnFocus ref={ref => this.inputRef = ref} /> </View> ); } } ```
`this.inputRef.focus()` sets focus to the `TextInput` component, and then the flag you set in the attributes `selectTextOnFocus` does the rest.
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
I don't know if there's a better way, but I found a workaround. The text has to be focused first. Here's an example ``` import React { Component } from 'react'; import { Button, TextInput, findNodeHandle } from 'react-native'; import TextInputState from 'react-native/lib/TextInputState'; class MyComponent extends Component { render() { return ( <View style={{ flex: 1, }}> <Button title="select text" onPress={() => { TextInputState.focusTextInput(findNodeHandle(this.inputRef)) }} </ <TextInput selectTextOnFocus ref={ref => this.inputRef = ref} /> </View> ); } } ```
I'm here to share my findings. In a List, you might encounter that `selectTextOnFocus` is broken. In this case you can use this method `selection`. From React-Native I found this: [![enter image description here](https://i.stack.imgur.com/wYR4O.png)](https://i.stack.imgur.com/wYR4O.png) In my case I had trouble with the `selectTextOnFocus` prop in a list. So I had to add a `debounce` function to work with `selection` prop. ``` const [shouldSelect, setShouldSelect] = useState(undefined); const onFocus = () =>{ setShouldSelect({start:0, end:String(text).length}); } const focus = useCallback(_.debounce(onFocus,500),[shouldSelect]); <TextInput selection={shouldSelect} onBlur={()=>setShouldSelect(undefined)} onFocus={()=>focus()}// this is important selectTextOnFocus ref={r=>onRef(r)} keyboardType={'number-pad'} autoCorrect={false} blurOnSubmit={false} returnKeyType={'done'} underlineColorIos={'transparent'} underlineColorAndroid={'white'} allowFontScaling={false} value={String(text)} /> ```
44,718,405
Is there a way to programmatically highlight/select text that is inside a TextInput component?
2017/06/23
[ "https://Stackoverflow.com/questions/44718405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890903/" ]
I'm here to share my findings. In a List, you might encounter that `selectTextOnFocus` is broken. In this case you can use this method `selection`. From React-Native I found this: [![enter image description here](https://i.stack.imgur.com/wYR4O.png)](https://i.stack.imgur.com/wYR4O.png) In my case I had trouble with the `selectTextOnFocus` prop in a list. So I had to add a `debounce` function to work with `selection` prop. ``` const [shouldSelect, setShouldSelect] = useState(undefined); const onFocus = () =>{ setShouldSelect({start:0, end:String(text).length}); } const focus = useCallback(_.debounce(onFocus,500),[shouldSelect]); <TextInput selection={shouldSelect} onBlur={()=>setShouldSelect(undefined)} onFocus={()=>focus()}// this is important selectTextOnFocus ref={r=>onRef(r)} keyboardType={'number-pad'} autoCorrect={false} blurOnSubmit={false} returnKeyType={'done'} underlineColorIos={'transparent'} underlineColorAndroid={'white'} allowFontScaling={false} value={String(text)} /> ```
`this.inputRef.focus()` sets focus to the `TextInput` component, and then the flag you set in the attributes `selectTextOnFocus` does the rest.
13,334,933
I'm trying to print a array to a particular id in my page. I have the array print out just fine but cannot figure out how to get it to print to that id. This Prints what i want out: ``` for(var i=0;i<playerCards.length;i++){ document.write('<img src="images/cards/card-' + playerCards[i] + '.jpg" width="58" height="79" alt="playercards" /> '); } ``` I'm trying to get it to work like this: ``` document.getElementById("player").innerHTML="THE ABOVE LOOP"; ``` I have tried combining to two and moving things around but cant seem to figure out how to print it out. Thanks!
2012/11/11
[ "https://Stackoverflow.com/questions/13334933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1218333/" ]
``` var str = ''; for(var i = 0; i < playerCards.length; i++){ str += '<img src="images/cards/card-' + playerCards[i] + '.jpg" width="58" height="79" alt="playercards" />'; } document.getElementById("player").innerHTML = str; ```
Here: ``` document.getElementById( 'player' ).innerHTML = playerCards.map(function ( card ) { return '<img src="images/cards/card-' +card + '.jpg" width="58" height="79" alt="playercards"> '; }).join( '' ); ``` Note that, in order to be able to select the `#player` element, you have to execute this code *after* the DOM is ready by putting it inside a "DOMContentLoaded" event handler.
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
You perform the check for every single item of the array, including the first `4`, the second `4` and so on. That's why it just doesn't stop and it prints the message multiple times per duplicated element. You're saying you cannot use a `Set` and that you don't want to sort your data. My suggestion is that you loop over the array and add each duplicated item to a list. Make sure you check whether the item has already been added. (or use a `Set` :) ) Then loop over the list and print those items.
This problem is much simpler and likely faster to solve using a collection. However, as requested here's an answer that uses "just simple array[s]" and no sorting. I've tried not to change your code too much but I refuse to leak resources in the case of an exception. ``` import java.io.*; import java.util.Arrays; import java.util.Scanner; class Average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; int flag = -1; File myFile = new File("num.txt"); try (Scanner Scan = new Scanner(myFile)) { while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } } try (Scanner Scan = new Scanner(myFile)) { System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } } for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); //copy every duplicate int[] dupesOnly = new int[numOfLines]; int dupesOnlyIndex = 0; for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { dupesOnly[dupesOnlyIndex++] = buffer[i]; //System.out.println(buffer[k]); } } } //mark all but first occurrence of dupe boolean[] skip = new boolean[dupesOnlyIndex]; //Inits to false for (int i = 0; i < dupesOnlyIndex; i++) { for(int k=i+1; k<buffer.length; k++) { if(dupesOnly[k] == dupesOnly[i]) { skip[k] = true; } } } //skip elements marked as extra dupes int[] dupesUnique = new int[dupesOnlyIndex]; int dupesUniqueIndex = 0; for (int i = 0; i < dupesOnlyIndex; i++) { if (skip[i] == false) { dupesUnique[dupesUniqueIndex++] = dupesOnly[i]; } } //trim to size int[] dupesReport = new int[dupesUniqueIndex]; for (int i = 0; i < dupesReport.length; i++) { dupesReport[i] = dupesUnique[i]; } System.out.println("Dupes: " + Arrays.toString(dupesReport)); } } ``` Input file "num.txt" (numbers separated by newlines not commas): ``` 1, 2, 3, 4, 5, 6, 7, 2, 1, 7, 9, 1, 1, 3 ``` Output: ``` Number Of Lines: 14 Sum: 91 Mean: 6 Dupes: [1, 2, 3, 7] ```
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
I would use a `HashMap` to store the value I encounter in the array, with the count as a value. So if you encounter a 4, you would look it up in the `HashMap`, if it doesn't exist, you would add it with a value of 1, otherwise increment the value returned. You can the loop over the `HashMap` and get all the values and print the number of duplicates encountered in the array.
``` Integer[] ints = {1, 1, 2, 3, 4}; System.out.println(new HashSet<Integer>(Arrays.asList(ints))); ``` Output: [1, 2, 3, 4]
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
You perform the check for every single item of the array, including the first `4`, the second `4` and so on. That's why it just doesn't stop and it prints the message multiple times per duplicated element. You're saying you cannot use a `Set` and that you don't want to sort your data. My suggestion is that you loop over the array and add each duplicated item to a list. Make sure you check whether the item has already been added. (or use a `Set` :) ) Then loop over the list and print those items.
``` Integer[] ints = {1, 1, 2, 3, 4}; System.out.println(new HashSet<Integer>(Arrays.asList(ints))); ``` Output: [1, 2, 3, 4]
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
I would use a `HashMap` to store the value I encounter in the array, with the count as a value. So if you encounter a 4, you would look it up in the `HashMap`, if it doesn't exist, you would add it with a value of 1, otherwise increment the value returned. You can the loop over the `HashMap` and get all the values and print the number of duplicates encountered in the array.
This problem is much simpler and likely faster to solve using a collection. However, as requested here's an answer that uses "just simple array[s]" and no sorting. I've tried not to change your code too much but I refuse to leak resources in the case of an exception. ``` import java.io.*; import java.util.Arrays; import java.util.Scanner; class Average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; int flag = -1; File myFile = new File("num.txt"); try (Scanner Scan = new Scanner(myFile)) { while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } } try (Scanner Scan = new Scanner(myFile)) { System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } } for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); //copy every duplicate int[] dupesOnly = new int[numOfLines]; int dupesOnlyIndex = 0; for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { dupesOnly[dupesOnlyIndex++] = buffer[i]; //System.out.println(buffer[k]); } } } //mark all but first occurrence of dupe boolean[] skip = new boolean[dupesOnlyIndex]; //Inits to false for (int i = 0; i < dupesOnlyIndex; i++) { for(int k=i+1; k<buffer.length; k++) { if(dupesOnly[k] == dupesOnly[i]) { skip[k] = true; } } } //skip elements marked as extra dupes int[] dupesUnique = new int[dupesOnlyIndex]; int dupesUniqueIndex = 0; for (int i = 0; i < dupesOnlyIndex; i++) { if (skip[i] == false) { dupesUnique[dupesUniqueIndex++] = dupesOnly[i]; } } //trim to size int[] dupesReport = new int[dupesUniqueIndex]; for (int i = 0; i < dupesReport.length; i++) { dupesReport[i] = dupesUnique[i]; } System.out.println("Dupes: " + Arrays.toString(dupesReport)); } } ``` Input file "num.txt" (numbers separated by newlines not commas): ``` 1, 2, 3, 4, 5, 6, 7, 2, 1, 7, 9, 1, 1, 3 ``` Output: ``` Number Of Lines: 14 Sum: 91 Mean: 6 Dupes: [1, 2, 3, 7] ```
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
Just add the number you will find duplicated to some structure like `HashSet` or `HashMap` so you can find it later when you will detect another duplication. ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { Integer intObj = new Integer(buffer[k]); if (!printed.contains(intObj)) { System.out.println(buffer[k]); printed.add(intObj); } break; } } } ``` **Better O(n) alghorithm:** ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { if (!printed.add(new Integer(buffer[i])) { System.out.println(buffer[i]); } } ```
I would use a `HashMap` to store the value I encounter in the array, with the count as a value. So if you encounter a 4, you would look it up in the `HashMap`, if it doesn't exist, you would add it with a value of 1, otherwise increment the value returned. You can the loop over the `HashMap` and get all the values and print the number of duplicates encountered in the array.
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
Just add the number you will find duplicated to some structure like `HashSet` or `HashMap` so you can find it later when you will detect another duplication. ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { Integer intObj = new Integer(buffer[k]); if (!printed.contains(intObj)) { System.out.println(buffer[k]); printed.add(intObj); } break; } } } ``` **Better O(n) alghorithm:** ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { if (!printed.add(new Integer(buffer[i])) { System.out.println(buffer[i]); } } ```
This problem is much simpler and likely faster to solve using a collection. However, as requested here's an answer that uses "just simple array[s]" and no sorting. I've tried not to change your code too much but I refuse to leak resources in the case of an exception. ``` import java.io.*; import java.util.Arrays; import java.util.Scanner; class Average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; int flag = -1; File myFile = new File("num.txt"); try (Scanner Scan = new Scanner(myFile)) { while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } } try (Scanner Scan = new Scanner(myFile)) { System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } } for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); //copy every duplicate int[] dupesOnly = new int[numOfLines]; int dupesOnlyIndex = 0; for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { dupesOnly[dupesOnlyIndex++] = buffer[i]; //System.out.println(buffer[k]); } } } //mark all but first occurrence of dupe boolean[] skip = new boolean[dupesOnlyIndex]; //Inits to false for (int i = 0; i < dupesOnlyIndex; i++) { for(int k=i+1; k<buffer.length; k++) { if(dupesOnly[k] == dupesOnly[i]) { skip[k] = true; } } } //skip elements marked as extra dupes int[] dupesUnique = new int[dupesOnlyIndex]; int dupesUniqueIndex = 0; for (int i = 0; i < dupesOnlyIndex; i++) { if (skip[i] == false) { dupesUnique[dupesUniqueIndex++] = dupesOnly[i]; } } //trim to size int[] dupesReport = new int[dupesUniqueIndex]; for (int i = 0; i < dupesReport.length; i++) { dupesReport[i] = dupesUnique[i]; } System.out.println("Dupes: " + Arrays.toString(dupesReport)); } } ``` Input file "num.txt" (numbers separated by newlines not commas): ``` 1, 2, 3, 4, 5, 6, 7, 2, 1, 7, 9, 1, 1, 3 ``` Output: ``` Number Of Lines: 14 Sum: 91 Mean: 6 Dupes: [1, 2, 3, 7] ```
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
Just add the number you will find duplicated to some structure like `HashSet` or `HashMap` so you can find it later when you will detect another duplication. ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { Integer intObj = new Integer(buffer[k]); if (!printed.contains(intObj)) { System.out.println(buffer[k]); printed.add(intObj); } break; } } } ``` **Better O(n) alghorithm:** ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { if (!printed.add(new Integer(buffer[i])) { System.out.println(buffer[i]); } } ```
Using the **apache commons** CollectionUtils.getCardinalityMap(collection): ``` final Integer[] buffer = {1, 2, 3, 4, 5, 6, 7, 2, 1, 7, 9, 1, 1, 3}; final List<Integer> list = Arrays.asList(buffer); final Map<Integer, Integer> cardinalityMap = CollectionUtils.getCardinalityMap(list); for (final Map.Entry<Integer, Integer> entry: cardinalityMap.entrySet()) { if (entry.getValue() > 1) { System.out.println(entry.getKey()); } } ``` toString() of cardinalityMap looks like this after the init: ``` {1=4, 2=2, 3=2, 4=1, 5=1, 6=1, 7=2, 9=1} ``` Using **standard java**: ``` final Integer[] buffer = {1, 2, 3, 4, 5, 6, 7, 2, 1, 7, 9, 1, 1, 3}; final List<Integer> list = Arrays.asList(buffer); final Set<Integer> set = new LinkedHashSet<Integer>(list); for (final Integer element: set) { if (Collections.frequency(list, element) > 1) { System.out.println(element); } } ```
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
Just add the number you will find duplicated to some structure like `HashSet` or `HashMap` so you can find it later when you will detect another duplication. ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { Integer intObj = new Integer(buffer[k]); if (!printed.contains(intObj)) { System.out.println(buffer[k]); printed.add(intObj); } break; } } } ``` **Better O(n) alghorithm:** ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { if (!printed.add(new Integer(buffer[i])) { System.out.println(buffer[i]); } } ```
``` Integer[] ints = {1, 1, 2, 3, 4}; System.out.println(new HashSet<Integer>(Arrays.asList(ints))); ``` Output: [1, 2, 3, 4]
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
I would use a `HashMap` to store the value I encounter in the array, with the count as a value. So if you encounter a 4, you would look it up in the `HashMap`, if it doesn't exist, you would add it with a value of 1, otherwise increment the value returned. You can the loop over the `HashMap` and get all the values and print the number of duplicates encountered in the array.
Using the **apache commons** CollectionUtils.getCardinalityMap(collection): ``` final Integer[] buffer = {1, 2, 3, 4, 5, 6, 7, 2, 1, 7, 9, 1, 1, 3}; final List<Integer> list = Arrays.asList(buffer); final Map<Integer, Integer> cardinalityMap = CollectionUtils.getCardinalityMap(list); for (final Map.Entry<Integer, Integer> entry: cardinalityMap.entrySet()) { if (entry.getValue() > 1) { System.out.println(entry.getKey()); } } ``` toString() of cardinalityMap looks like this after the init: ``` {1=4, 2=2, 3=2, 4=1, 5=1, 6=1, 7=2, 9=1} ``` Using **standard java**: ``` final Integer[] buffer = {1, 2, 3, 4, 5, 6, 7, 2, 1, 7, 9, 1, 1, 3}; final List<Integer> list = Arrays.asList(buffer); final Set<Integer> set = new LinkedHashSet<Integer>(list); for (final Integer element: set) { if (Collections.frequency(list, element) > 1) { System.out.println(element); } } ```
29,867,935
I am trying to loop through my array and find all the numbers that are repeating more than once: E.G: if there is `1 1 2 3 4` It should print saying "1 repeats more than once" Here is my code and so far what I have tried, however it prints all duplicates and keep going, if there is `4 4 4 4 3 6 5 6 9`, it will print all the 4's but i dont want that: ``` class average { public static void main(String[] args) throws IOException { int numOfLines = 0; int sum = 0, mean = 0, median = 0, lq = 0, uq = 0; int[] buffer; File myFile = new File("num.txt"); Scanner Scan = new Scanner(myFile); while(Scan.hasNextLine()) { Scan.nextLine(); numOfLines++; } Scan.close(); Scan = new Scanner(myFile); System.out.println("Number Of Lines: " + numOfLines); buffer = new int[numOfLines]; for(int i=0; i<numOfLines; i++) { buffer[i] = Scan.nextInt(); } Scan.close(); Scan = new Scanner(myFile); for(int i=0; i<buffer.length; i++) { sum = sum+i; mean = sum/numOfLines; } System.out.println("Sum: " + sum); System.out.println("Mean: " + mean); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { System.out.println(buffer[k]); } } } ```
2015/04/25
[ "https://Stackoverflow.com/questions/29867935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4699450/" ]
Just add the number you will find duplicated to some structure like `HashSet` or `HashMap` so you can find it later when you will detect another duplication. ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { for(int k=i+1; k<buffer.length; k++) { if(buffer[k] == buffer[i]) { Integer intObj = new Integer(buffer[k]); if (!printed.contains(intObj)) { System.out.println(buffer[k]); printed.add(intObj); } break; } } } ``` **Better O(n) alghorithm:** ```java Set<Integer> printed = new HashSet<Integer>(); for(int i=0; i<buffer.length; i++) { if (!printed.add(new Integer(buffer[i])) { System.out.println(buffer[i]); } } ```
You perform the check for every single item of the array, including the first `4`, the second `4` and so on. That's why it just doesn't stop and it prints the message multiple times per duplicated element. You're saying you cannot use a `Set` and that you don't want to sort your data. My suggestion is that you loop over the array and add each duplicated item to a list. Make sure you check whether the item has already been added. (or use a `Set` :) ) Then loop over the list and print those items.
20,270,245
Is it possible using jQuery to select a `<tr>` (which I have no class target to) right before another `<tr>` which I can target with a class '`active`'. The list can be displayed in a random order, below is an example, so I can't use `nth` to target where it falls here, it needs to be based on the superseding `<tr class='active'>` For example ``` <tr></tr> <tr></tr> <tr></tr> <tr></tr> // this is the one I want to be able to select. <tr class='active'></tr> <tr></tr> ``` Thanks
2013/11/28
[ "https://Stackoverflow.com/questions/20270245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1176352/" ]
Try this: ``` var apiKey = '6b5c02819a985881e46287c6507a9800'; var lati = 50; var longi = 25; var url = 'https://api.forecast.io/forecast/' + apiKey + '/' + lati + ',' + longi + '?callback=?&units=ca'; var fetchForecast = function () { var counter = 0; var skycons = new Skycons({ "color": "#6c5848" }); $.getJSON(url, function (data) { var icon = data.currently.icon; var tempC = data.currently.temperature; var tempCfeel = data.currently.apparentTemperature; // Icon skycons.set( 'icon', icon ); // this line doesn't work //skycons.set('icon', Skycons.SNOW); // this line works // Temperature $('#temp').html(tempC.toFixed(1) + ' &deg;C / feels like ' + tempCfeel.toFixed(1) + ' &deg;C'); counter++; $('#counter').html(counter + ' API calls'); skycons.play(); }); }; setInterval(function(){ fetchForecast(); }, 1000); ``` The counter is busted but check the console, its firing requests every second
When using the string from Forecast.io you have to enclose it in quotes. Where you are using `icon` which substitutes something like `partly-cloudy-night`, when you pass it into sky cons it has to be in quotes. Hope that makes sense.
20,270,245
Is it possible using jQuery to select a `<tr>` (which I have no class target to) right before another `<tr>` which I can target with a class '`active`'. The list can be displayed in a random order, below is an example, so I can't use `nth` to target where it falls here, it needs to be based on the superseding `<tr class='active'>` For example ``` <tr></tr> <tr></tr> <tr></tr> <tr></tr> // this is the one I want to be able to select. <tr class='active'></tr> <tr></tr> ``` Thanks
2013/11/28
[ "https://Stackoverflow.com/questions/20270245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1176352/" ]
Try this: ``` var apiKey = '6b5c02819a985881e46287c6507a9800'; var lati = 50; var longi = 25; var url = 'https://api.forecast.io/forecast/' + apiKey + '/' + lati + ',' + longi + '?callback=?&units=ca'; var fetchForecast = function () { var counter = 0; var skycons = new Skycons({ "color": "#6c5848" }); $.getJSON(url, function (data) { var icon = data.currently.icon; var tempC = data.currently.temperature; var tempCfeel = data.currently.apparentTemperature; // Icon skycons.set( 'icon', icon ); // this line doesn't work //skycons.set('icon', Skycons.SNOW); // this line works // Temperature $('#temp').html(tempC.toFixed(1) + ' &deg;C / feels like ' + tempCfeel.toFixed(1) + ' &deg;C'); counter++; $('#counter').html(counter + ' API calls'); skycons.play(); }); }; setInterval(function(){ fetchForecast(); }, 1000); ``` The counter is busted but check the console, its firing requests every second
i have same problem i was fix it with set string type of wheater. ``` var icon = String(data.currently.icon); ```
60,949,620
Below is REACT code for details page Ticket is a primary object, and what i want to do is when downloading add the ticket name as .pdf filename. So i need a solution to pass the concrete ticket name to the handleDownload function In the render section there are no problem declaring ticket.ticketName etc. But with onClick the problem arises. ``` type TicketProps = TicketStore.TicketState & typeof TicketStore.actionCreators & RouteComponentProps<{ticketId: string}>; class Ticket extends React.PureComponent<TicketProps> { public componentDidMount() { this.ensureDataFetched(); } private ensureDataFetched(){ this.props.requestTicket(+this.props.match.params.ticketId); } handleDownload = () =>{ Axios.get(`${apiUrl}/api/tickets/download/${this.props.match.params.ticketId}`,{responseType: 'arraybuffer', headers: { "Content-Type": 'application/pdf' } }).then((response) => { const url = window.URL.createObjectURL(new Blob([response.data])); const link = document.createElement('a'); link.href = url; link.setAttribute('download', "test"+.pdf"); document.body.appendChild(link); link.click(); }); } public render() { let ticket = this.props.ticket; if(this.props.isLoading){ return <span>Laen andmeid...</span>; } if (ticket === undefined) { return <h1>Piletit ei leitud</h1>; } let name = ticket.ticketName return ( <React.Fragment> <h3>Üritus: {ticket.ticketName}</h3> <Table striped hover size="sm"> <tbody> <tr> <td className="details">Asukoht:</td> <td>{ticket.eventLocation}</td> </tr> <tr> <td className="details">Kuupäev:</td> <td>{ticket.eventDate}</td> </tr> <tr> <td className="details">Lisainfo:</td> <td>{ticket.extraInfo}</td> </tr> <tr> <td className="details">Pilet:</td> <td>{ticket.pdfTicket}</td> </tr> </tbody> </Table> <Button onClick={this.handleDownload}>Lae alla</Button> <Popup trigger={<button className="btn btn-primary">Show location on map</button>} position="bottom left"> <div><Maps aadress={ticket.eventLocation}></Maps>></div> </Popup> <Link to='../tickets'> <Button color='primary' onClick={()=>{}}> Tagasi </Button> </Link> <br></br> </React.Fragment> ); } } export default connect( (state: ApplicationState) => state.ticket, TicketStore.actionCreators )(Ticket as any); ``` I am getting parsing error after ticket? Any thoughts? Thanks
2020/03/31
[ "https://Stackoverflow.com/questions/60949620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13101436/" ]
you should get more information how to access fields, register and other data in typoscript. if you have a property you mostly can modify the way to get other information than a constant text. In your example it is the `key` property where constants are not meaningful. if you want to access a field of the 'current' record/data you just use `key.field = fieldname` if it is other data you modify it to `key.data = register:registername` accessing a field can be done with `key.data = field:fieldname` If you want these data connected to other information you could use a wrap: ``` key.data = register:registername key.wrap = prefix- | -suffix ``` Notice: the parts of the wrap are trimmed before they are connected another way would be an inline notation where you even can use multiple values: ``` key = {register:registername}-with-{field:fieldname} key.insertData = 1 ``` here you have two replacements. each has to be wrapped in braces `{}` and you need to tell TYPO3 that there are replacements to do: `insertData = 1` --- special case `TEXT`object: ``` 10 = TEXT 10.value = constant Text 20 = TEXT 20.field = fieldname 30 = TEXT 30.data = register:registername 40 = TEXT 40.value = register is '{register:registername}' and field is '{field:fieldname}' 40.insertData = 1 ``` --- ADDED: [see the manual](https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/DataTypes/Index.html#gettext) of the typoscript data type `getText` where you can find what else can be used instead of `register`: then the [manual entry for `data`](https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Stdwrap.html#data) which is a property of the function `.stdWrap` and of type `getText`. This entry is followed by the property `field` stating, it is a shortcut for `data = field:` (This explaines why your `COA` with `.data` results in anything, as doing a `.stdWrap.data` on any object will replace the object's content.) be aware that `field` (either as property or as key of `getText`) will select * a field of the current record, which might vary dependent on context: * for page rendering it is the record of the current page (table `pages`), * for rendering a content element it is the element (table `tt_content`), * inside a filesProcessor it is a file (table `sys_file`\_reference`), * in the `renderObj` of `CONTENT`, `RECORDS`, or `split` it is the selction you define.
Found the answer. As far as I can tell, `CASE` works on `stdwrap.cObjects` and so the code ``` 10 = CASE 10 { key.data = {register:count_menuItems} ... } ``` should be ``` stdWrap.cObject = CASE stdWrap.cObject { key.data = register:count_menuItems if.isTrue.data = register:count_menuItems ... } ``` This way it works.
48,811,569
Inspired by: [How to protect against CSRF by default in ASP.NET MVC 4?](https://stackoverflow.com/questions/9965342/how-to-protect-against-csrf-by-default-in-asp-net-mvc-4) Is there a way to achieve the same result in ASP.NET Core?
2018/02/15
[ "https://Stackoverflow.com/questions/48811569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7505329/" ]
You can apply `AutoValidateAntiforgeryTokenAttribute` as a global filter in `Startup.ConfigureServices()`, so it applies to all of your routes automatically: ``` services.AddMvc(options => options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute())); ``` Note that `AutoValidateAntiforgeryTokenAttribute` only applies to unsafe requests (POST, PUT), not safe ones (GET, HEAD, OPTIONS, TRACE). This way, the antiforgery token is only required for actions that are susceptible to CSRF attacks. It's important to make sure only your POST or PUT actions modify data! This global filter approach is recommend by the [official docs](https://learn.microsoft.com/en-us/aspnet/core/security/anti-request-forgery#autovalidateantiforgerytoken) for non-API applications.
Another way to protect from CSRF for good is not using cookies for authentication at all. If that is a possibility I would try checking token authentication and implement it. No cookie, no CSRF. As far as I know it's not a big deal to have JWT token auth e.g. with Core.
22,330,009
I want to validate if user tapped on **Call** button or **Cancel** button after telprompt Current code: ``` NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", [personDetails valueForKey:@"phone"]]]; [[UIApplication sharedApplication] openURL:url]; ``` How can I do so?
2014/03/11
[ "https://Stackoverflow.com/questions/22330009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3049559/" ]
First `telprompt:` is not a documented URL schema and should not be used. Since Apple can change the way it used at any moment. Second since data is passed back to your app, you will not be able to detect a if call was made. You might be able to detect if you use the [`CoreTelephony`](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/CoreTelephonyFrameworkReference/_index.html). But getting this to work require your app to run in the background and you might have to misuse some background mode for this which will make Apple reject your app. Can you explain why you want to detect if there was a call made?
``` [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(called:) name:@"UIApplicationSuspendedNotification" object:nil]; -(void)called:(NSNotification *) notification { NSLog(@"Tapped Call button"); } ``` if Call button was tapped then application will be terminated and go into background so just add an observer for the `UIApplicationSuspendedNotification` notification.
22,330,009
I want to validate if user tapped on **Call** button or **Cancel** button after telprompt Current code: ``` NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", [personDetails valueForKey:@"phone"]]]; [[UIApplication sharedApplication] openURL:url]; ``` How can I do so?
2014/03/11
[ "https://Stackoverflow.com/questions/22330009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3049559/" ]
First `telprompt:` is not a documented URL schema and should not be used. Since Apple can change the way it used at any moment. Second since data is passed back to your app, you will not be able to detect a if call was made. You might be able to detect if you use the [`CoreTelephony`](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/CoreTelephonyFrameworkReference/_index.html). But getting this to work require your app to run in the background and you might have to misuse some background mode for this which will make Apple reject your app. Can you explain why you want to detect if there was a call made?
For my case, I used `tel://` instead of using `telprompt://` and make my own `UIAlertView`. This way you could detect if the call option is tapped from the `UIAlertView`'s delegate.
22,330,009
I want to validate if user tapped on **Call** button or **Cancel** button after telprompt Current code: ``` NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", [personDetails valueForKey:@"phone"]]]; [[UIApplication sharedApplication] openURL:url]; ``` How can I do so?
2014/03/11
[ "https://Stackoverflow.com/questions/22330009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3049559/" ]
``` [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(called:) name:@"UIApplicationSuspendedNotification" object:nil]; -(void)called:(NSNotification *) notification { NSLog(@"Tapped Call button"); } ``` if Call button was tapped then application will be terminated and go into background so just add an observer for the `UIApplicationSuspendedNotification` notification.
For my case, I used `tel://` instead of using `telprompt://` and make my own `UIAlertView`. This way you could detect if the call option is tapped from the `UIAlertView`'s delegate.
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
You need to add the JAXB dependency (as not provided any longer by default in Java 9) and **you have to** use Spring Boot 2 : ```xml <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ``` Note that if you use Java 10, you would have exactly the same issue as the JAXB dependency removal was not done just for the Java 9 version. --- [The Spring Boot wiki about Java 9 and above](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-Java-9-and-above) lists things that you need to know to run Spring Boot apps on Java 9 and above. Spring Boot version requirements -------------------------------- * Spring Boot 1 doesn't support it (and no planned to). * Spring Boot 2 supports it. > > Spring Boot 2 is the first version to support Java 9 (Java 8 is also > supported). If you are using 1.5 and wish to use Java 9 you should > upgrade to 2.0 as we have no plans to support Java 9 on Spring Boot > 1.5.x. > > > **Java 10** is supported as of Spring Boot **2.0.1.RELEASE** while **Java 11** is supported as of Spring Boot **2.1.0.M2**. Some known workarounds ---------------------- ### AspectJ > > With Java 9, if you need to weave classes from the JDK, you need to > use AspectJ 1.9. Spring AOP should work fine in most cases with > AspectJ 1.8 (the default in Spring Boot 2.0). > > > ### JAXB > > When upgrading you may face the following: > > > java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException > > > Hibernate typically requires JAXB that’s no longer provided by > default. You can add the java.xml.bind module to restore this > functionality with Java9 or Java10 (even if the module is deprecated). > > > ```xml <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ``` As of Java11, the module is not available so your only option is to add the JAXB RI (you can do that as of Java9 in place of adding the `java.xml.bind` module: ```xml <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> </dependency> ``` ### Lombok If you are using lombok, the managed version of Spring Boot may not work with the latest JDK. Check the Lombok web site and override its version if necessary. Some known limitations ---------------------- > > These libraries do not have full support for Java 9 yet: > > > * Apache Cassandra, see #10453 > > > --- Please, don't hesitate to edit this post if changes occur about the Java 9 and above compatibility with Spring Boot.
@Ratha : For Java12 (referred to your [comment](https://stackoverflow.com/questions/48986999/classnotfoundexception-for-javax-xml-bind-jaxbexception-with-spring-boot-when-sw/60371962#comment106790145_52019668)) this dependency list works: ```xml <dependencies> <...> <dependency> <groupId>com.sun.activation</groupId> <artifactId>javax.activation</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.1</version> <scope>runtime</scope> </dependency> </dependencies> ```
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
You need to add the JAXB dependency (as not provided any longer by default in Java 9) and **you have to** use Spring Boot 2 : ```xml <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ``` Note that if you use Java 10, you would have exactly the same issue as the JAXB dependency removal was not done just for the Java 9 version. --- [The Spring Boot wiki about Java 9 and above](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-Java-9-and-above) lists things that you need to know to run Spring Boot apps on Java 9 and above. Spring Boot version requirements -------------------------------- * Spring Boot 1 doesn't support it (and no planned to). * Spring Boot 2 supports it. > > Spring Boot 2 is the first version to support Java 9 (Java 8 is also > supported). If you are using 1.5 and wish to use Java 9 you should > upgrade to 2.0 as we have no plans to support Java 9 on Spring Boot > 1.5.x. > > > **Java 10** is supported as of Spring Boot **2.0.1.RELEASE** while **Java 11** is supported as of Spring Boot **2.1.0.M2**. Some known workarounds ---------------------- ### AspectJ > > With Java 9, if you need to weave classes from the JDK, you need to > use AspectJ 1.9. Spring AOP should work fine in most cases with > AspectJ 1.8 (the default in Spring Boot 2.0). > > > ### JAXB > > When upgrading you may face the following: > > > java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException > > > Hibernate typically requires JAXB that’s no longer provided by > default. You can add the java.xml.bind module to restore this > functionality with Java9 or Java10 (even if the module is deprecated). > > > ```xml <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ``` As of Java11, the module is not available so your only option is to add the JAXB RI (you can do that as of Java9 in place of adding the `java.xml.bind` module: ```xml <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> </dependency> ``` ### Lombok If you are using lombok, the managed version of Spring Boot may not work with the latest JDK. Check the Lombok web site and override its version if necessary. Some known limitations ---------------------- > > These libraries do not have full support for Java 9 yet: > > > * Apache Cassandra, see #10453 > > > --- Please, don't hesitate to edit this post if changes occur about the Java 9 and above compatibility with Spring Boot.
The accepted answer is right, just wanted to point out I was having the same issue during Tomcat 9 startup while migrating a web project to OpenJDK11. In my case got the following stack trace: ``` SEVERE [main] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at java.base/java.lang.Class.getDeclaredFields0(Native Method) at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3061) at java.base/java.lang.Class.getDeclaredFields(Class.java:2248) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.collectAnnotatedFields(ManagedBeanConfigHandler.java:245) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.getBeanInfo(ManagedBeanConfigHandler.java:154) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.process(ManagedBeanConfigHandler.java:140) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.push(ManagedBeanConfigHandler.java:126) at com.sun.faces.application.annotation.AnnotationManager.applyConfigAnnotations(AnnotationManager.java:234) at com.sun.faces.config.processor.AbstractConfigProcessor.processAnnotations(AbstractConfigProcessor.java:449) at com.sun.faces.config.processor.ManagedBeanConfigProcessor.process(ManagedBeanConfigProcessor.java:245) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ValidatorConfigProcessor.process(ValidatorConfigProcessor.java:121) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ConverterConfigProcessor.process(ConverterConfigProcessor.java:127) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ComponentConfigProcessor.process(ComponentConfigProcessor.java:118) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:403) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:138) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:246) at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:443) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:237) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4684) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5147) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1848) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) ... 65 more ``` Hope it helps
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
You need to add the JAXB dependency (as not provided any longer by default in Java 9) and **you have to** use Spring Boot 2 : ```xml <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ``` Note that if you use Java 10, you would have exactly the same issue as the JAXB dependency removal was not done just for the Java 9 version. --- [The Spring Boot wiki about Java 9 and above](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-Java-9-and-above) lists things that you need to know to run Spring Boot apps on Java 9 and above. Spring Boot version requirements -------------------------------- * Spring Boot 1 doesn't support it (and no planned to). * Spring Boot 2 supports it. > > Spring Boot 2 is the first version to support Java 9 (Java 8 is also > supported). If you are using 1.5 and wish to use Java 9 you should > upgrade to 2.0 as we have no plans to support Java 9 on Spring Boot > 1.5.x. > > > **Java 10** is supported as of Spring Boot **2.0.1.RELEASE** while **Java 11** is supported as of Spring Boot **2.1.0.M2**. Some known workarounds ---------------------- ### AspectJ > > With Java 9, if you need to weave classes from the JDK, you need to > use AspectJ 1.9. Spring AOP should work fine in most cases with > AspectJ 1.8 (the default in Spring Boot 2.0). > > > ### JAXB > > When upgrading you may face the following: > > > java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException > > > Hibernate typically requires JAXB that’s no longer provided by > default. You can add the java.xml.bind module to restore this > functionality with Java9 or Java10 (even if the module is deprecated). > > > ```xml <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ``` As of Java11, the module is not available so your only option is to add the JAXB RI (you can do that as of Java9 in place of adding the `java.xml.bind` module: ```xml <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> </dependency> ``` ### Lombok If you are using lombok, the managed version of Spring Boot may not work with the latest JDK. Check the Lombok web site and override its version if necessary. Some known limitations ---------------------- > > These libraries do not have full support for Java 9 yet: > > > * Apache Cassandra, see #10453 > > > --- Please, don't hesitate to edit this post if changes occur about the Java 9 and above compatibility with Spring Boot.
Add following dependency in pom.xml file ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> ```
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
Added below dependency and resolve the issue ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ```
The accepted answer is right, just wanted to point out I was having the same issue during Tomcat 9 startup while migrating a web project to OpenJDK11. In my case got the following stack trace: ``` SEVERE [main] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at java.base/java.lang.Class.getDeclaredFields0(Native Method) at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3061) at java.base/java.lang.Class.getDeclaredFields(Class.java:2248) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.collectAnnotatedFields(ManagedBeanConfigHandler.java:245) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.getBeanInfo(ManagedBeanConfigHandler.java:154) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.process(ManagedBeanConfigHandler.java:140) at com.sun.faces.application.annotation.ManagedBeanConfigHandler.push(ManagedBeanConfigHandler.java:126) at com.sun.faces.application.annotation.AnnotationManager.applyConfigAnnotations(AnnotationManager.java:234) at com.sun.faces.config.processor.AbstractConfigProcessor.processAnnotations(AbstractConfigProcessor.java:449) at com.sun.faces.config.processor.ManagedBeanConfigProcessor.process(ManagedBeanConfigProcessor.java:245) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ValidatorConfigProcessor.process(ValidatorConfigProcessor.java:121) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ConverterConfigProcessor.process(ConverterConfigProcessor.java:127) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ComponentConfigProcessor.process(ComponentConfigProcessor.java:118) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:403) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:138) at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155) at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:246) at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:443) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:237) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4684) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5147) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1848) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) ... 65 more ``` Hope it helps
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
Add below maven dependencies in you pom.xml and the issue will get resolve. in Java9/10 JaxB modules has been removed, hence need to add manually. ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2.11</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> <version>2.2.11</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.2.11</version> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> </dependency> ```
Add following dependency in pom.xml file ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> ```
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
Added below dependency and resolve the issue ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ```
Or for Gradle add the dependency ``` compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' ```
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
Added below dependency and resolve the issue ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ```
@Ratha : For Java12 (referred to your [comment](https://stackoverflow.com/questions/48986999/classnotfoundexception-for-javax-xml-bind-jaxbexception-with-spring-boot-when-sw/60371962#comment106790145_52019668)) this dependency list works: ```xml <dependencies> <...> <dependency> <groupId>com.sun.activation</groupId> <artifactId>javax.activation</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.1</version> <scope>runtime</scope> </dependency> </dependencies> ```
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
Or for Gradle add the dependency ``` compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' ```
@Ratha : For Java12 (referred to your [comment](https://stackoverflow.com/questions/48986999/classnotfoundexception-for-javax-xml-bind-jaxbexception-with-spring-boot-when-sw/60371962#comment106790145_52019668)) this dependency list works: ```xml <dependencies> <...> <dependency> <groupId>com.sun.activation</groupId> <artifactId>javax.activation</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.1</version> <scope>runtime</scope> </dependency> </dependencies> ```
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
Added below dependency and resolve the issue ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ```
Add following dependency in pom.xml file ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> ```
48,986,999
Initialized the project using [start.spring.io](http://start.spring.io) Added **WEB,JPA,H2** dependencies then tried to run the `MainApplication.java` using `Jdk 9` and got the following **error log** ``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.10.RELEASE) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT on RAJAT-PC with PID 3860 (C:\Users\devra\Downloads\Compressed\demo\target\demo-0.0.1-SNAPSHOT.jar started by rajat in C:\Users\devra\Downloads\Compressed\demo\target) 2018-02-26 16:23:33.973 INFO 3860 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default 2018-02-26 16:23:34.254 INFO 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1aa7ecca: startup date [Mon Feb 26 16:23:34 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/C:/Users/devra/Downloads/Compressed/demo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-02-26 16:23:38.429 INFO 3860 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1c55a85e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2018-02-26 16:23:39.856 INFO 3860 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-02-26 16:23:39.888 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2018-02-26 16:23:39.903 INFO 3860 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-02-26 16:23:40.247 INFO 3860 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6024 ms 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-02-26 16:23:40.622 INFO 3860 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*] 2018-02-26 16:23:42.200 INFO 3860 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 2018-02-26 16:23:42.263 INFO 3860 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ name: default ...] 2018-02-26 16:23:42.591 INFO 3860 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final} 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found 2018-02-26 16:23:42.607 INFO 3860 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist 2018-02-26 16:23:42.653 WARN 3860 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2018-02-26 16:23:42.669 INFO 3860 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-02-26 16:23:42.716 INFO 3860 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-02-26 16:23:42.747 ERROR 3860 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar!/:1.5.10.RELEASE] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE] ... 24 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) ~[na:na] at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] ... 35 common frames omitted ``` Then I switched to jdk 8 and it working fine. The same happening with **Spring-boot 2.0.0 RC2** Why this happening when spring doc mentioned the required Java version for it to be 8 or 9.
2018/02/26
[ "https://Stackoverflow.com/questions/48986999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4107038/" ]
Added below dependency and resolve the issue ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> ```
Add below maven dependencies in you pom.xml and the issue will get resolve. in Java9/10 JaxB modules has been removed, hence need to add manually. ``` <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2.11</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> <version>2.2.11</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.2.11</version> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> </dependency> ```
275,573
Is there any research on learning a bijective function from data? For example, let's imagine that we're trying to learn to assign four random musicians to instruments in a band. We have: * lead guitar * rhythm guitar * drums * bass We can rate any musician on say 5 quantifiable skills (timing, creativity, guitar, drums, bass). For training, we have a corpus of previous bands, each one mapping four musicians to the four instruments. How do we learn a function to map a new band to the four instruments?
2017/04/24
[ "https://stats.stackexchange.com/questions/275573", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/109890/" ]
1. Are you doing a PCA or an EFA? You say that you do a factor analysis and use a direct oblimin rotation, but you also note that you are extracting components. PCA and EFA rely on different theoretical assumptions, and one should not use an oblique rotation for a PCA, as it goes against the fundamental point of the PCA—to maximize interindividual differences. 2. What software/packages are you using? What output you get is somewhat determined by what the programmers thought necessary given one factor extracted. 3. What are the eigenvalues? What does the scree plot look like? If it is extracting one factor, and there is an obvious elbow at the second eigenvalue, then extracting one factor seems reasonable for these six questions.
I can't really say without looking at your loadings or the corresponding eigenvalue of your single factor. If I had to guess, though, your issue might be that your items are not that related. Just running a single factor should give you no trouble. Again, take this with a grain of salt since its a little tough to evaluate a factor analysis without the corresponding loadings.
14,612,774
I use Node (latest version) + Express, also latest Version. I have 2 folders, public and secured. The secured folder should only be accessible after login. I've create a login system by myself, now I wonder how I can secure the route to this "secure-folder". I was thining about setting a static route to my "secured" folder (like I did with the public one) and then check whether the user is logged in, but it doesn't work. This is what I thought should work... ``` (...) app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'secured'))); (...) function requireLogin(req, res, next) { if (req.session.loggedIn) { next(); // allow the next route to run } else { // require the user to log in res.redirect("/login"); } } app.all("/secured/*", requireLogin, function(req, res, next) { next(); }); ```
2013/01/30
[ "https://Stackoverflow.com/questions/14612774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/867432/" ]
Specify a different folder for your private statics on a separate route ``` app.use(express.static(path.join(__dirname, 'public'))); app.use('/private', express.static(path.join(__dirname, 'private'))); ``` Then you can use your middleware on each request ``` app.all('/private/*', function(req, res, next) { if (req.session.loggedIn) { next(); // allow the next route to run } else { // require the user to log in res.redirect("/login"); } }) ```
before your first app.use, add something like ``` app.use(function(req, res, next) { if (req.url.match(/^\/secured\//)) { return requireLogin(req, res, next); } next(); }) ```
3,431,985
I haven't seen quite this scenario on a card drawing problem on here. I'm trying to figure out the probabilities for a card game I'm developing. There are 3 separate decks with 15 cards each. In each deck there are 2 'white cards' let's say and we're interested in drawing those. So if I draw 3 cards from each of the decks, then what is the probability that I draw at least 1 'white card' and not one of the other 13? I think I calculated the probability for one of the decks so I'll put my work here for someone to check it. Probability of drawing at least 1 white card when drawing 3 cards from one deck: First, I computed the probability of drawing exactly 1 white card when drawing 3 cards from one deck, which is as follows. $P(W\_1) = (\_3C\_1) \left(\frac{2}{15}\right)^1 \left(\frac{13}{15}\right)^2$ $P(W\_1) = 0.3004$ Then, I computed the probability of drawing 2 white cards when drawing 3 cards from the deck. $P(W\_2) = (\_3C\_2)\left(\frac{2}{15}\right)^2 \left(\frac{13}{15}\right)^1$ $P(W\_2) = 0.0462 $ So then the probability of drawing at least 1 white card is, $P(W)= P(W\_1) + P(W\_2) = 0.3466$ So how do I go about incorporating the other 2 decks into my equation? What's the probability of drawing a white card when drawing 3 cards from each deck? Thanks.
2019/11/12
[ "https://math.stackexchange.com/questions/3431985", "https://math.stackexchange.com", "https://math.stackexchange.com/users/724350/" ]
Notice that the probability of drawing **at least one white card** is the same as $1$ minus the probability of drawing **no white cards**: $$ P\left(\text{at least $1$ white card}\right) = 1 - P\left(\text{no white cards}\right)$$ --- The probability that no white cards are drawn when taking three cards from a single deck is: $$P\left(\text{no white cards from a single deck over three draws}\right) = \left(\frac{13}{15}\right)\left(\frac{12}{14}\right)\left(\frac{11}{13}\right)$$ --- In order to get no white cards over all nine draws, it's necessary to get no white cards on the three draws from each of the three decks: $$P\left(\text{no white cards}\right) = \left(\left(\frac{13}{15}\right)\left(\frac{12}{14}\right)\left(\frac{11}{13}\right)\right)^3$$ --- Therefore, \begin{align\*} P\left(\text{at least $1$ white card}\right) &= 1 - P\left(\text{no white cards}\right)\\\\ &= 1 - \left(\left(\frac{13}{15}\right)\left(\frac{12}{14}\right)\left(\frac{11}{13}\right)\right)^3 = \boxed{\frac{32227}{42875}} \approx 0.75165 \end{align\*}
So I was messing around with it more and talking to a friend about it. Can anyone tell me if this is correct... $P(W) = 1 - P(W')$ $ = 1 - \left(\frac{^{13}C\_3}{^{15}C\_3}\right)^3 $ Which comes out to $P(W) = 0.752$ It just seems quite high to me.
63,860,489
I'm try to do something like this ``` def noAsyncPrint(c): sleep(random.uniform(1,10)) print(c) chars = ['a','b','c'] for c in chars: noAsyncPrint(c) ``` getting this output ``` a, b, c ``` How I get some random order?? thank you :) edit to be clear about my example \*\*It's just basic example for being clear, It should be random api request after doing few things \*\*
2020/09/12
[ "https://Stackoverflow.com/questions/63860489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13423845/" ]
you can use `ThreadPool` from [multiprocessing.pool](https://docs.python.org/3.7/library/multiprocessing.html#multiprocessing.pool.Pool) : ``` from multiprocessing.pool import ThreadPool from time import sleep import random def noAsyncPrint(c): sleep(random.uniform(1,10)) print(c) chars = ['a','b','c'] with ThreadPool(3) as p: p.map(noAsyncPrint, chars) ``` output: ``` a c b ``` the output is random, can be any combination in the above code, you are using 3 threads that will execute your function `noAsyncPrint` in an asynchronous fashion so your output is random
You might want to use the [asyncio library](https://docs.python.org/3/library/asyncio.html). Checkout this [guide](https://realpython.com/async-io-python/) for a nice walk-through. The following example uses the `gather()` function to schedule the `async_print()` in a concurrent fashion. I also added logging with time stamp to make the execution order visible: ``` import logging import random import asyncio lgr = logging.getLogger('main') async def async_print(c): tau = round(random.uniform(1,10)) lgr.debug(f"async_print('%s'): - sleeping of %g sec ...", c, tau) await asyncio.sleep(tau) lgr.debug(f"async_print('%s'): ... done sleeping.", c) print(c) async def main(): chars = ['a','b','c'] lgr.info("Creating futures... ") list_of_futures = [async_print(c_) for c_ in chars] lgr.debug("Calling futures concurrently ... ") await asyncio.gather(*list_of_futures) lgr.info(" ... done.") logging.basicConfig(level=logging.DEBUG, datefmt="%H:%M:%S", format='%(asctime)s %(name)s[%(lineno)s] %(levelname)s %(message)s') asyncio.run(main()) ``` The output looks like this: ```none 15:17:56 asyncio[59] DEBUG Using selector: EpollSelector 15:17:56 main[17] INFO Calling futures ... 15:17:56 main[19] DEBUG Waiting for completion ... 15:17:56 main[9] DEBUG async_print('a'): - sleeping of 9 sec ... 15:17:56 main[9] DEBUG async_print('b'): - sleeping of 9 sec ... 15:17:56 main[9] DEBUG async_print('c'): - sleeping of 1 sec ... 15:17:57 main[11] DEBUG async_print('c'): ... done sleeping. c a b 15:18:05 main[11] DEBUG async_print('a'): ... done sleeping. 15:18:05 main[11] DEBUG async_print('b'): ... done sleeping. 15:18:05 main[21] INFO ... done. ``` Note that the `print()` function does not always display the output immediately. The logging functions behave much better in that regard.
63,860,489
I'm try to do something like this ``` def noAsyncPrint(c): sleep(random.uniform(1,10)) print(c) chars = ['a','b','c'] for c in chars: noAsyncPrint(c) ``` getting this output ``` a, b, c ``` How I get some random order?? thank you :) edit to be clear about my example \*\*It's just basic example for being clear, It should be random api request after doing few things \*\*
2020/09/12
[ "https://Stackoverflow.com/questions/63860489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13423845/" ]
you can use `ThreadPool` from [multiprocessing.pool](https://docs.python.org/3.7/library/multiprocessing.html#multiprocessing.pool.Pool) : ``` from multiprocessing.pool import ThreadPool from time import sleep import random def noAsyncPrint(c): sleep(random.uniform(1,10)) print(c) chars = ['a','b','c'] with ThreadPool(3) as p: p.map(noAsyncPrint, chars) ``` output: ``` a c b ``` the output is random, can be any combination in the above code, you are using 3 threads that will execute your function `noAsyncPrint` in an asynchronous fashion so your output is random
in the numpy library, there is a function for random order, called `np.random.suffle()` ``` import numpy as np # import the numpy lybrary def noAsyncPrint(c): sleep(random.uniform(1,10)) print(c) chars = np.array(['a','b','c']) #make it a np array random_chars = np.random.suffle(chars) # shuffle it! for c in random_chars: noAsyncPrint(c) ```
11,752,582
I have created this javascript which generates a random number ranging from 0-20. What I want to do is create a text field where the user has 4 attempts to guess the generated number. How would I do this? ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> </head> <body> <form><input name="code" id="code" type="text" value="" ></input> <script type="text/javascript"> function makeid() { return Math.floor(Math.random() * 20) } </script> <input type="button" style="font-size:9pt" value="Generate Code" onclick="document.getElementById('code').value = makeid()"> </input> </form> </body> </html> ```
2012/08/01
[ "https://Stackoverflow.com/questions/11752582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1404603/" ]
You could use a global to track state. However, the security of this is weak, as the user could simply reload the page to circumvent the limit. What you really need to do then is track state on the server side (e.g. database) and then use e.g. an Ajax Call on the browser to do the checking :) ``` <script type="text/javascript"> var count = 0; function makeid() { count++; if (count <= 4) { return Math.floor(Math.random() * 20); } alert('Out of attempts'); } </script> ``` **Edit** Apologies, I've only answered half your question. ``` <script type="text/javascript"> var attempts = 0; var secretValue = makeid(); // Calculate the secret value once, and don't vary it once page is loaded function makeid() { return Math.floor(Math.random() * 20); } function checkId(userValue) { if (parseInt(userValue) == secretValue) { alert('Correct'); } else { attempts++; if (attempts <= 4) { alert('Wrong - try again'); } else { alert('Out of attempts'); } } } </script> ``` And then change your click handler to ``` onclick="checkId(document.getElementById('code').value);" ```
One way is to put the generated number into an element that is hidden. Keep a count of the attempts, when the user either gets it right or reaches 4 attempts, show the value and whether or not they guessed correctly. Perhaps also show the number of attempts. Include a reset button to reset the counter and generate a new hidden value.
11,752,582
I have created this javascript which generates a random number ranging from 0-20. What I want to do is create a text field where the user has 4 attempts to guess the generated number. How would I do this? ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> </head> <body> <form><input name="code" id="code" type="text" value="" ></input> <script type="text/javascript"> function makeid() { return Math.floor(Math.random() * 20) } </script> <input type="button" style="font-size:9pt" value="Generate Code" onclick="document.getElementById('code').value = makeid()"> </input> </form> </body> </html> ```
2012/08/01
[ "https://Stackoverflow.com/questions/11752582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1404603/" ]
You could use a global to track state. However, the security of this is weak, as the user could simply reload the page to circumvent the limit. What you really need to do then is track state on the server side (e.g. database) and then use e.g. an Ajax Call on the browser to do the checking :) ``` <script type="text/javascript"> var count = 0; function makeid() { count++; if (count <= 4) { return Math.floor(Math.random() * 20); } alert('Out of attempts'); } </script> ``` **Edit** Apologies, I've only answered half your question. ``` <script type="text/javascript"> var attempts = 0; var secretValue = makeid(); // Calculate the secret value once, and don't vary it once page is loaded function makeid() { return Math.floor(Math.random() * 20); } function checkId(userValue) { if (parseInt(userValue) == secretValue) { alert('Correct'); } else { attempts++; if (attempts <= 4) { alert('Wrong - try again'); } else { alert('Out of attempts'); } } } </script> ``` And then change your click handler to ``` onclick="checkId(document.getElementById('code').value);" ```
Rather than using a text field, why not try using the [prompt()](http://www.w3schools.com/jsref/met_win_prompt.asp) function? Here's a basic idea for the control flow: 1. Generate your random number and store it in a variable. 2. Create some variable like *correct* and set it to false. 3. Prompt the user for a guess in a [for loop](http://www.w3schools.com/js/js_loop_for.asp) (with 4 iterations) 4. After each guess, check if the guess matches your stored number. If it is, then [break](http://www.w3schools.com/js/js_break.asp) out of the loop early after setting *correct* to true. 5. Upon exiting the for loop, [alert](http://www.w3schools.com/jsref/met_win_alert.asp) the user whether they won or lost based on the value of *correct*.
22,915,951
``` public void Post(IEnumerable<int> ids) { foreach (var id in ids) { string postIdVal = AddPublicationOnMonster(id); string url = string.Format("http://jobview.monster.com/getjob.aspx?JobID={0}", postIdVal); System.Diagnostics.Process.Start(url); ; } } ``` the error was in the line foreach (var id in ids), how can I solve it ?
2014/04/07
[ "https://Stackoverflow.com/questions/22915951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2576121/" ]
Found the answer elsewhere. You have to set a camera also. Here is a sample camera init : ``` MKMapCamera *newCamera = [[self.mapView camera] copy]; [newCamera setPitch:45.0]; [newCamera setHeading:90.0]; [newCamera setAltitude:500.0]; [self.mapView setCamera:newCamera animated:YES]; ```
Please see Discussion here at apple document. [<https://developer.apple.com/documentation/mapkit/mkmapview/1452277-camera#discussion][1]> You have to play with the pitch property to toggle between the 2D and 3D map view
4,227,167
Question: In how many ways can 3 vertices be selected from a decagon so no two are consecutive? Once I choose one of the vertices, since the adjacent ones are ruled out, I now have 7 vertices to choose my next one from. Similarly, the next time around, I will have 4 vertices to choose from. Additionally, I accounted for overlapping triangles by dividing my answer with 3. My final answer looks like this: (10C1 \* 7C1 \* 4C1)/3 which isn't even a natural number. Where am I going wrong?
2021/08/18
[ "https://math.stackexchange.com/questions/4227167", "https://math.stackexchange.com", "https://math.stackexchange.com/users/959489/" ]
Let's try your strategy with 6 elements XXXXXX In the first case, I select one as you told at random: XX(X)XXX Now for the second, suppose I take this choice: XX(X)XX(X) Then you see there is no where I can keep the third such that all three are not adjacent. But suppose, I took this other choice: XX(X)X(X)X Clearly I have one more choice left for third element. --- I couldn't think of a faithful notation for circular seating but the idea is the string repeats itself as end, meaning if you ask "what is the next element" pointing at the last element from the left, then I'd point at the first element in the string.
Number the vertices clockwise from $1-10$ Make $3$ blocks of chosen-unchosen, looking clockwise, $\,\boxed{\circ\bullet}$ so there are now $3$ paired units and $4$ single units. The block formation ensures that two *chosen* vertices can't now be adjacent, wherever the blocks might be placed. The blocks can be placed among the $7$ units in $\binom73 = 35$ ways, but each unit is getting only $7$ starting points instead of $10$, thus the final answer $= \dfrac{10}{7} \times 35 = 50$
55,210,994
i've an unexpected issue trying to remove child entity from parent single database record. After doing some tests we have replicated the problem. Our C# code use Northwind database. ``` NWModel context = new NWModel(); Orders order = context.Orders.Where(w => w.OrderID == 10248).FirstOrDefault(); context.Entry(order).Collection(typeof(Order_Details).Name).Load(); order.Order_Details.RemoveAt(1); System.Data.Entity.Infrastructure.DbChangeTracker changeset = context.ChangeTracker; var changes = changeset.Entries().Where(x => x.State == System.Data.Entity.EntityState.Modified).ToList<Object>(); var detetions = changeset.Entries().Where(x => x.State == System.Data.Entity.EntityState.Deleted).ToList<Object>(); ``` All works fine with original Order\_Details table setup. var deletions correctly has got deleted record. In order to reproduce the issue, we have added on Order\_Details table a new PK identity int field (OrderDetailId int identity); after doing that: **var deletions** contain no record while **var changes** contain **Order\_Detail** record. EF set **Orders** property of **Order\_Detail** to null and mark the record as **Updated**. I've found a lot of articles regarding this issue, all of them suggests to mark **Order\_Detail** **Orders** property to **[Required]**. I've tried to set **[Required]** attribute on FK entity as suggested in [this post](https://stackoverflow.com/questions/5471374/how-do-you-ensure-cascade-delete-is-enabled-on-a-table-relationship-in-ef-code-f), (this article describe EFCore behaviour that is the same as EF6 behaviour) but is does not solve my issue. Is this behaviour expected? we would appreciate any comments or suggestions. Thanks
2019/03/17
[ "https://Stackoverflow.com/questions/55210994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8339959/" ]
Your first line starts at `(0,0)` and got to `(50, -50)`, thus goes 50 units in **X** and **Y** direction. But you second ist going from `(0,-50)` to `(50,50)`, thus goes 50 units in **X** direction and **100 units** in **Y** direction. Additionally your right and left have no effect. One possible solution would be: ``` t.setposition(-50,50) t.pendown() t.setposition(50,-50) t.penup() t.setposition(-50,-50) t.pendown() t.setposition(50,50) ```
Another approach you can take is to avoid `setposition()` altogether and think like a turtle. That is, crawl forward, backward and turn rather than teleport: ``` import turtle as t t.right(45) t.forward(70) t.backward(140) t.forward(70) t.left(90) t.forward(70) t.backward(140) t.hideturtle() t.done() ```
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
A lot of disclaimers apply here because different types of pain tend to mean different things and while you can ignore some of them to an extent, you want to be careful not to ignore things too much your you may find yourself with a serious injury on your hands. I'm going to run down the short list of issues that I've encountered while training: * Sharp pain while stretching - Stop and ease up a bit, odds are you have hit a threshold and you don't want to keep pushing yourself any farther than you already have as it could result in torn muscles. * Pain during cardio work (i.e. [side stitch](http://en.wikipedia.org/wiki/Side_stitch)) - These are just something you have to tough through, on the bright side, the better shape you get into, the less likely the are to occur if you are warmed up properly. * Dull aches and pains following practice or deadening exercises - I like to call these "demotivators" because they tend to persist anywhere from a couple minutes after practice to a couple days later and have a tendency cause people not to come to class any more. Assuming these aren't sharper pains they tend to be something you can safely ignore. Just make sure you stretch and warm up properly before class and in some cases rubs like [Tiger Balm](http://en.wikipedia.org/wiki/Tiger_Balm) can help a lot afterwards. * Sharp pain following a strike from another - This really depends upon where you get hit and how hard, make sure you pay attention to what your body is saying so you don't make something worse by ignoring it, but generally when it comes to sparing practice you shouldn't have to worry too much. However, even though you can't stop a fight if you get hurt on the street, you should be careful not to push yourself to do something that could get your injuries. One thing to note though, in my experience, my worst injury (partly torn [ACL](http://en.wikipedia.org/wiki/Anterior_cruciate_ligament)) didn't result in any immediate pain due to shock, I just couldn't support my weight on my knee any more. In the event that something like that happens, stop immediately. Likewise if you are dizzy and are having problems recovering in general, you can make things worse by pushing yourself when you should not.
What kind of pain? There are many kinds. Beyond the obvious "mental / emotional / physical", there are many kinds of each. The awareness of this will get you started on the path to understanding. When is there too much pain? When there is so much pain that you can't think. When your world disappears, and your body, and your mind, and all that is left is the pain. Over time, with training, the pain can be your friend, too. Not to be feared, but to be understood, to be recognized. Pain is a great teacher. [Edit - Okay, your concern is that your body is made of flesh and can be disoriented. As far as I can tell, you could try PCP or just practice really hard not getting hit that way, or examine these situations and examine how to minimize damage / effects. There are always ways. It just takes time, and my answers may not work for you.]
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
> > *All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more aware of what is happening around me.* > > > Of course they do - they are supposed to, your body doesn't like being hit in those spots! You can mitigate some of these to a certain degree by: * building the muscle groups around the target area. This can lessen the pain and discomfort from a wayward shot, but still will not prevent pain and/or damage from a precise and expertly targeted shot. You can have abdominals of steel but a correctly placed shot into the Solar Plexus will still cause issues because of the [Vagus nerve](http://en.wikipedia.org/wiki/Vagus_nerve) cannot be completely shielded by muscle. * working on your technique and awareness so that you do not get hit in vulnerable spots * doing a lot of linework and katas/forms to enhance your muscle memory so that even when suffering through a blow to one of these areas you can still continue to function. ***IMVHO you should not work on conditioning these areas without expert supervision.*** You will never eliminate the pain of being struck there (unless maybe you join the [traveling Shaolin monks](http://www.shaolinmonksinmalta.com/) and spend many years training). The best (and fastest) solution is to not get hit there.
What kind of pain? There are many kinds. Beyond the obvious "mental / emotional / physical", there are many kinds of each. The awareness of this will get you started on the path to understanding. When is there too much pain? When there is so much pain that you can't think. When your world disappears, and your body, and your mind, and all that is left is the pain. Over time, with training, the pain can be your friend, too. Not to be feared, but to be understood, to be recognized. Pain is a great teacher. [Edit - Okay, your concern is that your body is made of flesh and can be disoriented. As far as I can tell, you could try PCP or just practice really hard not getting hit that way, or examine these situations and examine how to minimize damage / effects. There are always ways. It just takes time, and my answers may not work for you.]
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
I want to make sure I hit every part of this, so I'm going to make heavy use of quotes here... First, we need to answer an unasked question: ***What is pain?*** This is important first off since, in order to work through pain, you have to understand pain. Pain is a nervous-system response to intense or damaging stimuli. When someone strikes you, your body perceives the stimulus, nervous impulses fire, hormones flood your body, and your brain sends a message – Something has happened at XYZ location, be aware of it! Part of overcoming pain is overcoming fear. The fear of pain intensifies pain and prevents you from thinking through the problem. This does not help, so it can also be important to experience pain as a means of overcoming a fear of pain. Finally, it's important to notice that it's the brain that sends the impulse as to how pain is perceived. There are those who, either through an addiction to the hormone release, or through mental control, or even through misfiring of neurons experience pain as a pleasurable sensation. *Since the brain tells the body what to feel and how, we have an opportunity to change our interpretation of that pain, maintaining acknowledgment that it is a warning of imminent danger, but perceiving it as a welcome message, rather than a crippling one*. Now let's answer your questions. > > How do you train attacks/defense while in physical pain? > > > The problem that most practitioners experience is that they jump straight into pain. That is, from the first moment, they're taught to feel pain, to tap out, and the pain ends. This instills a fear of pain. Like a child learning to walk, you have to take easy first steps, not attempt to run full out. First, experience pain. When I was first faced with this same issue, my *shidoshi* (instructor in the Bujinkan) was using me as the class *uke*, demonstrating techniques on me with regularity, and always taking them to a final control. After a bit of this, he would make the pain excruciating; I would be screaming in pain. Eventually, I knew that I had to take the pain, and I began to "drift off". I would use visualization to get myself into a nice place (I have a fondness for Maui, so I'd visualize myself on the beach there), only to be wrenched back to reality, being told I needed to experience it. He was right. Once you experience pain, you can isolate the pain. Use the pain, and feel for it; what direction is the pain moving, how are you contributing to it, and, most importantly, what happens when I breathe? A French obstetrician by the name of Dr. Fernand Lamaze, in the 1940s, became rather fascinated with the techniques practiced by midwives in the Soviet Union. Many of these practices included breathing and relaxation techniques guided by the midwife during childbirth, and led to the development of a series of techniques designed to increase a woman's confidence in her ability to give birth. Similarly, these techniques are used by (and may stem from) Cossack practices for avoiding or shrugging off pain, by giving the mind something else to focus on. The human brain is fairly well maxed out most of the time on its ability to multi-task, and forcing a specific focal behavior (e.g. breathing) can be distracting. Distraction, as you'll note I'd already found, is imperative in blocking pain. Finding a distraction that allows you to stay active and focused is far better than imagining yourself on a beach in Hawaii. When you find yourself in pain, first start breathing in forced deep breaths. While you do so, find the source of your pain. Once you find the source, the most general rule of escape is to move toward the pain. Note the way you need to move in performing escapes from shoulder locks, wrist locks, chokes, etc. when you're training escapes. Pain wants to draw you away from the thing hurting you; sometimes to escape a burning house you need to leap through flames. > > Are there safe ways to cause a lot of physical pain without long term damage? > > > Well, yes and no... Any impact injury carries risk. Any rending, tearing, pulling, grabbing, etc. can have the risk of dislodging a blood clot leading to infarction; grappling could lead to fracture and bone shards could cause an embolism. That said, so long as you're carefully training, these risks are minimum. Training with a partner you trust is key. Exploring your pain threshold carefully can lead you to a greater understanding of when enough is enough, always being careful to push just past where you want to tap. You want the immediate result, but ***there is no easy way to learn to overcome pain***. It's equal parts personal resolve and psychological trickery to move past the things that cause you intense pain. > > How do you learn to recognize when there is too much physical pain? > > > Very good question. Before you begin training to resist pain, you need to learn what causes you pain. Work with a partner in slowly inflicting pain upon each other, being careful to not injure the other, and resolving to push further than you'd normally allow before tapping. Generally, if you can't escape from this level of training, then you just need to tap. Your partner should continue to slowly apply greater pain until you tap or escape. If something gets torn, you've gone too far. Careful training is vital, and only you can know your limits. > > Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: > > > This is irrelevant. All pain offers the same effects. The compression of the sciatic nerve leads to a collapse in the legs, compression of the suprascapular nerve leads to a numbing of the arm. But pain is pain. These nerves carry impulses, and you can not overcome their compression immediately; it's a physiological function. The pain you feel, however, you can overcome, but to do so quickly will mean practice. Nothing comes overnight. For those that cause a momentary loss of function, train from the position to which you're dropped. Do that, and you'll still be defensible.
What kind of pain? There are many kinds. Beyond the obvious "mental / emotional / physical", there are many kinds of each. The awareness of this will get you started on the path to understanding. When is there too much pain? When there is so much pain that you can't think. When your world disappears, and your body, and your mind, and all that is left is the pain. Over time, with training, the pain can be your friend, too. Not to be feared, but to be understood, to be recognized. Pain is a great teacher. [Edit - Okay, your concern is that your body is made of flesh and can be disoriented. As far as I can tell, you could try PCP or just practice really hard not getting hit that way, or examine these situations and examine how to minimize damage / effects. There are always ways. It just takes time, and my answers may not work for you.]
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
What kind of pain? There are many kinds. Beyond the obvious "mental / emotional / physical", there are many kinds of each. The awareness of this will get you started on the path to understanding. When is there too much pain? When there is so much pain that you can't think. When your world disappears, and your body, and your mind, and all that is left is the pain. Over time, with training, the pain can be your friend, too. Not to be feared, but to be understood, to be recognized. Pain is a great teacher. [Edit - Okay, your concern is that your body is made of flesh and can be disoriented. As far as I can tell, you could try PCP or just practice really hard not getting hit that way, or examine these situations and examine how to minimize damage / effects. There are always ways. It just takes time, and my answers may not work for you.]
I'm glad you clarified your question. The question I see there is not "how can I overcome pain" but "can I overcome (partial) paralysis?". The answer is simple: no, you can't. Weak spots are just that, weak, and should be defended. Your problem is not - apparently - the simple pain.
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
I want to make sure I hit every part of this, so I'm going to make heavy use of quotes here... First, we need to answer an unasked question: ***What is pain?*** This is important first off since, in order to work through pain, you have to understand pain. Pain is a nervous-system response to intense or damaging stimuli. When someone strikes you, your body perceives the stimulus, nervous impulses fire, hormones flood your body, and your brain sends a message – Something has happened at XYZ location, be aware of it! Part of overcoming pain is overcoming fear. The fear of pain intensifies pain and prevents you from thinking through the problem. This does not help, so it can also be important to experience pain as a means of overcoming a fear of pain. Finally, it's important to notice that it's the brain that sends the impulse as to how pain is perceived. There are those who, either through an addiction to the hormone release, or through mental control, or even through misfiring of neurons experience pain as a pleasurable sensation. *Since the brain tells the body what to feel and how, we have an opportunity to change our interpretation of that pain, maintaining acknowledgment that it is a warning of imminent danger, but perceiving it as a welcome message, rather than a crippling one*. Now let's answer your questions. > > How do you train attacks/defense while in physical pain? > > > The problem that most practitioners experience is that they jump straight into pain. That is, from the first moment, they're taught to feel pain, to tap out, and the pain ends. This instills a fear of pain. Like a child learning to walk, you have to take easy first steps, not attempt to run full out. First, experience pain. When I was first faced with this same issue, my *shidoshi* (instructor in the Bujinkan) was using me as the class *uke*, demonstrating techniques on me with regularity, and always taking them to a final control. After a bit of this, he would make the pain excruciating; I would be screaming in pain. Eventually, I knew that I had to take the pain, and I began to "drift off". I would use visualization to get myself into a nice place (I have a fondness for Maui, so I'd visualize myself on the beach there), only to be wrenched back to reality, being told I needed to experience it. He was right. Once you experience pain, you can isolate the pain. Use the pain, and feel for it; what direction is the pain moving, how are you contributing to it, and, most importantly, what happens when I breathe? A French obstetrician by the name of Dr. Fernand Lamaze, in the 1940s, became rather fascinated with the techniques practiced by midwives in the Soviet Union. Many of these practices included breathing and relaxation techniques guided by the midwife during childbirth, and led to the development of a series of techniques designed to increase a woman's confidence in her ability to give birth. Similarly, these techniques are used by (and may stem from) Cossack practices for avoiding or shrugging off pain, by giving the mind something else to focus on. The human brain is fairly well maxed out most of the time on its ability to multi-task, and forcing a specific focal behavior (e.g. breathing) can be distracting. Distraction, as you'll note I'd already found, is imperative in blocking pain. Finding a distraction that allows you to stay active and focused is far better than imagining yourself on a beach in Hawaii. When you find yourself in pain, first start breathing in forced deep breaths. While you do so, find the source of your pain. Once you find the source, the most general rule of escape is to move toward the pain. Note the way you need to move in performing escapes from shoulder locks, wrist locks, chokes, etc. when you're training escapes. Pain wants to draw you away from the thing hurting you; sometimes to escape a burning house you need to leap through flames. > > Are there safe ways to cause a lot of physical pain without long term damage? > > > Well, yes and no... Any impact injury carries risk. Any rending, tearing, pulling, grabbing, etc. can have the risk of dislodging a blood clot leading to infarction; grappling could lead to fracture and bone shards could cause an embolism. That said, so long as you're carefully training, these risks are minimum. Training with a partner you trust is key. Exploring your pain threshold carefully can lead you to a greater understanding of when enough is enough, always being careful to push just past where you want to tap. You want the immediate result, but ***there is no easy way to learn to overcome pain***. It's equal parts personal resolve and psychological trickery to move past the things that cause you intense pain. > > How do you learn to recognize when there is too much physical pain? > > > Very good question. Before you begin training to resist pain, you need to learn what causes you pain. Work with a partner in slowly inflicting pain upon each other, being careful to not injure the other, and resolving to push further than you'd normally allow before tapping. Generally, if you can't escape from this level of training, then you just need to tap. Your partner should continue to slowly apply greater pain until you tap or escape. If something gets torn, you've gone too far. Careful training is vital, and only you can know your limits. > > Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: > > > This is irrelevant. All pain offers the same effects. The compression of the sciatic nerve leads to a collapse in the legs, compression of the suprascapular nerve leads to a numbing of the arm. But pain is pain. These nerves carry impulses, and you can not overcome their compression immediately; it's a physiological function. The pain you feel, however, you can overcome, but to do so quickly will mean practice. Nothing comes overnight. For those that cause a momentary loss of function, train from the position to which you're dropped. Do that, and you'll still be defensible.
A lot of disclaimers apply here because different types of pain tend to mean different things and while you can ignore some of them to an extent, you want to be careful not to ignore things too much your you may find yourself with a serious injury on your hands. I'm going to run down the short list of issues that I've encountered while training: * Sharp pain while stretching - Stop and ease up a bit, odds are you have hit a threshold and you don't want to keep pushing yourself any farther than you already have as it could result in torn muscles. * Pain during cardio work (i.e. [side stitch](http://en.wikipedia.org/wiki/Side_stitch)) - These are just something you have to tough through, on the bright side, the better shape you get into, the less likely the are to occur if you are warmed up properly. * Dull aches and pains following practice or deadening exercises - I like to call these "demotivators" because they tend to persist anywhere from a couple minutes after practice to a couple days later and have a tendency cause people not to come to class any more. Assuming these aren't sharper pains they tend to be something you can safely ignore. Just make sure you stretch and warm up properly before class and in some cases rubs like [Tiger Balm](http://en.wikipedia.org/wiki/Tiger_Balm) can help a lot afterwards. * Sharp pain following a strike from another - This really depends upon where you get hit and how hard, make sure you pay attention to what your body is saying so you don't make something worse by ignoring it, but generally when it comes to sparing practice you shouldn't have to worry too much. However, even though you can't stop a fight if you get hurt on the street, you should be careful not to push yourself to do something that could get your injuries. One thing to note though, in my experience, my worst injury (partly torn [ACL](http://en.wikipedia.org/wiki/Anterior_cruciate_ligament)) didn't result in any immediate pain due to shock, I just couldn't support my weight on my knee any more. In the event that something like that happens, stop immediately. Likewise if you are dizzy and are having problems recovering in general, you can make things worse by pushing yourself when you should not.
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
A lot of disclaimers apply here because different types of pain tend to mean different things and while you can ignore some of them to an extent, you want to be careful not to ignore things too much your you may find yourself with a serious injury on your hands. I'm going to run down the short list of issues that I've encountered while training: * Sharp pain while stretching - Stop and ease up a bit, odds are you have hit a threshold and you don't want to keep pushing yourself any farther than you already have as it could result in torn muscles. * Pain during cardio work (i.e. [side stitch](http://en.wikipedia.org/wiki/Side_stitch)) - These are just something you have to tough through, on the bright side, the better shape you get into, the less likely the are to occur if you are warmed up properly. * Dull aches and pains following practice or deadening exercises - I like to call these "demotivators" because they tend to persist anywhere from a couple minutes after practice to a couple days later and have a tendency cause people not to come to class any more. Assuming these aren't sharper pains they tend to be something you can safely ignore. Just make sure you stretch and warm up properly before class and in some cases rubs like [Tiger Balm](http://en.wikipedia.org/wiki/Tiger_Balm) can help a lot afterwards. * Sharp pain following a strike from another - This really depends upon where you get hit and how hard, make sure you pay attention to what your body is saying so you don't make something worse by ignoring it, but generally when it comes to sparing practice you shouldn't have to worry too much. However, even though you can't stop a fight if you get hurt on the street, you should be careful not to push yourself to do something that could get your injuries. One thing to note though, in my experience, my worst injury (partly torn [ACL](http://en.wikipedia.org/wiki/Anterior_cruciate_ligament)) didn't result in any immediate pain due to shock, I just couldn't support my weight on my knee any more. In the event that something like that happens, stop immediately. Likewise if you are dizzy and are having problems recovering in general, you can make things worse by pushing yourself when you should not.
I'm glad you clarified your question. The question I see there is not "how can I overcome pain" but "can I overcome (partial) paralysis?". The answer is simple: no, you can't. Weak spots are just that, weak, and should be defended. Your problem is not - apparently - the simple pain.
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
I want to make sure I hit every part of this, so I'm going to make heavy use of quotes here... First, we need to answer an unasked question: ***What is pain?*** This is important first off since, in order to work through pain, you have to understand pain. Pain is a nervous-system response to intense or damaging stimuli. When someone strikes you, your body perceives the stimulus, nervous impulses fire, hormones flood your body, and your brain sends a message – Something has happened at XYZ location, be aware of it! Part of overcoming pain is overcoming fear. The fear of pain intensifies pain and prevents you from thinking through the problem. This does not help, so it can also be important to experience pain as a means of overcoming a fear of pain. Finally, it's important to notice that it's the brain that sends the impulse as to how pain is perceived. There are those who, either through an addiction to the hormone release, or through mental control, or even through misfiring of neurons experience pain as a pleasurable sensation. *Since the brain tells the body what to feel and how, we have an opportunity to change our interpretation of that pain, maintaining acknowledgment that it is a warning of imminent danger, but perceiving it as a welcome message, rather than a crippling one*. Now let's answer your questions. > > How do you train attacks/defense while in physical pain? > > > The problem that most practitioners experience is that they jump straight into pain. That is, from the first moment, they're taught to feel pain, to tap out, and the pain ends. This instills a fear of pain. Like a child learning to walk, you have to take easy first steps, not attempt to run full out. First, experience pain. When I was first faced with this same issue, my *shidoshi* (instructor in the Bujinkan) was using me as the class *uke*, demonstrating techniques on me with regularity, and always taking them to a final control. After a bit of this, he would make the pain excruciating; I would be screaming in pain. Eventually, I knew that I had to take the pain, and I began to "drift off". I would use visualization to get myself into a nice place (I have a fondness for Maui, so I'd visualize myself on the beach there), only to be wrenched back to reality, being told I needed to experience it. He was right. Once you experience pain, you can isolate the pain. Use the pain, and feel for it; what direction is the pain moving, how are you contributing to it, and, most importantly, what happens when I breathe? A French obstetrician by the name of Dr. Fernand Lamaze, in the 1940s, became rather fascinated with the techniques practiced by midwives in the Soviet Union. Many of these practices included breathing and relaxation techniques guided by the midwife during childbirth, and led to the development of a series of techniques designed to increase a woman's confidence in her ability to give birth. Similarly, these techniques are used by (and may stem from) Cossack practices for avoiding or shrugging off pain, by giving the mind something else to focus on. The human brain is fairly well maxed out most of the time on its ability to multi-task, and forcing a specific focal behavior (e.g. breathing) can be distracting. Distraction, as you'll note I'd already found, is imperative in blocking pain. Finding a distraction that allows you to stay active and focused is far better than imagining yourself on a beach in Hawaii. When you find yourself in pain, first start breathing in forced deep breaths. While you do so, find the source of your pain. Once you find the source, the most general rule of escape is to move toward the pain. Note the way you need to move in performing escapes from shoulder locks, wrist locks, chokes, etc. when you're training escapes. Pain wants to draw you away from the thing hurting you; sometimes to escape a burning house you need to leap through flames. > > Are there safe ways to cause a lot of physical pain without long term damage? > > > Well, yes and no... Any impact injury carries risk. Any rending, tearing, pulling, grabbing, etc. can have the risk of dislodging a blood clot leading to infarction; grappling could lead to fracture and bone shards could cause an embolism. That said, so long as you're carefully training, these risks are minimum. Training with a partner you trust is key. Exploring your pain threshold carefully can lead you to a greater understanding of when enough is enough, always being careful to push just past where you want to tap. You want the immediate result, but ***there is no easy way to learn to overcome pain***. It's equal parts personal resolve and psychological trickery to move past the things that cause you intense pain. > > How do you learn to recognize when there is too much physical pain? > > > Very good question. Before you begin training to resist pain, you need to learn what causes you pain. Work with a partner in slowly inflicting pain upon each other, being careful to not injure the other, and resolving to push further than you'd normally allow before tapping. Generally, if you can't escape from this level of training, then you just need to tap. Your partner should continue to slowly apply greater pain until you tap or escape. If something gets torn, you've gone too far. Careful training is vital, and only you can know your limits. > > Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: > > > This is irrelevant. All pain offers the same effects. The compression of the sciatic nerve leads to a collapse in the legs, compression of the suprascapular nerve leads to a numbing of the arm. But pain is pain. These nerves carry impulses, and you can not overcome their compression immediately; it's a physiological function. The pain you feel, however, you can overcome, but to do so quickly will mean practice. Nothing comes overnight. For those that cause a momentary loss of function, train from the position to which you're dropped. Do that, and you'll still be defensible.
> > *All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more aware of what is happening around me.* > > > Of course they do - they are supposed to, your body doesn't like being hit in those spots! You can mitigate some of these to a certain degree by: * building the muscle groups around the target area. This can lessen the pain and discomfort from a wayward shot, but still will not prevent pain and/or damage from a precise and expertly targeted shot. You can have abdominals of steel but a correctly placed shot into the Solar Plexus will still cause issues because of the [Vagus nerve](http://en.wikipedia.org/wiki/Vagus_nerve) cannot be completely shielded by muscle. * working on your technique and awareness so that you do not get hit in vulnerable spots * doing a lot of linework and katas/forms to enhance your muscle memory so that even when suffering through a blow to one of these areas you can still continue to function. ***IMVHO you should not work on conditioning these areas without expert supervision.*** You will never eliminate the pain of being struck there (unless maybe you join the [traveling Shaolin monks](http://www.shaolinmonksinmalta.com/) and spend many years training). The best (and fastest) solution is to not get hit there.
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
> > *All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more aware of what is happening around me.* > > > Of course they do - they are supposed to, your body doesn't like being hit in those spots! You can mitigate some of these to a certain degree by: * building the muscle groups around the target area. This can lessen the pain and discomfort from a wayward shot, but still will not prevent pain and/or damage from a precise and expertly targeted shot. You can have abdominals of steel but a correctly placed shot into the Solar Plexus will still cause issues because of the [Vagus nerve](http://en.wikipedia.org/wiki/Vagus_nerve) cannot be completely shielded by muscle. * working on your technique and awareness so that you do not get hit in vulnerable spots * doing a lot of linework and katas/forms to enhance your muscle memory so that even when suffering through a blow to one of these areas you can still continue to function. ***IMVHO you should not work on conditioning these areas without expert supervision.*** You will never eliminate the pain of being struck there (unless maybe you join the [traveling Shaolin monks](http://www.shaolinmonksinmalta.com/) and spend many years training). The best (and fastest) solution is to not get hit there.
I'm glad you clarified your question. The question I see there is not "how can I overcome pain" but "can I overcome (partial) paralysis?". The answer is simple: no, you can't. Weak spots are just that, weak, and should be defended. Your problem is not - apparently - the simple pain.
459
Big part of my training is maintaining control of your body even though I feel physical pain. There are usually two situations, in physical pain while still having energy to fight, and in physical pain while being exhausted. How do you train attacks/defense while in physical pain? Are there safe ways to cause a lot of physical pain without long term damage? How do you learn to recognize when there is too much physical pain? Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: punch in the ear, solar plexus pain when breathing from kick or a punch, when kicked near the shoulder blade or kidney paralyzing pain in my spine. All of the above cause intense pain for few seconds and than go away to the point where I'm able to refocus and become more avare of what is happening around me. There are more instances but I would say that the above are the once I'm concerned about the most.
2012/02/12
[ "https://martialarts.stackexchange.com/questions/459", "https://martialarts.stackexchange.com", "https://martialarts.stackexchange.com/users/-1/" ]
I want to make sure I hit every part of this, so I'm going to make heavy use of quotes here... First, we need to answer an unasked question: ***What is pain?*** This is important first off since, in order to work through pain, you have to understand pain. Pain is a nervous-system response to intense or damaging stimuli. When someone strikes you, your body perceives the stimulus, nervous impulses fire, hormones flood your body, and your brain sends a message – Something has happened at XYZ location, be aware of it! Part of overcoming pain is overcoming fear. The fear of pain intensifies pain and prevents you from thinking through the problem. This does not help, so it can also be important to experience pain as a means of overcoming a fear of pain. Finally, it's important to notice that it's the brain that sends the impulse as to how pain is perceived. There are those who, either through an addiction to the hormone release, or through mental control, or even through misfiring of neurons experience pain as a pleasurable sensation. *Since the brain tells the body what to feel and how, we have an opportunity to change our interpretation of that pain, maintaining acknowledgment that it is a warning of imminent danger, but perceiving it as a welcome message, rather than a crippling one*. Now let's answer your questions. > > How do you train attacks/defense while in physical pain? > > > The problem that most practitioners experience is that they jump straight into pain. That is, from the first moment, they're taught to feel pain, to tap out, and the pain ends. This instills a fear of pain. Like a child learning to walk, you have to take easy first steps, not attempt to run full out. First, experience pain. When I was first faced with this same issue, my *shidoshi* (instructor in the Bujinkan) was using me as the class *uke*, demonstrating techniques on me with regularity, and always taking them to a final control. After a bit of this, he would make the pain excruciating; I would be screaming in pain. Eventually, I knew that I had to take the pain, and I began to "drift off". I would use visualization to get myself into a nice place (I have a fondness for Maui, so I'd visualize myself on the beach there), only to be wrenched back to reality, being told I needed to experience it. He was right. Once you experience pain, you can isolate the pain. Use the pain, and feel for it; what direction is the pain moving, how are you contributing to it, and, most importantly, what happens when I breathe? A French obstetrician by the name of Dr. Fernand Lamaze, in the 1940s, became rather fascinated with the techniques practiced by midwives in the Soviet Union. Many of these practices included breathing and relaxation techniques guided by the midwife during childbirth, and led to the development of a series of techniques designed to increase a woman's confidence in her ability to give birth. Similarly, these techniques are used by (and may stem from) Cossack practices for avoiding or shrugging off pain, by giving the mind something else to focus on. The human brain is fairly well maxed out most of the time on its ability to multi-task, and forcing a specific focal behavior (e.g. breathing) can be distracting. Distraction, as you'll note I'd already found, is imperative in blocking pain. Finding a distraction that allows you to stay active and focused is far better than imagining yourself on a beach in Hawaii. When you find yourself in pain, first start breathing in forced deep breaths. While you do so, find the source of your pain. Once you find the source, the most general rule of escape is to move toward the pain. Note the way you need to move in performing escapes from shoulder locks, wrist locks, chokes, etc. when you're training escapes. Pain wants to draw you away from the thing hurting you; sometimes to escape a burning house you need to leap through flames. > > Are there safe ways to cause a lot of physical pain without long term damage? > > > Well, yes and no... Any impact injury carries risk. Any rending, tearing, pulling, grabbing, etc. can have the risk of dislodging a blood clot leading to infarction; grappling could lead to fracture and bone shards could cause an embolism. That said, so long as you're carefully training, these risks are minimum. Training with a partner you trust is key. Exploring your pain threshold carefully can lead you to a greater understanding of when enough is enough, always being careful to push just past where you want to tap. You want the immediate result, but ***there is no easy way to learn to overcome pain***. It's equal parts personal resolve and psychological trickery to move past the things that cause you intense pain. > > How do you learn to recognize when there is too much physical pain? > > > Very good question. Before you begin training to resist pain, you need to learn what causes you pain. Work with a partner in slowly inflicting pain upon each other, being careful to not injure the other, and resolving to push further than you'd normally allow before tapping. Generally, if you can't escape from this level of training, then you just need to tap. Your partner should continue to slowly apply greater pain until you tap or escape. If something gets torn, you've gone too far. Careful training is vital, and only you can know your limits. > > Here are some examples of pain that I have experienced but was unable to overcame as quick as I'd like: > > > This is irrelevant. All pain offers the same effects. The compression of the sciatic nerve leads to a collapse in the legs, compression of the suprascapular nerve leads to a numbing of the arm. But pain is pain. These nerves carry impulses, and you can not overcome their compression immediately; it's a physiological function. The pain you feel, however, you can overcome, but to do so quickly will mean practice. Nothing comes overnight. For those that cause a momentary loss of function, train from the position to which you're dropped. Do that, and you'll still be defensible.
I'm glad you clarified your question. The question I see there is not "how can I overcome pain" but "can I overcome (partial) paralysis?". The answer is simple: no, you can't. Weak spots are just that, weak, and should be defended. Your problem is not - apparently - the simple pain.
29,045,500
In the code, you can see that there is register of state ( reg [N-1] State). i want to access the 10 bits of state in 10 different signal or register or we can say wires. how is this possible. ?? i used assign statement but i want to make a logic for clock. This gives an error Line 33: Syntax error near "<=" ``` module Genes_Network #( N =10 // ) ( input Clock , input Reset , // input reg [N-1:0] Satein, output reg [N-1 : 0] State_Gene ); reg [N-1:0] State ; reg Fgf8,Emx2, Pax6,Coup_tfi,Sp8; // Genes reg F,E,P,C,S ; // Proteins // Fgf8 <= State[9] ; F <= State[N-2] ; E <= State[N-4] ; Pax6 <= State[N-5] ; Emx2 <= State[N-3] ; P <= State[N-6] ; Coup_tfi<= State[N-7] ; C <= State[N-8] ; Sp8 <= State[N-8] ; S <= State[N-9] ; always @(posedge Clock ) //Network LOgic Fgf8 <= F & (~E) & S; endmodule ```
2015/03/14
[ "https://Stackoverflow.com/questions/29045500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4286661/" ]
Not sure if this helps but I save my bitmapped images to parse like this, this is after taking the photo with the camera. ``` @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { byte[] image_byte_array; if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { post_object = new Post(); Bundle extras = data.getExtras(); image = (Bitmap) extras.get("data"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.PNG, 100, stream); image_byte_array = stream.toByteArray(); picture_file = new ParseFile("Picture", image_byte_array); picture_file.saveInBackground(); post_object.put("Image", picture_file); post_object.saveInBackground(); } } ```
i have a similar code in my proyect, and i save the image of an user on Parse with this and show in a ParseImageView, and it work: ``` protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumn = {MediaStore.Images.Media.DATA}; Cursor cursor = getContentResolver().query( selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath); ByteArrayOutputStream stream = new ByteArrayOutputStream(); yourSelectedImage.compress(Bitmap.CompressFormat.PNG, 100, stream); // put on my imageview // ImagenParseUserNavigation.setImageBitmap(yourSelectedImage); // ImagenParseUser.setImageBitmap(yourSelectedImage); byte[] image = stream.toByteArray(); ParseUser currentUser = ParseUser.getCurrentUser(); ParseFile photoFile = new ParseFile("fotoperfil"+currentUser.getUsername()+".png",image); currentUser.put("Imagen", photoFile); currentUser.saveInBackground(); } } ```
35,871,602
So I installed CentOs in a VM and then elastic search, I set up it's network as bridge. Elasticsearch 1.7.3 is of course running. I can SSH to it without issue however curl is not working ``` curl '163.113.183.229:9200/_cat/indices?v' curl: (7) couldn't connect to host ``` What can I look at to identify the problem? Thanks EDIT ==== CentOs 7 block the port 80 which I opened but no change : ``` firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --reload ```
2016/03/08
[ "https://Stackoverflow.com/questions/35871602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2105339/" ]
You can use javascript as ``` function sendMail() { var body = document.getElementById("contact_message").value; window.location.href = "mailto:[email protected]?subject=Mail request&body="+body; } ``` Call function as ``` <a class="submit" onclick="sendMail()">Send mail</a> ```
```js function MyFunction(){ var email = document.getElementById("input").value; window.location.href = "mailto:" + email + "?subject=Test email&body=Testing email"; } ``` ```html <!DOCTYPE html> <html> <head> </head> <body> <input type="text" id="input"/> <button onclick="MyFunction()">Click</button> </body> </html> ```
8,287,341
How to animate the movement of annotations on the MKMapView? When position of annotation is changed, then annotation moving to other position with animation?
2011/11/27
[ "https://Stackoverflow.com/questions/8287341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/183527/" ]
[This](https://stackoverflow.com/questions/8564013/animate-removal-of-annotations/8564097#8564097) question has the answer. Simply wrapping coordinate change in UIView animateWithDuration seems to work fine: ``` [UIView animateWithDuration:0.3f animations:^{ myAnnotation.coordinate = newCoordinate; }] ```
You need to use these delegate methods for that `setRegion:animated:` & `regionThatFits:` ``` [mapView setRegion:region animated:YES]; [mapView regionThatFits:region]; ``` Also mind you that the map update doesn't work with animation when using SIMULATOR. When you try `setCenterCoordinate:animated:` on the device, it does work with animation.
3,011
In the series [*A Song of Ice and Fire*](http://en.wikipedia.org/wiki/A_Song_of_Ice_and_Fire), dragons always occur in groups of three - The three conquering dragons, the three eggs etc. Somewhere, it's also implied that there should be three dragon-controllers (I forgot where, but this is what I remember). > > So if Danaerys is one, Jon the second. > > > Who is the third head? Has there been any discussions about this somewhere?
2011/04/25
[ "https://scifi.stackexchange.com/questions/3011", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/947/" ]
The most common suggestion for the third head is > > Tyrion. > > >
While Mike's answer is correct , I want to say that most of the discussions seem to be weak. > > I believe it much more likely that Daenerys' brother was the third head. After all, nowhere does it say that one of the heads can't die after he/she is born. > > >
3,011
In the series [*A Song of Ice and Fire*](http://en.wikipedia.org/wiki/A_Song_of_Ice_and_Fire), dragons always occur in groups of three - The three conquering dragons, the three eggs etc. Somewhere, it's also implied that there should be three dragon-controllers (I forgot where, but this is what I remember). > > So if Danaerys is one, Jon the second. > > > Who is the third head? Has there been any discussions about this somewhere?
2011/04/25
[ "https://scifi.stackexchange.com/questions/3011", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/947/" ]
The most common suggestion for the third head is > > Tyrion. > > >
> > In Book 4, Maester Aemon, dying, says to Sam that he thought he'd be the third. > > >
3,011
In the series [*A Song of Ice and Fire*](http://en.wikipedia.org/wiki/A_Song_of_Ice_and_Fire), dragons always occur in groups of three - The three conquering dragons, the three eggs etc. Somewhere, it's also implied that there should be three dragon-controllers (I forgot where, but this is what I remember). > > So if Danaerys is one, Jon the second. > > > Who is the third head? Has there been any discussions about this somewhere?
2011/04/25
[ "https://scifi.stackexchange.com/questions/3011", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/947/" ]
The most common suggestion for the third head is > > Tyrion. > > >
Now that *A Dance with Dragons* has been released I believe it's worth adding another answer to this question. ***A Dance with Dragons*** spoiler --- > > It seems more likely now that one of the dragons is Aegon Targaryen. Aegon Targaryen was the second child and only son of Prince Rhaegar Targaryen and Elia Martell. It is revealed that the baby murdered during the Sack of King's Landing was that of a peasant who Lord Varys put in the cot. Varys then hid baby Aegon. When Robert Baratheon and the realm falsely believed him dead, Varys had agents smuggle him across the narrow sea. [Aegon\_Targaryen @ asoif wiki](http://awoiaf.westeros.org/index.php/Aegon_Targaryen). > > > Also > > It now seems possible, although not certain, that Jon Snow isn't one of the three; so the other answers could still be just as accurate. > > >
3,011
In the series [*A Song of Ice and Fire*](http://en.wikipedia.org/wiki/A_Song_of_Ice_and_Fire), dragons always occur in groups of three - The three conquering dragons, the three eggs etc. Somewhere, it's also implied that there should be three dragon-controllers (I forgot where, but this is what I remember). > > So if Danaerys is one, Jon the second. > > > Who is the third head? Has there been any discussions about this somewhere?
2011/04/25
[ "https://scifi.stackexchange.com/questions/3011", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/947/" ]
The most common suggestion for the third head is > > Tyrion. > > >
Spoiler: It has been discussed. The most popular contenders for the third head are: > > 1. Tyrion (he has a fascination with dragons, also there is a theory that Tyrion may unknowingly be the son of Aerys and Joanna) > > 2. Bran (he's a powerful warg and maybe dragons can be warged, also he has a connection with 'flying') > > 3. Aegon (though there is some speculation that he may not actually be Aegon Targaryen) > > >
3,011
In the series [*A Song of Ice and Fire*](http://en.wikipedia.org/wiki/A_Song_of_Ice_and_Fire), dragons always occur in groups of three - The three conquering dragons, the three eggs etc. Somewhere, it's also implied that there should be three dragon-controllers (I forgot where, but this is what I remember). > > So if Danaerys is one, Jon the second. > > > Who is the third head? Has there been any discussions about this somewhere?
2011/04/25
[ "https://scifi.stackexchange.com/questions/3011", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/947/" ]
Now that *A Dance with Dragons* has been released I believe it's worth adding another answer to this question. ***A Dance with Dragons*** spoiler --- > > It seems more likely now that one of the dragons is Aegon Targaryen. Aegon Targaryen was the second child and only son of Prince Rhaegar Targaryen and Elia Martell. It is revealed that the baby murdered during the Sack of King's Landing was that of a peasant who Lord Varys put in the cot. Varys then hid baby Aegon. When Robert Baratheon and the realm falsely believed him dead, Varys had agents smuggle him across the narrow sea. [Aegon\_Targaryen @ asoif wiki](http://awoiaf.westeros.org/index.php/Aegon_Targaryen). > > > Also > > It now seems possible, although not certain, that Jon Snow isn't one of the three; so the other answers could still be just as accurate. > > >
While Mike's answer is correct , I want to say that most of the discussions seem to be weak. > > I believe it much more likely that Daenerys' brother was the third head. After all, nowhere does it say that one of the heads can't die after he/she is born. > > >
3,011
In the series [*A Song of Ice and Fire*](http://en.wikipedia.org/wiki/A_Song_of_Ice_and_Fire), dragons always occur in groups of three - The three conquering dragons, the three eggs etc. Somewhere, it's also implied that there should be three dragon-controllers (I forgot where, but this is what I remember). > > So if Danaerys is one, Jon the second. > > > Who is the third head? Has there been any discussions about this somewhere?
2011/04/25
[ "https://scifi.stackexchange.com/questions/3011", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/947/" ]
Now that *A Dance with Dragons* has been released I believe it's worth adding another answer to this question. ***A Dance with Dragons*** spoiler --- > > It seems more likely now that one of the dragons is Aegon Targaryen. Aegon Targaryen was the second child and only son of Prince Rhaegar Targaryen and Elia Martell. It is revealed that the baby murdered during the Sack of King's Landing was that of a peasant who Lord Varys put in the cot. Varys then hid baby Aegon. When Robert Baratheon and the realm falsely believed him dead, Varys had agents smuggle him across the narrow sea. [Aegon\_Targaryen @ asoif wiki](http://awoiaf.westeros.org/index.php/Aegon_Targaryen). > > > Also > > It now seems possible, although not certain, that Jon Snow isn't one of the three; so the other answers could still be just as accurate. > > >
> > In Book 4, Maester Aemon, dying, says to Sam that he thought he'd be the third. > > >
3,011
In the series [*A Song of Ice and Fire*](http://en.wikipedia.org/wiki/A_Song_of_Ice_and_Fire), dragons always occur in groups of three - The three conquering dragons, the three eggs etc. Somewhere, it's also implied that there should be three dragon-controllers (I forgot where, but this is what I remember). > > So if Danaerys is one, Jon the second. > > > Who is the third head? Has there been any discussions about this somewhere?
2011/04/25
[ "https://scifi.stackexchange.com/questions/3011", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/947/" ]
Now that *A Dance with Dragons* has been released I believe it's worth adding another answer to this question. ***A Dance with Dragons*** spoiler --- > > It seems more likely now that one of the dragons is Aegon Targaryen. Aegon Targaryen was the second child and only son of Prince Rhaegar Targaryen and Elia Martell. It is revealed that the baby murdered during the Sack of King's Landing was that of a peasant who Lord Varys put in the cot. Varys then hid baby Aegon. When Robert Baratheon and the realm falsely believed him dead, Varys had agents smuggle him across the narrow sea. [Aegon\_Targaryen @ asoif wiki](http://awoiaf.westeros.org/index.php/Aegon_Targaryen). > > > Also > > It now seems possible, although not certain, that Jon Snow isn't one of the three; so the other answers could still be just as accurate. > > >
Spoiler: It has been discussed. The most popular contenders for the third head are: > > 1. Tyrion (he has a fascination with dragons, also there is a theory that Tyrion may unknowingly be the son of Aerys and Joanna) > > 2. Bran (he's a powerful warg and maybe dragons can be warged, also he has a connection with 'flying') > > 3. Aegon (though there is some speculation that he may not actually be Aegon Targaryen) > > >
93
Software Escrow (SE) is about getting a 3rd party involved, trusted by 2 parties, where pieces of software components (Artefacts?) get deposited, with al sorts of "strings attached". If you know a bit about SCM (Software Change Management), then you'll understand (as I like to explain it) it's a special kind of SCM. But because of its nature, all sorts of extra challenges show up. Think of a legal person, such as a lawyer, acting as a release manager (not knnowing at all what the software application is supposed to do) ... fun garanteed! So is SE on-topic or not?
2017/03/11
[ "https://devops.meta.stackexchange.com/questions/93", "https://devops.meta.stackexchange.com", "https://devops.meta.stackexchange.com/users/40/" ]
As for any pay only software, with some luck someone with enough expertise may be able to answer your question. As long as the question describe a real problem with enough details and background I see no reason to bring them off topic, but therés a good chance you won't get an answer as the question about got smudge and ansible vault [here](https://devops.stackexchange.com/questions/106/git-clean-smudge-filters-for-ansible-vault-secrets). Main difference is that ansible is free, someone willing to tackle the problem can install, test and'maybe answer.
Depositing to a Software Escrow is fundamentally just another variation of a delivery in the software development process. Which can considered for automation. I'd definitely consider it on-topic for DevOps.
296,442
We use SASS when building custom themes, and sometimes clients need a quick change made which is easier to do on the server rather than locally and pushing new changes. To that end, we've installed SASS on our server to watch for file changes. The problem is, if we use the WordPress Appearance Editor to edit SASS files, it defaults to tabs instead of spaces and we use spaces in the office. So SASS compiler (transpiler?) throws an error. Is there any way to force the WordPress Appearance Editor to use Spaces instead of Tabs? I tried a quick search but everything seemed to be related to the WYSIWYG editor in pages/posts.
2018/03/11
[ "https://wordpress.stackexchange.com/questions/296442", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/90498/" ]
The WordPress theme/plugin (file) editor uses [CodeMirror](http://codemirror.net/) for syntax highlighting, and with the hook [`wp_enqueue_code_editor`](https://developer.wordpress.org/reference/functions/wp_enqueue_code_editor/) (which is available starting from WordPress version 4.9.0), you can filter the default CodeMirror settings, as in the following example: ``` add_filter( 'wp_code_editor_settings', function( $settings ) { $settings['codemirror']['indentUnit'] = 2; $settings['codemirror']['indentWithTabs'] = false; return $settings; } ); ``` See <http://codemirror.net/doc/manual.html#config> if you'd like to change other CodeMirror settings. PS: You'd add the code above to the theme's *functions.php* file.
The wordpress editor should not be used, end of story. In addition to forcing a security hole, how do you git the changes, how do you test them before applying to production?? The proper solution is to teach your clients the way of the GIT (command line in general), failing that, if all that is needed is CSS changes, they can do it in the customizer, which still violates "best practice" but at least you can test it properly before applying it to the live setup.
6,131,764
I'm facing a strange issue. I have a method which populates an array with some data (fetchData) (quite a lot actually and it's a bit slow). I'm using the array to build the rows of the table. I've tried calling fetchData in a number of places in my code, at various times in the construction of the view and I always seem to get the following: a black screen which is shown until the data from the array is loaded. I've called fetchData from the following: * (void)viewDidLoad; * (void)viewWillAppear:(BOOL)animated; * (void)viewDidAppear:(BOOL)animated; Since I'm using a navigation view controller, having the app appear to hang is pretty bad looking since it gets stuck on a black screen. What I was hoping my code would achieve was displaying an empty table, with a progress indicator until the data is loaded - then refresh. Unfortunately I'm not getting this far since the view isn't being loaded no matter where I call fetchData. Help appreciated! P.S. To get around this problem I even tried using a TTTableViewController, but the Loading view is never displayed. Typical. *sigh*
2011/05/25
[ "https://Stackoverflow.com/questions/6131764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/87336/" ]
Your load method must be blocking the UI. You should move it to another thread and let the data load there. You can instantiate the thread in `viewDidLoad`. This is a skeleton code for that you need to (using GCD) ``` dispatch_queue_t downloadQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(downloadQueue, ^{ ... Move all the loading part here. dispatch_async(dispatch_get_main_queue(),^{ ... Do all the UI updates, mostly, [tableView reloadData]; }) }) ```
It possible that you could add a timer to delay the call somewhere in your `viewDidAppear` method. For example: ``` - (void)viewDidAppear:(BOOL)animated { [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(fetchData) userInfo:nil repeats:NO]; } ``` This will give your app time to load the UI and start your loading screen, then start fetching the data later. You can also try fetching the data in a background thread if you would prefer to go that route
6,131,764
I'm facing a strange issue. I have a method which populates an array with some data (fetchData) (quite a lot actually and it's a bit slow). I'm using the array to build the rows of the table. I've tried calling fetchData in a number of places in my code, at various times in the construction of the view and I always seem to get the following: a black screen which is shown until the data from the array is loaded. I've called fetchData from the following: * (void)viewDidLoad; * (void)viewWillAppear:(BOOL)animated; * (void)viewDidAppear:(BOOL)animated; Since I'm using a navigation view controller, having the app appear to hang is pretty bad looking since it gets stuck on a black screen. What I was hoping my code would achieve was displaying an empty table, with a progress indicator until the data is loaded - then refresh. Unfortunately I'm not getting this far since the view isn't being loaded no matter where I call fetchData. Help appreciated! P.S. To get around this problem I even tried using a TTTableViewController, but the Loading view is never displayed. Typical. *sigh*
2011/05/25
[ "https://Stackoverflow.com/questions/6131764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/87336/" ]
Your load method must be blocking the UI. You should move it to another thread and let the data load there. You can instantiate the thread in `viewDidLoad`. This is a skeleton code for that you need to (using GCD) ``` dispatch_queue_t downloadQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(downloadQueue, ^{ ... Move all the loading part here. dispatch_async(dispatch_get_main_queue(),^{ ... Do all the UI updates, mostly, [tableView reloadData]; }) }) ```
I was having the same issue with a table view not loading initially, but it worked n another .m file I had. Here is the one that worked: add this to your viewDidLoad: ``` NSError *error = nil; if (![[self fetchedResultsController] performFetch:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } ``` and this to the implementation block: ``` #pragma mark - #pragma mark Fetched results controller - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController == nil) { // Create the fetch request for the entity. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as appropriate. NSEntityDescription *entity = [NSEntityDescription entityForName:@"OMFrackinG" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; ``` // grouping and sorting optional ``` //NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"country" ascending:YES]; NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"state" ascending:YES];// was name NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor1,sortDescriptor2, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; propriate. NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"state" cacheName:nil];//@"state" aFetchedResultsController.delegate = self; self.fetchedResultsController = aFetchedResultsController; [aFetchedResultsController release]; [fetchRequest release]; [sortDescriptor1 release]; [sortDescriptor2 release]; [sortDescriptors release]; } return fetchedResultsController; } ```
6,131,764
I'm facing a strange issue. I have a method which populates an array with some data (fetchData) (quite a lot actually and it's a bit slow). I'm using the array to build the rows of the table. I've tried calling fetchData in a number of places in my code, at various times in the construction of the view and I always seem to get the following: a black screen which is shown until the data from the array is loaded. I've called fetchData from the following: * (void)viewDidLoad; * (void)viewWillAppear:(BOOL)animated; * (void)viewDidAppear:(BOOL)animated; Since I'm using a navigation view controller, having the app appear to hang is pretty bad looking since it gets stuck on a black screen. What I was hoping my code would achieve was displaying an empty table, with a progress indicator until the data is loaded - then refresh. Unfortunately I'm not getting this far since the view isn't being loaded no matter where I call fetchData. Help appreciated! P.S. To get around this problem I even tried using a TTTableViewController, but the Loading view is never displayed. Typical. *sigh*
2011/05/25
[ "https://Stackoverflow.com/questions/6131764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/87336/" ]
It possible that you could add a timer to delay the call somewhere in your `viewDidAppear` method. For example: ``` - (void)viewDidAppear:(BOOL)animated { [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(fetchData) userInfo:nil repeats:NO]; } ``` This will give your app time to load the UI and start your loading screen, then start fetching the data later. You can also try fetching the data in a background thread if you would prefer to go that route
I was having the same issue with a table view not loading initially, but it worked n another .m file I had. Here is the one that worked: add this to your viewDidLoad: ``` NSError *error = nil; if (![[self fetchedResultsController] performFetch:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } ``` and this to the implementation block: ``` #pragma mark - #pragma mark Fetched results controller - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController == nil) { // Create the fetch request for the entity. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as appropriate. NSEntityDescription *entity = [NSEntityDescription entityForName:@"OMFrackinG" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; ``` // grouping and sorting optional ``` //NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"country" ascending:YES]; NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"state" ascending:YES];// was name NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor1,sortDescriptor2, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; propriate. NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"state" cacheName:nil];//@"state" aFetchedResultsController.delegate = self; self.fetchedResultsController = aFetchedResultsController; [aFetchedResultsController release]; [fetchRequest release]; [sortDescriptor1 release]; [sortDescriptor2 release]; [sortDescriptors release]; } return fetchedResultsController; } ```
68,051,284
I have the following URL queryString `index.html?cars=honda+nissan&price=90+60+70` and need to remove all the characters `=, +, &`. When I chain the split it returns `split is not a function` Desired output; ``` honda nissan 90 60 70 ``` JS: ``` const urlSearch = window.location.search; const param = urlSearch.split('=')[1].split('&'); ```
2021/06/19
[ "https://Stackoverflow.com/questions/68051284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/992731/" ]
Since your initial string is JSON, you can easily parse it with `json_decode()`. Then just iterate through the array and `explode()` the `"val"` by the delimiter `,,` and add it to an array. ``` <?php $string = '[{"val":"agent,,james,,89","number":0,"dID":0}, {"val":"house,,Villa,,389m","number":1,"dID":2}]'; $json = json_decode($string, true); $output = []; foreach($json as $elm) { $val = $elm["val"]; $words = explode(",,", $val); $output[] = $words; } var_dump($output); ?> ``` This gives $output a value of ``` [["agent", "james", "89"], ["house", "villa", "389m"]] ``` [Demo here](http://sandbox.onlinephpfunctions.com/code/616ad6f4d7a538231d047ed1873388762e1ba313)
You have an accepted answer, but I was bored: ``` $result = array_map(function($v) { return explode(',,', $v['val']); }, json_decode($string, true)); ```
2,342,682
I know that over a field, every non-invertible matrix is a zero divisor. Does the same hold for matrices over an arbitrary commutative ring?
2017/07/01
[ "https://math.stackexchange.com/questions/2342682", "https://math.stackexchange.com", "https://math.stackexchange.com/users/360858/" ]
In $p$-adics any integer ending with $0$ is noninvertible, but a zero product requires a zero factor. Multiplication of two $p$-adic integers with only a finite number of total terminal zero digits gives a product with only that number of terminal zeroes.
The determinant makes sense for matrices over a commutative ring $R$ and it's easy to prove that the square matrix $A$ is invertible if and only if $\det A$ is invertible in the base ring. On the other hand, if $d=\det A$ is not a zero divisor, then it becomes invertible in the full ring of quotients $Q(R)$ of $R$ (that is, $S^{-1}R$, where $S$ is the set of non zero divisors, which is a multiplicative set). Thus the matrix $A$ becomes invertible when seen (via the canonical map $\lambda\colon R\to Q(R)$) as a matrix with entries in $Q(R)$. If $A$ is a (left) zero divisor (over $R$), there exists a nonzero matrix $B$ with $AB=0$. However, the canonical map $\lambda$ is injective, so when we see these matrices over $Q(R)$ we have the same relation and invertibility of $A$ forces $B=0$: contradiction. The same if $A$ is a right zero divisor. Thus $A$ can be a zero divisor only if $\det A$ is a zero divisor in $R$ (including $0$, of course).
2,342,682
I know that over a field, every non-invertible matrix is a zero divisor. Does the same hold for matrices over an arbitrary commutative ring?
2017/07/01
[ "https://math.stackexchange.com/questions/2342682", "https://math.stackexchange.com", "https://math.stackexchange.com/users/360858/" ]
In the case of $1\times 1$ matrices, which are just elements of the ring, you are asking whether every non-unit in a ring must be a zero divisor. This is obviously false, for instance, in the ring $\mathbb{Z}$.
The determinant makes sense for matrices over a commutative ring $R$ and it's easy to prove that the square matrix $A$ is invertible if and only if $\det A$ is invertible in the base ring. On the other hand, if $d=\det A$ is not a zero divisor, then it becomes invertible in the full ring of quotients $Q(R)$ of $R$ (that is, $S^{-1}R$, where $S$ is the set of non zero divisors, which is a multiplicative set). Thus the matrix $A$ becomes invertible when seen (via the canonical map $\lambda\colon R\to Q(R)$) as a matrix with entries in $Q(R)$. If $A$ is a (left) zero divisor (over $R$), there exists a nonzero matrix $B$ with $AB=0$. However, the canonical map $\lambda$ is injective, so when we see these matrices over $Q(R)$ we have the same relation and invertibility of $A$ forces $B=0$: contradiction. The same if $A$ is a right zero divisor. Thus $A$ can be a zero divisor only if $\det A$ is a zero divisor in $R$ (including $0$, of course).
15,955,157
I have two tables in mysql. * Table 1 contains a column called `app_id` * Table 2 contains a column called `id` I need to create a query that will show all table 1 columns for any row where `app_id` is not present in table 1's id. For example: Table 1: ``` app_id 1 2 3 4 5 ``` Table 2: ``` id 1 3 4 5 ``` So my results will be the columns of table 1 showing the `app_id=2` since that is not found in table 2
2013/04/11
[ "https://Stackoverflow.com/questions/15955157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1316445/" ]
You could do ``` SELECT app_id FROM tableOne WHERE app_id NOT IN(SELECT id from tableTwo) ```
Just do a left join, then select rows that don't match: ``` SELECT * FROM table_1 LEFT JOIN table_2 ON table_1.app_id = table_2.id WHERE table_2.id IS NULL; ```
43,066,220
I've noticed that connection strings link is missing on settings section in Azure Portal. I was following [this tutorial](https://learn.microsoft.com/en-us/azure/documentdb/documentdb-connect-mongodb-account "This tutorial") in order to use .NET mongodb driver to work with Azure DocumentDB. Look at the image below(from the tutorial) [![enter image description here](https://i.stack.imgur.com/ZIou8.png)](https://i.stack.imgur.com/ZIou8.png) And in my azure portal it does not show the connection strings. [![enter image description here](https://i.stack.imgur.com/P5NEI.png)](https://i.stack.imgur.com/P5NEI.png)
2017/03/28
[ "https://Stackoverflow.com/questions/43066220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6002830/" ]
The `Connection Strings` option appears when you configure a database with MongoDB compatibility (which you must choose when creating your new database: [![mongo compat enable](https://i.stack.imgur.com/SeSqs.jpg)](https://i.stack.imgur.com/SeSqs.jpg) Once you do this, you'll then have the `Connection String` option: [![mongo connection string](https://i.stack.imgur.com/ZSMWQ.jpg)](https://i.stack.imgur.com/ZSMWQ.jpg) With databases where you have not enabled MongoDB compatibility, you're correct that the connection info appears under `Keys`: [![DocumentDB keys](https://i.stack.imgur.com/dL0TH.jpg)](https://i.stack.imgur.com/dL0TH.jpg)
I've managed to build my connection string by comparing the tutorial screen shots and the information that is on my Azure Portal. I've navigate to **Keys** link, and used the **Primary Key** as **Password** but that's not very obvious since the word may confuse the reader. Also the **Port 10250** that is shown in the tutorial is not mentioned anywhere in the Azure Portal, I've just tried it and it worked. It makes me believe that connection strings link is missing on purpose and not due a bug. For those who are looking for the **Connection Strings** link to complete the tutorial here's what I did. ``` string endpoint = "bi4all-nosql"; //Your DocumentDB Name string password ="********"; //Primary Key string ConnectionString = $"mongodb://{endpoint}:{password}@{endpoint}.documents.azure.com:10250/?ssl=true"; MongoClientSettings settings = MongoClientSettings.FromUrl(new MongoUrl(ConnectionString)); settings.SslSettings = new SslSettings { EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12 }; MongoClient client = new MongoClient(settings); ```
306,193
I am unable to partially select text in titles. For example, if I want to select `processing a sorted array` part of the following title, I must start from the left or the right, I cannot partially select it because it's a link. [![Sample select](https://i.stack.imgur.com/snNbr.png)](https://i.stack.imgur.com/snNbr.png) I see two possible solutions: 1. Solve with JavaScript: if a person clicks somewhere on the title and moves the mouse, select that text 2. Don't make titles links: do title of posts need to link to themselves? What is the logic in that?
2015/09/16
[ "https://meta.stackoverflow.com/questions/306193", "https://meta.stackoverflow.com", "https://meta.stackoverflow.com/users/1004708/" ]
Assuming Windows, hold the `Alt` key while selecting text that are also links, it's a standard browser feature. See [How to Select Hyperlink Text in Google Chrome?](//superuser.com/q/173200): > > Pressing ALT while selecting text prevents hyperlinks being followed, and therefore allows all or partial text in links to be selected and copied. > > > This applies, at least, to both Firefox and Chrome. * On Macs, use the `Option ⌥` key. * On Linux, use `Super`+`Alt`
I never use the title for anything other than reading and editing but this doesn't seem to be too hard. Let me demonstrate with a drawring [![enter image description here](https://i.stack.imgur.com/Vh97q.png)](https://i.stack.imgur.com/Vh97q.png)
37,732,822
Im new to node, javascript and what not and I ran in to a no Access-control-allow-origin error when trying to do a get using XMLHttpRequest. Ive looked everywhere for a solution but nothing seems to be working. Any suggestions would be great. I would appreciate everything I really want to be able to get better at node, javascript, and html stuff so let me know if you notice something i shouldn't be doing. Also I have \* out some of the important stuff just to be private. The error ``` XMLHttpRequest cannot load http://*************. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://************' is therefore not allowed access. ``` my main parts of server.js ``` var express = require('express'); var path = require('path'); var server = express(); var http = require('http'); var fs = require('fs'); var formidable = require("formidable"); var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; var xhr = new XMLHttpRequest(); var request = require("request"); var port = process.env.port || 63342; // Define ./public as static server.use(express.static(path.join(__dirname, 'public'))); // // as you can see Ive added this to try to fix the problem // server.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }); //All POST's use processFormFieldsIndividual server.post('*', processFormFieldsIndividual); server.listen(port, function () { console.log('listening on port ' + port); }); ``` test.js ``` function addTable() { var uri = '***************'; var r = new XMLHttpRequest(); r.open("GET", uri, true); console.log(r.toString()); r.onreadystatechange = function () { if (r.readyState == 4 && (r.status == 201 || r.status == 200)) { var json = JSON.parse(r.responseText); // use json to make table in html logic } else { console.log("food"); } }; r.send(); } ``` index.html ``` <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/html"> <head> <script src="js/test.js"></script> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href=""> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="css/jumbotron.css" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <img src="images/taskbar.png" alt="navbar-header" border="0"> </div> <div id="navbar" class="navbar-collapse collapse"> </div><!--/.navbar-collapse --> <br> </div> </nav> <br> <d iv class=container2> <form role="form" action="" method="post" enctype="multipart/form-data"> <fieldset> /* * my form logic goes here */ </fieldset> </form> <div id="metric_results"> <input type="button" id="create" value="Click here" onclick="Javascript:addTable()"> </div> </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script> <script src="js/bootstrap.min.js"></script> </body> </html> ```
2016/06/09
[ "https://Stackoverflow.com/questions/37732822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3646746/" ]
I suspect that it's an order of operations issue: ``` !is.na(x) %>% sum ``` is evaluating to ``` !(is.na(x) %>% sum) ``` Which is equivalent to `TRUE`
Although I accepted @C-Z\_ 's answer I want to add another to provide context on this. Thanks to @rawr for directing me to `?Syntax`. Basically `%>%` is considered to be an operator, like `%in%` and as such it has to obey the order of operations. On the `Syntax` help page this corresponds to the `%any%` operator (i.e. any infix operator), as users can define these at will. As it happens, this means that `%>%` fires before any logical operator and also before arithmetic operators (e.g. `*` and `\`). As a result, if you are naively, like I was, thinking that the left side of `%>%` will complete before the next step in the chain, you can get some surprises. For example: ``` 3+2 %>% '*'(4) %>% `/`(2) ``` Does not do `3+2=5, 5*4= 20, 20/2=10` instead it does `2*4/2=4, 4+3=7`, because the `%>%` has precedence over `+`. If you use the functions in the `magrittr` package such as: ``` add(3,2) %>% multiply_by(4) %>% divide_by(2) ``` You get `10` as expected. Placing brackets around the `3+2` will also get you `10`. In my original examples, the logical operators, such as `!` have a lower precedence than `%>%`, so they act last, after the sum has competed. Moral of the story: Be careful mixing `%>%` with other operators.
37,732,822
Im new to node, javascript and what not and I ran in to a no Access-control-allow-origin error when trying to do a get using XMLHttpRequest. Ive looked everywhere for a solution but nothing seems to be working. Any suggestions would be great. I would appreciate everything I really want to be able to get better at node, javascript, and html stuff so let me know if you notice something i shouldn't be doing. Also I have \* out some of the important stuff just to be private. The error ``` XMLHttpRequest cannot load http://*************. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://************' is therefore not allowed access. ``` my main parts of server.js ``` var express = require('express'); var path = require('path'); var server = express(); var http = require('http'); var fs = require('fs'); var formidable = require("formidable"); var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; var xhr = new XMLHttpRequest(); var request = require("request"); var port = process.env.port || 63342; // Define ./public as static server.use(express.static(path.join(__dirname, 'public'))); // // as you can see Ive added this to try to fix the problem // server.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }); //All POST's use processFormFieldsIndividual server.post('*', processFormFieldsIndividual); server.listen(port, function () { console.log('listening on port ' + port); }); ``` test.js ``` function addTable() { var uri = '***************'; var r = new XMLHttpRequest(); r.open("GET", uri, true); console.log(r.toString()); r.onreadystatechange = function () { if (r.readyState == 4 && (r.status == 201 || r.status == 200)) { var json = JSON.parse(r.responseText); // use json to make table in html logic } else { console.log("food"); } }; r.send(); } ``` index.html ``` <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/html"> <head> <script src="js/test.js"></script> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href=""> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="css/jumbotron.css" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <img src="images/taskbar.png" alt="navbar-header" border="0"> </div> <div id="navbar" class="navbar-collapse collapse"> </div><!--/.navbar-collapse --> <br> </div> </nav> <br> <d iv class=container2> <form role="form" action="" method="post" enctype="multipart/form-data"> <fieldset> /* * my form logic goes here */ </fieldset> </form> <div id="metric_results"> <input type="button" id="create" value="Click here" onclick="Javascript:addTable()"> </div> </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script> <script src="js/bootstrap.min.js"></script> </body> </html> ```
2016/06/09
[ "https://Stackoverflow.com/questions/37732822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3646746/" ]
I suspect that it's an order of operations issue: ``` !is.na(x) %>% sum ``` is evaluating to ``` !(is.na(x) %>% sum) ``` Which is equivalent to `TRUE`
You can also use the "not" alias from the magrittr package: ``` > is.na(1:20) %>% not %>% sum ``` [1] 20
37,732,822
Im new to node, javascript and what not and I ran in to a no Access-control-allow-origin error when trying to do a get using XMLHttpRequest. Ive looked everywhere for a solution but nothing seems to be working. Any suggestions would be great. I would appreciate everything I really want to be able to get better at node, javascript, and html stuff so let me know if you notice something i shouldn't be doing. Also I have \* out some of the important stuff just to be private. The error ``` XMLHttpRequest cannot load http://*************. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://************' is therefore not allowed access. ``` my main parts of server.js ``` var express = require('express'); var path = require('path'); var server = express(); var http = require('http'); var fs = require('fs'); var formidable = require("formidable"); var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; var xhr = new XMLHttpRequest(); var request = require("request"); var port = process.env.port || 63342; // Define ./public as static server.use(express.static(path.join(__dirname, 'public'))); // // as you can see Ive added this to try to fix the problem // server.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }); //All POST's use processFormFieldsIndividual server.post('*', processFormFieldsIndividual); server.listen(port, function () { console.log('listening on port ' + port); }); ``` test.js ``` function addTable() { var uri = '***************'; var r = new XMLHttpRequest(); r.open("GET", uri, true); console.log(r.toString()); r.onreadystatechange = function () { if (r.readyState == 4 && (r.status == 201 || r.status == 200)) { var json = JSON.parse(r.responseText); // use json to make table in html logic } else { console.log("food"); } }; r.send(); } ``` index.html ``` <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/html"> <head> <script src="js/test.js"></script> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href=""> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="css/jumbotron.css" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <img src="images/taskbar.png" alt="navbar-header" border="0"> </div> <div id="navbar" class="navbar-collapse collapse"> </div><!--/.navbar-collapse --> <br> </div> </nav> <br> <d iv class=container2> <form role="form" action="" method="post" enctype="multipart/form-data"> <fieldset> /* * my form logic goes here */ </fieldset> </form> <div id="metric_results"> <input type="button" id="create" value="Click here" onclick="Javascript:addTable()"> </div> </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script> <script src="js/bootstrap.min.js"></script> </body> </html> ```
2016/06/09
[ "https://Stackoverflow.com/questions/37732822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3646746/" ]
Although I accepted @C-Z\_ 's answer I want to add another to provide context on this. Thanks to @rawr for directing me to `?Syntax`. Basically `%>%` is considered to be an operator, like `%in%` and as such it has to obey the order of operations. On the `Syntax` help page this corresponds to the `%any%` operator (i.e. any infix operator), as users can define these at will. As it happens, this means that `%>%` fires before any logical operator and also before arithmetic operators (e.g. `*` and `\`). As a result, if you are naively, like I was, thinking that the left side of `%>%` will complete before the next step in the chain, you can get some surprises. For example: ``` 3+2 %>% '*'(4) %>% `/`(2) ``` Does not do `3+2=5, 5*4= 20, 20/2=10` instead it does `2*4/2=4, 4+3=7`, because the `%>%` has precedence over `+`. If you use the functions in the `magrittr` package such as: ``` add(3,2) %>% multiply_by(4) %>% divide_by(2) ``` You get `10` as expected. Placing brackets around the `3+2` will also get you `10`. In my original examples, the logical operators, such as `!` have a lower precedence than `%>%`, so they act last, after the sum has competed. Moral of the story: Be careful mixing `%>%` with other operators.
You can also use the "not" alias from the magrittr package: ``` > is.na(1:20) %>% not %>% sum ``` [1] 20
26,250,353
hy all help me pleass.. I have quetions, how to grab text in event onlcik suing simple html dom for example : I have see in website like this ```html <a id="inquiry-agent-phone" class="tooltiped-links" data-toggle="tooltip" data-placement="right" onclick="scigineer_func('call');inquiryAgentPhoneLeads('xxx', 'xxx', 'xx', 'xxx', 'xxx')">+62-821-22...</a> ``` I do not know what the function of the applied and I want grab full text phone number Thanks
2014/10/08
[ "https://Stackoverflow.com/questions/26250353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3974085/" ]
Make sure to enable the **Allow less secure apps** option in Google account setting at <https://google.com/settings/security/lesssecureapps> -- from the second half of 2014, this is required to authenticate with Gmail SMTP using basic authentication. Alternatively, you can keep the above option disabled and implement XOAUTH2 for SMTP authentication (see <https://developers.google.com/gmail/xoauth2_protocol>).
It seems from your code that you'r enabling SSL by `smtp.EnableSsl = true;`. If you want to do it by same way, use 465 port. Below is the resolved answer link for relative problem: [How can I send emails through SSL SMTP with the .NET Framework?](https://stackoverflow.com/questions/1011245/how-can-i-send-emails-through-ssl-smtp-with-the-net-framework) If you find any difficulties, please do let me know.
24,047,236
I've got a form and when it's not filled out properly, Rails wraps it in a "field\_with\_errors" class. I've got a css.scss file in which I import Bootstrap, and I want to extend field\_with\_errors to use Bootstrap 3's form validation styling. I found this ``` .field_with_errors { @extend .control-group; @extend .error; } ``` But it didn't work, so I figured out that the classes were Bootstrap 2 classes. So I found their equivalents: ``` .field_with_errors { @extend .form-group; @extend .has-error; } ``` But this doesn't seem to have any effect. I'm completely new to Rails and Sass, can somebody give me a pointer?
2014/06/04
[ "https://Stackoverflow.com/questions/24047236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1172720/" ]
Alright, I'm a big ol' bootstrap noob, but I've found the problem. Here are all the references to has-error in the bootstrap source code ``` .has-error .help-block, .has-error .control-label, .has-error .radio, .has-error .checkbox, .has-error .radio-inline, .has-error .checkbox-inline { color: #a94442; } .has-error .form-control { border-color: #a94442; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); } .has-error .form-control:focus { border-color: #843534; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483; box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483; } .has-error .input-group-addon { color: #a94442; background-color: #f2dede; border-color: #a94442; } .has-error .form-control-feedback { color: #a94442; ``` As you can see, there's no plain .has-error styling. I thought I could just apply it to the class generated by rails and move on with my life. Turns out you still have to name the components with the proper `form-control` , `control-label` classes as well. But after you do that, my code works for bootstrap 3 with rails 4. Hopefully this helps someone else. Alternatively, I came up with this ugly way to just make it work with your basic ruby formhelper form. It's not DRY or anything, but it's less hassle. in custom.css.scss or wherever you do your css styling: ``` .field_with_errors { input{ border-color: #a94442; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075); } label { color: #a94442; } } ```
You can use this snippet: `.field-with-errors { @extend .has-error; }`
4,487,089
I have a script that is somehow inserts line breaks into the end of the data that is being inserted in SQL. I don't see anything in the script that is adding a line break. Is there a way to strip all line breaks inside the INSERT statement? I can't imagine what could be doing this. Thanks, Mike
2010/12/20
[ "https://Stackoverflow.com/questions/4487089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547794/" ]
Apply `TRIM()` mysql function to the needed fields. ``` INSERT INTO table (field) VALUES (TRIM('foobar')) ``` where `foobar` is your data. But better I would suggest to find why that script adds those newlines.
Thanks for the quick answers guys. I ended up using the php trim function right before the data insert - that worked.
23,121,962
So I have made a form with CodeIgniter and it does uses CodeIgniter's form validation class to validate input fields. I have a total of 6 input fields which all are required fields. I would like to show the same error of "This field is required" even if there are multiple empty fields, but right now it will show the error message for each of the fields. So if I leave every field empty, it will echo the same message 6 times. I won't paste any code here since I know how to use the actual validation class, just don't know how to implement it in a way as said above. Thanks in advance! E: Now comes another problem, it doesn't show any errors, in fact the whole method will fail right after it's checking if the "add\_user" button is submitted. I'm 100% sure that the name of my submit button is "add\_user". Sorry about bad indenting, I'll never learn how to use StackOverflow's indenting. Here's my controller for adding a user: ``` <?php class Users extends CI_Controller { public function add_user() { if($this->input->post('add_user')) { $this->load->model('subject'); $data['subjects'] = $this->subject->get_all_subjects(); $data['schools'] = $this->subject->get_all_schools(); $this->load->library('form_validation'); $this->form_validation->set_rules('f_name', 'Etunimi', 'required'); $this->form_validation->set_rules('l_name', 'Sukunimi', 'min_length[3]'); $this->form_validation->set_rules('email', 'Sähköpostiosoite', 'matches[email_confirm]|is_unique[users.email]|valid_email'); $this->form_validation->set_rules('email_confirm', 'Sähköpostiosoite', 'valid_email'); $this->form_validation->set_rules('phone_number', 'Puhelinnumero', 'min_length[7]|max_length[10]'); if($this->input->post('user_type') == "moderator") { $this->load->library('form_validation'); $this->form_validation->set_rules('school', 'Koulutalo', 'required'); $this->form_validation->set_rules('subject', 'Laji', 'required'); } $this->form_validation->set_message('required', 'Täyttämättömiä kenttiä'); $this->form_validation->set_message('min_length', '%s - kentässä on liian vähän merkkejä'); $this->form_validation->set_message('matches', 'Sähköpostit eivät täsmää'); $this->form_validation->set_message('is_unique', '%s on jo rekisteröity'); if($this->form_validation->run() == FALSE) { $this->output->set_content_type('application_json'); $this->output->set_output(json_encode(array('result' => 0, 'error' => $this->form_validation->error_array() ))); return false; } $first_part_username = substr($this->input->post('f_name'), 0, 2); $second_part_username = substr($this->input->post('l_name'), 0, 3); $first_part_username = strtolower($first_part_username); $second_part_username = strtolower($second_part_username); $this->load->helper('string'); $random_number = random_string('numeric', 4); $username = $first_part_username . $second_part_username .$random_number; $password = random_string('alnum', 8); $this->load->model('user'); $name = ucfirst($this->input->post('f_name')). " " .ucfirst($this->input->post('l_name')); $data = array ( 'name' => $name, 'email' => $this->input->post('email'), 'username' => $username, 'password' => $this->phpass->hash($password), 'user_type' => $this->input->post('user_type'), 'phone_number' => $this->input->post('phone_number'), 'subject_id' => !($this->input->post('subject')) ? null : $this->input->post('subject'), 'school_id' => !($this->input->post('school')) ? null : $this->input->post('school') ); $this->user->add_user($data); $this->load->library('email'); $config['mailtype'] = 'html'; $this->email->initialize($config); $this->email->from('[email protected]', 'Your Name'); $this->email->to($this->input->post('email')); $this->email->subject('test test'); $this->email->message('Test'); if($this->email->send()) { $this->output->set_content_type('application_json'); $this->output->set_output(json_encode(array('result'=>1, 'msg' => 'Uusi käyttäjä lisätty'))); } } /* It will echo out this one which is viewable from developer tab right after the form is submitted */ $this->output->set_content_type('application_json'); $this->output->set_output(json_encode(array('result'=>1, 'msg' => 'Form not submitted'))); } } ?> ``` And the javascript: ``` $(document).ready(function() { $("#add_user_form").on('submit', function(e) { e.preventDefault(); $("#loading_spinner").show(); var from = $(this); $.ajax({ url: from.attr('action'), type: from.attr('method'), data: $(from).serialize(), }).done(function(data) { if(data.result == 0) { $("#forgot-pass-success").hide(); $("#forgot-pass-error").show(); $("#forgot-pass-error").fadeIn(1000).html("<p>" + data.error + "</p>"); } if(data.result == 1) { $("#forgot-pass-error").hide(); $("#forgot-pass-success").show(); $("#forgot-pass-success").fadeIn(1000).html("<p>" + data.msg + "</p>"); } $("#loading_spinner").hide(); }, 'json'); return false; }); }); ```
2014/04/16
[ "https://Stackoverflow.com/questions/23121962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2411636/" ]
Here is an example that returns the errors in a JSON string to process with jQuery, you have to load the form validation helper. Load the library: ``` $this->load->library('form_validation'); /* Outputto Json Format */ $this->output->set_content_type('application_json'); /* Validate Form Data */ $this->form_validation->set_rules('login', 'Username', 'required|min_length[4]|max_length[16]|is_unique[user.login]'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[user.email]'); $this->form_validation->set_rules('password', 'Password', 'required|min_lenght[6]|max_length[16]|matches[confirm_password]'); /* Custom Messages */ $this->form_validation->set_message('required', 'You must enter a %s.'); $this->form_validation->set_message('is_unique', 'That %s is already in use, please try again.'); $this->form_validation->set_message('valid_email', 'You must enter a vaild email address.'); if($this->form_validation->run() == false) { $this->output->set_output(json_encode(['result' => 0, 'error' => $this->form_validation->error_array()])); return false; } $login = $this->input->post('login'); $email = $this->input->post('email'); $password = $this->input->post('password'); $confirm_password = $this->input->post('comfirm_password'); $user_id = // DO YOUR QUERY HERE if($user_id) { $this->session->set_userdata(['user_id' => $user_id]); $this->output->set_output(json_encode(['result' => 1])); return false; } $this->output->set_output(json_encode(['result' => 0, 'error' => 'User not created.'])); ``` EDIT: Sorry I'm using a custom library to extend the form\_validation so I can create arrays to return. Just make sure you save this in your library files as my\_form\_validation.php ``` class MY_Form_validation extends CI_Form_validation { // ------------------------------------------------------------------------ public function __construct($config = array()) { parent::__construct($config); } // ------------------------------------------------------------------------ public function error_array() { if(count($this->_error_array > 0)) { return $this->_error_array; } } // ------------------------------------------------------------------------ } ``` **EDIT: Example of dealing with this data in jQuery** ``` <!-- Javascript POST --> <script type="text/javascript"> $(function() { // You need to create a div called #register_form_error $("#register_form_error").hide(); // Your register form would go here in place of #regiser_form $("#register_form").submit(function(evt) { evt.preventDefault(); var url = $(this).attr('action'); var postData = $(this).serialize(); $.post(url, postData, function(o) { if (o.result == 1) { // If the registration was successful where to go. window.location.href = '<?=site_url('where to go')?>'; } else { // This is where all of the form errors will be displayed $("#register_form_error").show(); var output = '<ul>'; for (var key in o.error) { var value = o.error[key]; output += '<li>' + value + '</li>'; } output += '</ul>'; $("#register_form_error").html(output); } }, 'json'); }); }); </script> ``` Lastly: ``` if($this->input->post('add_user')) ``` Shoud be: ``` if($this->input->post('$_POST')) ``` That way you get the entire post array.
Off the top of my head, you could try using individual errors. In your view: ``` <?php $form_errors = array( form_error('field_1'), form_error('field_2'), form_error('field_3'), form_error('field_4'), form_error('field_5'), form_error('field_6') ); $error = FALSE; foreach ($form_errors as $form_error) { if ( ! empty($form_error)) $error = TRUE; } if ($error) echo "All fields are required". ?> ``` So basically what you are doing here, is filling an array of individual form errors. `form_error()` returns an empty string if the field is filled in correctly according to the validation rule, otherwise it will be an error message. To confirm that everything is filled in correctly, you are looking for an array of empty strings. If a field isn't filled in correctly, your array will contain an element which has an error message.
139,991
> > When I was 11, my sister bought our father a ''World Greatest Dad's'' > coffee mug, and frankly, the man **coasted** until the day he died. > > > This sentence comes from a piece of line of Sheldon in The Big Bang Theory. The meaning of coast as a intransitive verb below, and pls interpret it in this particular context above. 1.to slide on a sled down a snowy or icy hillside or incline. 2.to descend a hill or the like, as on a bicycle, without using pedals. 3.to continue to move or advance after effort has ceased; keep going on acquired momentum: We cut off the car engine and coasted for a while. 4.to advance or proceed with little or no effort, especially owing to one's actual or former assets, as wealth, position, or name, or those of another: The actor coasted to stardom on his father's name. 5.to sail along, or call at the various ports of, a coast. 6.Obsolete. to proceed in a roundabout way. All the listed definitions are quoted from [Dictionary.com](http://www.dictionary.com/browse/coast?s=t)
2017/08/23
[ "https://ell.stackexchange.com/questions/139991", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/56715/" ]
In this context "to coast" has the same meaning as the idiomatic expression ["to rest on one's laurels"](http://www.phrases.org.uk/meanings/rest-on-his-laurels.html): *To be satisfied with one's past success and to consider further effort unnecessary.* In this case, the character in the show is saying that his father felt that getting a "World's Greatest Dad" mug was sufficient enough glory that he didn't have to strive for any further achievement.
Definition #4 fits the use accurately. It refers to someone who has rested on his laurels (to use another phrase), and "coasted" through life or career based on prior accomplishments.
58,187,832
Code speaks more than thousand words, so... This is undefined behaviour for mutating a `const int`: ``` struct foo { int x; void modify() { x = 3; } }; void test_foo(const foo& f) { const_cast<foo&>(f).modify(); } int main(){ const foo f{2}; test_foo(f); } ``` What about this: ``` struct bar { void no_modify() { } }; void test_bar(const bar& b) { const_cast<bar&>(b).no_modify(); } int main(){ const bar b; test_bar(b); } ``` **Is it allowed to call a non-const method on a const object (via `const_cast`) when the method does not mutate the object?** **PS**: I know that `no_modify` should have been declared as `const` and then the question is pointless, but assume `bar`s definition cannot change. **PPS**: Just do be sure: Dont do this at home (or anywhere else). I'd never let such code pass a review. The cast can be avoided trivially. This is a language-lawyer question.
2019/10/01
[ "https://Stackoverflow.com/questions/58187832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4117728/" ]
The behaviour of your code is well-defined. The only thing that matters is if you actually modify the object. You don't. All you do is call a member function, and that function does not modify the object.
In the C++14 standard N4296 that I have access to we see a note in 5.2.11/6: > > [ Note: Depending on the type of the object, a write operation through > the pointer, lvalue or pointer to data member resulting from a > const\_cast that casts away a const-qualifier74 may produce undefined > behavior (7.1.6.1). —end note ] > > > Technically I suspect the note may not be normative but it seems clear that the intention here is that casting away const-ness only becomes undefined behavior when a write is attempted through the pointer/reference (possibly to help support legacy code that didn't follow proper const-correctness).
7,608,159
I have an html page called test.html, here is it's content: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body style="margin: 0; padding: 0; background: #d9d9d9;"> <form name="form1" method="post" action="NewsLetterPreview.aspx?NewsletterID=1" id="form1"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTA3NzM3OTc4N2Rkkk3StA9iwyEdCoR43JPpw6OyRHubNTnbXatTbxCXsVA=" /> </div> </form> </body> </html> ``` I then have another page which I am using $.get to get the content of the page: ``` $.get("test.html", function (data) { alert($(data).find("body").html()); }); ``` However the `alert($(data).find("body").html())` returns null. It does the same for the `alert($(data).find("form").html())` also. Only if I specify `alert($(data).find("div").html())` does it return the input field. How can I select the body / form?
2011/09/30
[ "https://Stackoverflow.com/questions/7608159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/520712/" ]
If you want to replace your body with fetched HTML, this should do it. ``` $.get("test.html", function (data) { $(body).html(data); }); ``` **EDIT:** Missread your question. It'd suggest you to use json or .replace() instead. Example: `alert(data.replace(/^.*?\<body\>(.*?)\<\/body\>.*$/, "$1"));` If you want body tags included: `alert(data.replace(/^.*?(\<body\>.*?\<\/body\>).*$/, "$1"));` I don't think jquery can work with HTML the way you wish. Either include it in the code and then use regular functions or find another workaround.
I am not sure of the solution, but I think I can shed some light on the problem... From here: <http://api.jquery.com/jQuery/> > > When passing in complex HTML, some browsers may not generate a DOM > that exactly replicates the HTML source provided. As mentioned, we use > the browser's .innerHTML property to parse the passed HTML and insert > it into the current document. During this process, some browsers > filter out certain elements such as , , or > elements. As a result, the elements inserted may not be representative > of the original string passed. > > > Which means that on *some browsers* the HTML string being input has the form, head, and body tags stripped out before jQuery processes the string - so it is as if your returned string only has the div and it's contents.
594,709
[RFC 1034](https://serverfault.com/a/82606/87017) requires us to assign at least two IP addresses for DNS servers. However, redundancy can already be achieved by a single IP address if we use anycast addressing. BGP anycast seems to scale well into hundreds or even thousands of servers. If so, why do we still need multiple IP addresses for DNS servers? Does it actually enhance redundancy (contribute to availability) if we already have anycast in place, or is it just a myth? **What problems and errors can we expect to face** if we only use a single IP address? By that, I mean totally omitting secondary DNS addresses, or using a bogus IP (e.g. `1.2.3.4`) for the second address when some setups require at least two.
2014/05/13
[ "https://serverfault.com/questions/594709", "https://serverfault.com", "https://serverfault.com/users/87017/" ]
A single anycast IP address does not give you the same redundancy as two unicast IP addresses in distinct IP prefixes would. Often the hardest problem for redundancy is not when something fails completely, but rather when it is misbehaving just enough to still pass the health checks, but not actually be functional. I have seen an anycast DNS setup where a DNS server went down, but packets would still get routed to that DNS server. Whatever was taking care of advertising the prefix might simply not be aware, that the DNS server had gone down. It becomes even more tricky if the DNS server in question is not an authoritative DNS server, but rather a recursive resolver. Such a recursive resolver would need to have both the anycast address for receiving queries from clients and unicast addresses for querying authoritative DNS servers. But if the unicast addresses went down, it could easily look healthy enough that it would still be routed queries. Anycast is a great tool for scalability and reducing latency. But for redundancy it should not stand alone. Multiple redundant anycast pools is however a good solution for availability. A well known example is 8.8.8.8 and 8.8.4.4. Both are anycast addresses, but they should never be routed to the same physical DNS server (assuming Google did their job well). If you have 10 physical DNS servers, you could configure them as 2 pools with 5 servers in each pool or 5 pools with 2 in each pool. You want to avoid having one physical DNS server be in multiple pools simultaneously. So how many IPs should you allocate? You need to have IPs that can be configured as anycast independently of each other. That usually means you'll need to allocate an entire /24 of IPv4 address space or /48 of IPv6 address space for each pool. This may very well limit the number of pools you can have. Additionally if we are talking authoritative servers the DNS reply with all your NS records and A and AAAA glue should fit in a single 512 byte packet. For the root servers this worked out to 13 addresses. But that did not include glue and IPv6, so the number you'd reach would be lower. Each pool should be as geographically distributed as possible. If you have 5 servers in Europe and 5 in Noth America and 2 anycast IPs, you do not create one pool spanning each continent. You put 2 from Europe in a pool with 3 from North America, and the other 5 in the other pool. If you have more than 2 anycast pools, you can let a physical server temporarily be in more than one pool. But you should never allow a physical server to be in all pools at the same time. Combining anycast and unicast is possible, but care must be taken. If you have IPs for two pools, I wouldn't combine. But if you only have a single anycast IP to work with, it may make sense to also include unicast IPs. The problem is that including unicast IPs will not give you as good latency and load balancing. If a physical server is made available by both unicast and anycast, you may risk users reaching the same server as primary and secondary and lose access if it goes down. This can be avoided by only using unicast addresses of servers not in the anycast pool or by always providing users with two unicast addresses. The more unicast addresses you put into the mix, the less queries will be sent to the anycast address, and the less benefit you will get from anycast in terms of latency and scalability.
The RFC 1034 only states that you require two DNS servers. This isn't a mandatory requirement, but a recommendation, so do with it what you will. Regardless, if you want HA, your 2 DNS servers can be assigned the same IP using anycast, and the only thing your end users would notice when one DNS server fails, is a momentary lack of connectivity as the network reconverges. So in summary, yes using anycast is sufficient to be RFC 1034 compliant.
594,709
[RFC 1034](https://serverfault.com/a/82606/87017) requires us to assign at least two IP addresses for DNS servers. However, redundancy can already be achieved by a single IP address if we use anycast addressing. BGP anycast seems to scale well into hundreds or even thousands of servers. If so, why do we still need multiple IP addresses for DNS servers? Does it actually enhance redundancy (contribute to availability) if we already have anycast in place, or is it just a myth? **What problems and errors can we expect to face** if we only use a single IP address? By that, I mean totally omitting secondary DNS addresses, or using a bogus IP (e.g. `1.2.3.4`) for the second address when some setups require at least two.
2014/05/13
[ "https://serverfault.com/questions/594709", "https://serverfault.com", "https://serverfault.com/users/87017/" ]
A single anycast IP address does not give you the same redundancy as two unicast IP addresses in distinct IP prefixes would. Often the hardest problem for redundancy is not when something fails completely, but rather when it is misbehaving just enough to still pass the health checks, but not actually be functional. I have seen an anycast DNS setup where a DNS server went down, but packets would still get routed to that DNS server. Whatever was taking care of advertising the prefix might simply not be aware, that the DNS server had gone down. It becomes even more tricky if the DNS server in question is not an authoritative DNS server, but rather a recursive resolver. Such a recursive resolver would need to have both the anycast address for receiving queries from clients and unicast addresses for querying authoritative DNS servers. But if the unicast addresses went down, it could easily look healthy enough that it would still be routed queries. Anycast is a great tool for scalability and reducing latency. But for redundancy it should not stand alone. Multiple redundant anycast pools is however a good solution for availability. A well known example is 8.8.8.8 and 8.8.4.4. Both are anycast addresses, but they should never be routed to the same physical DNS server (assuming Google did their job well). If you have 10 physical DNS servers, you could configure them as 2 pools with 5 servers in each pool or 5 pools with 2 in each pool. You want to avoid having one physical DNS server be in multiple pools simultaneously. So how many IPs should you allocate? You need to have IPs that can be configured as anycast independently of each other. That usually means you'll need to allocate an entire /24 of IPv4 address space or /48 of IPv6 address space for each pool. This may very well limit the number of pools you can have. Additionally if we are talking authoritative servers the DNS reply with all your NS records and A and AAAA glue should fit in a single 512 byte packet. For the root servers this worked out to 13 addresses. But that did not include glue and IPv6, so the number you'd reach would be lower. Each pool should be as geographically distributed as possible. If you have 5 servers in Europe and 5 in Noth America and 2 anycast IPs, you do not create one pool spanning each continent. You put 2 from Europe in a pool with 3 from North America, and the other 5 in the other pool. If you have more than 2 anycast pools, you can let a physical server temporarily be in more than one pool. But you should never allow a physical server to be in all pools at the same time. Combining anycast and unicast is possible, but care must be taken. If you have IPs for two pools, I wouldn't combine. But if you only have a single anycast IP to work with, it may make sense to also include unicast IPs. The problem is that including unicast IPs will not give you as good latency and load balancing. If a physical server is made available by both unicast and anycast, you may risk users reaching the same server as primary and secondary and lose access if it goes down. This can be avoided by only using unicast addresses of servers not in the anycast pool or by always providing users with two unicast addresses. The more unicast addresses you put into the mix, the less queries will be sent to the anycast address, and the less benefit you will get from anycast in terms of latency and scalability.
Best practice is to use at least two addresses from different prefixes and giving them a name under two different TLDs. Both those addresses can be anycast if you want. Having only one IP address will give you a single point of failure. If the routing to that address doesn't work (configuration error, an anycast instance not working correctly, the prefix being hijacked etc) then your whole domain becomes unreachable. Every anycast address will require at least a `/24` IPv4 or a `/48` IPv6 prefix to be routable in BGP. Smaller (longer) prefixes will usually not be accepted in the global routing table in many places. Never ***ever*** put in a bogus IP address as a DNS server. It will cause severe delays for resolvers.
212,251
I want to generate host names for example from my patter like this: `inc-[tnc][app|web][1-10]` where it should output like below: ``` inc-tapp1 inc-tapp2 . . inc-tapp10 inc-napp1 . . inc-capp10 inc-tweb1 . . inc-cweb10 ``` Here t,n,c represents our datacenters in texas, new york and california.
2015/06/25
[ "https://unix.stackexchange.com/questions/212251", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/104377/" ]
Just use bash expansion. ``` $ echo inc-{t,n,c}{app,web}{1..10} inc-tapp1 inc-tapp2 inc-tapp3 inc-tapp4 inc-tapp5 inc-tapp6 inc-tapp7 inc-tapp8 inc-tapp9 inc-tapp10 inc-tweb1 inc-tweb2 inc-tweb3 inc-tweb4 inc-tweb5 inc-tweb6 inc-tweb7 inc-tweb8 inc-tweb9 inc-tweb10 inc-napp1 inc-napp2 inc-napp3 inc-napp4 inc-napp5 inc-napp6 inc-napp7 inc-napp8 inc-napp9 inc-napp10 inc-nweb1 inc-nweb2 inc-nweb3 inc-nweb4 inc-nweb5 inc-nweb6 inc-nweb7 inc-nweb8 inc-nweb9 inc-nweb10 inc-capp1 inc-capp2 inc-capp3 inc-capp4 inc-capp5 inc-capp6 inc-capp7 inc-capp8 inc-capp9 inc-capp10 inc-cweb1 inc-cweb2 inc-cweb3 inc-cweb4 inc-cweb5 inc-cweb6 inc-cweb7 inc-cweb8 inc-cweb9 inc-cweb10 $ ``` Or if you want a line break between each, pipe through tr. ``` $ echo inc-{t,n,c}{app,web}{1..10}|tr " " "\n" inc-tapp1 inc-tapp2 inc-tapp3 [etc] ```
You can use shell brace expansion ``` bash$ echo a{d,c,b}e ade ace abe ``` <http://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html#Brace-Expansion>
7,622,213
There are many ways to see if a value exists using PHP. There's isset, !=false, !==false, !empty, etc. Which one will be the best (fast and accurate) one to use in the following situation? ``` if($_GET['test']) ... ```
2011/10/01
[ "https://Stackoverflow.com/questions/7622213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599184/" ]
`if (isset($_GET['test'])) { // use value }`
``` if(array_key_exists($_GET, "test")) ``` array\_key\_exists return true if a key exists in an array, isset will return true if the key/variable exists and is not null.
7,622,213
There are many ways to see if a value exists using PHP. There's isset, !=false, !==false, !empty, etc. Which one will be the best (fast and accurate) one to use in the following situation? ``` if($_GET['test']) ... ```
2011/10/01
[ "https://Stackoverflow.com/questions/7622213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599184/" ]
``` if(array_key_exists($_GET, "test")) ``` array\_key\_exists return true if a key exists in an array, isset will return true if the key/variable exists and is not null.
isset function only checks for its avaliability you have to use empty function too in order to see if it is set and not empty also as: ``` if (isset($_GET['test']) && !empty($_GET['test'])) { ```
7,622,213
There are many ways to see if a value exists using PHP. There's isset, !=false, !==false, !empty, etc. Which one will be the best (fast and accurate) one to use in the following situation? ``` if($_GET['test']) ... ```
2011/10/01
[ "https://Stackoverflow.com/questions/7622213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599184/" ]
`if (isset($_GET['test'])) { // use value }`
Isset is probably best because it checks if the url contains a "?test=". If you want to make sure it is not empty you have to check further.
7,622,213
There are many ways to see if a value exists using PHP. There's isset, !=false, !==false, !empty, etc. Which one will be the best (fast and accurate) one to use in the following situation? ``` if($_GET['test']) ... ```
2011/10/01
[ "https://Stackoverflow.com/questions/7622213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599184/" ]
`if (isset($_GET['test'])) { // use value }`
isset function only checks for its avaliability you have to use empty function too in order to see if it is set and not empty also as: ``` if (isset($_GET['test']) && !empty($_GET['test'])) { ```
7,622,213
There are many ways to see if a value exists using PHP. There's isset, !=false, !==false, !empty, etc. Which one will be the best (fast and accurate) one to use in the following situation? ``` if($_GET['test']) ... ```
2011/10/01
[ "https://Stackoverflow.com/questions/7622213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599184/" ]
`if (isset($_GET['test'])) { // use value }`
I'd go with the php5 one type of get: ``` $test = filter_input(INPUT_GET, 'test', FILTER_SANITIZE_STRING); if($test){ //do something } ``` Reference [here](http://www.php.net/manual/en/function.filter-input.php), you can validate and sanitize with them. you can use "filter\_input\_array" for the full input types.
7,622,213
There are many ways to see if a value exists using PHP. There's isset, !=false, !==false, !empty, etc. Which one will be the best (fast and accurate) one to use in the following situation? ``` if($_GET['test']) ... ```
2011/10/01
[ "https://Stackoverflow.com/questions/7622213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599184/" ]
Isset is probably best because it checks if the url contains a "?test=". If you want to make sure it is not empty you have to check further.
isset function only checks for its avaliability you have to use empty function too in order to see if it is set and not empty also as: ``` if (isset($_GET['test']) && !empty($_GET['test'])) { ```
7,622,213
There are many ways to see if a value exists using PHP. There's isset, !=false, !==false, !empty, etc. Which one will be the best (fast and accurate) one to use in the following situation? ``` if($_GET['test']) ... ```
2011/10/01
[ "https://Stackoverflow.com/questions/7622213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/599184/" ]
I'd go with the php5 one type of get: ``` $test = filter_input(INPUT_GET, 'test', FILTER_SANITIZE_STRING); if($test){ //do something } ``` Reference [here](http://www.php.net/manual/en/function.filter-input.php), you can validate and sanitize with them. you can use "filter\_input\_array" for the full input types.
isset function only checks for its avaliability you have to use empty function too in order to see if it is set and not empty also as: ``` if (isset($_GET['test']) && !empty($_GET['test'])) { ```
37,534
I have a slightly high pH, 7.2. Nothing bad but I would like to bring it down a little. I was looking at two elements/products whatever you want to call them. One was Aluminum Sulfate and the other was Sulfur. The things I know is it does not take near as much S to bring down pH, were it does take a lot of AlS. But I do not know if there is anything wrong with AlS or S. I would really like to know the negative effects of either, if any. Thanks! AlS - Aluminum Sulfate S - Sulfur
2018/03/14
[ "https://gardening.stackexchange.com/questions/37534", "https://gardening.stackexchange.com", "https://gardening.stackexchange.com/users/14214/" ]
Lowering soil ph isn't a one off treatment - it needs to be ongoing, with frequent soil tests to check its not getting too low. Sulphur is the safest from a planting point of view, but takes longer to work in cold weather. Aluminium sulphate works more quickly, but its easy to overdose - it can build up in the soil to toxic levels, and reduces phosphorus levels, which can cause significant problems for plants. Sulphate of iron is sometimes used, and can create similar issues with phosphorus availability. Another factor is whether there is free lime or chalk in your soil - if there is, then attempts at lowering the ph are not likely to be successful. Information here <https://www.rhs.org.uk/advice/profile?PID=82> Aluminium sulphate and sulphate of iron are usually applied around specific plants rather than applied to a whole area, the former often to produce bluer flowers in Hydrangea, and the latter for similar reasons and to correct leaf chlorosis in acid loving shrubs. You might want to consider finding plants that suit the soil you've got rather than trying to keep the ph lower ongoing if you were thinking to change soil ph in a large area.
The classic old method: manure, especially on your case, where you have a nearly neutral soil. But in general fertilizers acidify the soil, so often this is enough for vegetable garden (one fertilize near seedling). Not doing lawn scarifier helps (also this remove acidity, which is bad for lawn in a acid soil, but not so bad on normal soils). On flower garden: some plants/tree help to acidify soil, so with a good placement of element, you can have a acid corner. Peat-like substances are (should be) also acidifier. Normally plants usually tolerate acid soil (but not extreme), but only plants evolved to tolerate Calcium can live in a non-acid soil: roots absorb nutrients, but if there is much calcium, acid plants absorb calcium and not the other needed substances. About your product: "Sulphur" usually (and unfortunately) is just a nametag. Also that should be a sulphur salt/component. The possible problem: the soil is huge, so nutrients moves, and basic soil will neutralize your acidifier, but the real problem is the watering. Usually water is also not neutral if your soil is not neutral. So you need to acidify periodically. Microorganism could not like many changes on acidity, so soil could become poorer. But this is often a problem on the inverse step: there is already acid parts on soil (see decomposition of leaves), so also acidophile organism. Soil pollution is also a problem, because acidifier could go into groundwater. But this is usually a problem with huge fields (and fertilizing at the same instant such large area). So: check acidity of your water, and the structure of your soil. If water is not so basic, it is ok, else consider to collect rain water (before soil will increase the pH). If soil is light and sandy, your acidification will fail, and basic ions will enter so easily (so you need a waterproof "wall" inside the soil). On the other cases (more common): if you are building new gardening (in deep), you can uses several (and slow) acidifier on the base of soil. In any case, try with more natural methods and limited near root of the vegetables you need to acidify. Sulphur is not so bad (it is a common natural element), just it could wash away and cause some problem on other places, and drastic pH changes kill the soil, but nature will recover quickly.
37,534
I have a slightly high pH, 7.2. Nothing bad but I would like to bring it down a little. I was looking at two elements/products whatever you want to call them. One was Aluminum Sulfate and the other was Sulfur. The things I know is it does not take near as much S to bring down pH, were it does take a lot of AlS. But I do not know if there is anything wrong with AlS or S. I would really like to know the negative effects of either, if any. Thanks! AlS - Aluminum Sulfate S - Sulfur
2018/03/14
[ "https://gardening.stackexchange.com/questions/37534", "https://gardening.stackexchange.com", "https://gardening.stackexchange.com/users/14214/" ]
Lowering soil ph isn't a one off treatment - it needs to be ongoing, with frequent soil tests to check its not getting too low. Sulphur is the safest from a planting point of view, but takes longer to work in cold weather. Aluminium sulphate works more quickly, but its easy to overdose - it can build up in the soil to toxic levels, and reduces phosphorus levels, which can cause significant problems for plants. Sulphate of iron is sometimes used, and can create similar issues with phosphorus availability. Another factor is whether there is free lime or chalk in your soil - if there is, then attempts at lowering the ph are not likely to be successful. Information here <https://www.rhs.org.uk/advice/profile?PID=82> Aluminium sulphate and sulphate of iron are usually applied around specific plants rather than applied to a whole area, the former often to produce bluer flowers in Hydrangea, and the latter for similar reasons and to correct leaf chlorosis in acid loving shrubs. You might want to consider finding plants that suit the soil you've got rather than trying to keep the ph lower ongoing if you were thinking to change soil ph in a large area.
Applying elemental sulfur, or brimstone, to acidify alkaline soil with a high lime content is not cost effective. Bacteria act on the sulfur to turn it into sulfuric acid which acidifies the soil temporarily but then the carbonates present in the soil will return the pH back to what it was before. [![acidification using sulfur](https://i.stack.imgur.com/ZdLcJ.jpg)](https://i.stack.imgur.com/ZdLcJ.jpg) You are better off to apply composted manure and other organic materials. The humic acid present in the compost will free up phosphorus to the plants. You need to maintain a high level of organic material in the ground. <https://www.agvise.com/educational-articles/does-elemental-sulfur-lower-soil-ph/>